summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2012-04-02 01:23:04 +0200
committerKay Sievers <kay.sievers@vrfy.org>2012-04-02 01:23:04 +0200
commitd935ff9bed7815bff2bdb12ed7702e46964cc8a2 (patch)
tree639fa9121c4f8ff4102b26785513f55f2ee29453
parentf9c5acade14194332a9ea04973e9e0aa9cadbb33 (diff)
downloadpatches-d935ff9bed7815bff2bdb12ed7702e46964cc8a2.tar.gz
printk: fix log_next()
-rw-r--r--printk.patch80
1 files changed, 45 insertions, 35 deletions
diff --git a/printk.patch b/printk.patch
index 3bc374c..09870ce 100644
--- a/printk.patch
+++ b/printk.patch
@@ -100,15 +100,15 @@ devices, drivers, subsystems, classes and types of messages.
SYSLOG_FACILITY=3
PRIORITY=6
SEQNUM=863
- TIMESTAMP=3679024
- MESSAGE=udevd[83]: starting version 175
+ TIMESTAMP=2479024
+ MESSAGE=udevd[71]: starting version 182
...
PRIORITY=6
SEQNUM=1012
- TIMESTAMP=7169447
- MESSAGE=usb 2-1.4: MAC-Address: 02:80:37:ec:02:00
+ TIMESTAMP=4069447
+ MESSAGE=usb 2-1.4: MAC-Address: 02:80:37:e6:12:00
SUBSYSTEM=usb
DEVICE=c189:130
@@ -117,8 +117,8 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
drivers/base/core.c | 49 +
drivers/char/mem.c | 40 -
include/linux/printk.h | 13
- kernel/printk.c | 1384 +++++++++++++++++++++++++++++++++----------------
- 4 files changed, 1017 insertions(+), 469 deletions(-)
+ kernel/printk.c | 1394 +++++++++++++++++++++++++++++++++----------------
+ 4 files changed, 1027 insertions(+), 469 deletions(-)
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -322,7 +322,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
* If exclusive_console is non-NULL then only this console is to be printed to.
*/
static struct console *exclusive_console;
-@@ -146,12 +127,539 @@ EXPORT_SYMBOL(console_set_on_cmdline);
+@@ -146,12 +127,549 @@ EXPORT_SYMBOL(console_set_on_cmdline);
static int console_may_schedule;
#ifdef CONFIG_PRINTK
@@ -482,7 +482,10 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
+{
+ struct log *msg = (struct log *)(log_buf + idx);
+
-+ /* length == 0 indicates the end of the buffer; wrap */
++ /*
++ * A length == 0 record is the end of buffer marker. Wrap around and
++ * read the message at the start of the buffer.
++ */
+ if (!msg->len)
+ return (struct log *)log_buf;
+ return msg;
@@ -494,8 +497,15 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
+ struct log *msg = (struct log *)(log_buf + idx);
+
+ /* length == 0 indicates the end of the buffer; wrap */
-+ if (!msg->len)
-+ return 0;
++ /*
++ * A length == 0 record is the end of buffer marker. Wrap around and
++ * read the message at the start of the buffer as *this* one, and
++ * return the one after that.
++ */
++ if (!msg->len) {
++ msg = (struct log *)log_buf;
++ return msg->len;
++ }
+ return idx + msg->len;
+}
+
@@ -865,7 +875,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
#ifdef CONFIG_KEXEC
/*
-@@ -165,9 +673,9 @@ static int saved_console_loglevel = -1;
+@@ -165,9 +683,9 @@ static int saved_console_loglevel = -1;
void log_buf_kexec_setup(void)
{
VMCOREINFO_SYMBOL(log_buf);
@@ -877,7 +887,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
}
#endif
-@@ -191,7 +699,6 @@ early_param("log_buf_len", log_buf_len_s
+@@ -191,7 +709,6 @@ early_param("log_buf_len", log_buf_len_s
void __init setup_log_buf(int early)
{
unsigned long flags;
@@ -885,7 +895,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
char *new_log_buf;
int free;
-@@ -219,20 +726,8 @@ void __init setup_log_buf(int early)
+@@ -219,20 +736,8 @@ void __init setup_log_buf(int early)
log_buf_len = new_log_buf_len;
log_buf = new_log_buf;
new_log_buf_len = 0;
@@ -908,7 +918,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
raw_spin_unlock_irqrestore(&logbuf_lock, flags);
pr_info("log_buf_len: %d\n", log_buf_len);
-@@ -332,11 +827,165 @@ static int check_syslog_permissions(int
+@@ -332,11 +837,165 @@ static int check_syslog_permissions(int
return 0;
}
@@ -1077,7 +1087,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
int error;
error = check_syslog_permissions(type, from_file);
-@@ -364,28 +1013,14 @@ int do_syslog(int type, char __user *buf
+@@ -364,28 +1023,14 @@ int do_syslog(int type, char __user *buf
goto out;
}
error = wait_event_interruptible(log_wait,
@@ -1109,7 +1119,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
/* FALL THRU */
/* Read last kernel messages */
case SYSLOG_ACTION_READ_ALL:
-@@ -399,52 +1034,11 @@ int do_syslog(int type, char __user *buf
+@@ -399,52 +1044,11 @@ int do_syslog(int type, char __user *buf
error = -EFAULT;
goto out;
}
@@ -1164,7 +1174,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
/* Disable logging to console */
case SYSLOG_ACTION_CONSOLE_OFF:
if (saved_console_loglevel == -1)
-@@ -472,7 +1066,33 @@ int do_syslog(int type, char __user *buf
+@@ -472,7 +1076,33 @@ int do_syslog(int type, char __user *buf
break;
/* Number of chars in the log buffer */
case SYSLOG_ACTION_SIZE_UNREAD:
@@ -1199,7 +1209,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
break;
/* Size of the log buffer */
case SYSLOG_ACTION_SIZE_BUFFER:
-@@ -501,29 +1121,11 @@ void kdb_syslog_data(char *syslog_data[4
+@@ -501,29 +1131,11 @@ void kdb_syslog_data(char *syslog_data[4
{
syslog_data[0] = log_buf;
syslog_data[1] = log_buf + log_buf_len;
@@ -1231,7 +1241,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
static bool __read_mostly ignore_loglevel;
static int __init ignore_loglevel_setup(char *str)
-@@ -540,142 +1142,33 @@ MODULE_PARM_DESC(ignore_loglevel, "ignor
+@@ -540,142 +1152,33 @@ MODULE_PARM_DESC(ignore_loglevel, "ignor
"print all kernel messages to the console.");
/*
@@ -1393,7 +1403,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
}
/*
-@@ -700,16 +1193,6 @@ static void zap_locks(void)
+@@ -700,16 +1203,6 @@ static void zap_locks(void)
sema_init(&console_sem, 1);
}
@@ -1410,7 +1420,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
/* Check if we have any console registered that can be called early in boot. */
static int have_callable_console(void)
{
-@@ -722,51 +1205,6 @@ static int have_callable_console(void)
+@@ -722,51 +1215,6 @@ static int have_callable_console(void)
return 0;
}
@@ -1462,7 +1472,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
/*
* Can we actually use the console at this time on this cpu?
*
-@@ -810,17 +1248,12 @@ static int console_trylock_for_printk(un
+@@ -810,17 +1258,12 @@ static int console_trylock_for_printk(un
retval = 0;
}
}
@@ -1481,7 +1491,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
int printk_delay_msec __read_mostly;
-@@ -836,15 +1269,22 @@ static inline void printk_delay(void)
+@@ -836,15 +1279,22 @@ static inline void printk_delay(void)
}
}
@@ -1511,7 +1521,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
boot_delay_msec();
printk_delay();
-@@ -856,7 +1296,7 @@ asmlinkage int vprintk(const char *fmt,
+@@ -856,7 +1306,7 @@ asmlinkage int vprintk(const char *fmt,
/*
* Ouch, printk recursed into itself!
*/
@@ -1520,7 +1530,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
/*
* If a crash is occurring during printk() on this CPU,
* then try to get the crash message out but make sure
-@@ -873,97 +1313,92 @@ asmlinkage int vprintk(const char *fmt,
+@@ -873,97 +1323,92 @@ asmlinkage int vprintk(const char *fmt,
lockdep_off();
raw_spin_lock(&logbuf_lock);
@@ -1689,7 +1699,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
*/
if (console_trylock_for_printk(this_cpu))
console_unlock();
-@@ -974,12 +1409,73 @@ out_restore_irqs:
+@@ -974,12 +1419,73 @@ out_restore_irqs:
return printed_len;
}
@@ -1765,7 +1775,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
{
}
-@@ -1217,7 +1713,7 @@ int is_console_locked(void)
+@@ -1217,7 +1723,7 @@ int is_console_locked(void)
}
/*
@@ -1774,7 +1784,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
*/
#define PRINTK_BUF_SIZE 512
-@@ -1253,6 +1749,10 @@ void wake_up_klogd(void)
+@@ -1253,6 +1759,10 @@ void wake_up_klogd(void)
this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
}
@@ -1785,7 +1795,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
/**
* console_unlock - unlock the console system
*
-@@ -1263,15 +1763,16 @@ void wake_up_klogd(void)
+@@ -1263,15 +1773,16 @@ void wake_up_klogd(void)
* by printk(). If this is the case, console_unlock(); emits
* the output prior to releasing the lock.
*
@@ -1805,7 +1815,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
if (console_suspended) {
up(&console_sem);
-@@ -1281,17 +1782,41 @@ void console_unlock(void)
+@@ -1281,17 +1792,41 @@ void console_unlock(void)
console_may_schedule = 0;
again:
@@ -1855,7 +1865,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
start_critical_timings();
local_irq_restore(flags);
}
-@@ -1312,8 +1837,7 @@ again:
+@@ -1312,8 +1847,7 @@ again:
* flush, no worries.
*/
raw_spin_lock(&logbuf_lock);
@@ -1865,7 +1875,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
raw_spin_unlock_irqrestore(&logbuf_lock, flags);
if (retry && console_trylock())
-@@ -1549,7 +2073,8 @@ void register_console(struct console *ne
+@@ -1549,7 +2083,8 @@ void register_console(struct console *ne
* for us.
*/
raw_spin_lock_irqsave(&logbuf_lock, flags);
@@ -1875,7 +1885,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
raw_spin_unlock_irqrestore(&logbuf_lock, flags);
/*
* We're about to replay the log buffer. Only do this to the
-@@ -1758,6 +2283,9 @@ int kmsg_dump_unregister(struct kmsg_dum
+@@ -1758,6 +2293,9 @@ int kmsg_dump_unregister(struct kmsg_dum
}
EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
@@ -1885,7 +1895,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
/**
* kmsg_dump - dump kernel log to kernel message dumpers.
* @reason: the reason (oops, panic etc) for dumping
-@@ -1767,8 +2295,7 @@ EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
+@@ -1767,8 +2305,7 @@ EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
*/
void kmsg_dump(enum kmsg_dump_reason reason)
{
@@ -1895,7 +1905,7 @@ Signed-off-by: Kay Sievers <kay@vrfy.org>
struct kmsg_dumper *dumper;
const char *s1, *s2;
unsigned long l1, l2;
-@@ -1780,24 +2307,27 @@ void kmsg_dump(enum kmsg_dump_reason rea
+@@ -1780,24 +2317,27 @@ void kmsg_dump(enum kmsg_dump_reason rea
/* Theoretically, the log could move on after we do this, but
there's not a lot we can do about that. The new messages
will overwrite the start of what we dump. */