summaryrefslogtreecommitdiff
path: root/kernel/printk
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>2018-04-19 10:42:50 +0900
committerPetr Mladek <pmladek@suse.com>2018-04-25 13:26:02 +0200
commit43a17111c2553925f65e7be9b9c3f9d90cf29a8b (patch)
tree3e14a2ad36779608bc6d4d3bfbdb12ef6c5482d2 /kernel/printk
parent357aa6aefebe888c712152cb83c9e700f98eebd1 (diff)
printk: wake up klogd in vprintk_emit
We wake up klogd very late - only when current console_sem owner is done pushing pending kernel messages to the serial/net consoles. In some cases this results in lost syslog messages, because kernel log buffer is a circular buffer and if we don't wakeup syslog long enough there are chances that logbuf simply will wrap around. The patch moves the klogd wake up call to vprintk_emit(), which is the only legit way for a kernel message to appear in the logbuf, right after the attempt to handle consoles. As a result, klogd will get waken either after flushing the new message to consoles or immediately when consoles are still busy with older messages. Link: http://lkml.kernel.org/r/20180419014250.5692-1-sergey.senozhatsky@gmail.com To: Steven Rostedt <rostedt@goodmis.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'kernel/printk')
-rw-r--r--kernel/printk/printk.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 704e55129c3a..fba995b305b1 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1907,6 +1907,7 @@ asmlinkage int vprintk_emit(int facility, int level,
preempt_enable();
}
+ wake_up_klogd();
return printed_len;
}
EXPORT_SYMBOL(vprintk_emit);
@@ -2288,9 +2289,7 @@ void console_unlock(void)
{
static char ext_text[CONSOLE_EXT_LOG_MAX];
static char text[LOG_LINE_MAX + PREFIX_MAX];
- static u64 seen_seq;
unsigned long flags;
- bool wake_klogd = false;
bool do_cond_resched, retry;
if (console_suspended) {
@@ -2334,11 +2333,6 @@ again:
printk_safe_enter_irqsave(flags);
raw_spin_lock(&logbuf_lock);
- if (seen_seq != log_next_seq) {
- wake_klogd = true;
- seen_seq = log_next_seq;
- }
-
if (console_seq < log_first_seq) {
len = sprintf(text, "** %u printk messages dropped **\n",
(unsigned)(log_first_seq - console_seq));
@@ -2396,7 +2390,7 @@ skip:
if (console_lock_spinning_disable_and_check()) {
printk_safe_exit_irqrestore(flags);
- goto out;
+ return;
}
printk_safe_exit_irqrestore(flags);
@@ -2428,10 +2422,6 @@ skip:
if (retry && console_trylock())
goto again;
-
-out:
- if (wake_klogd)
- wake_up_klogd();
}
EXPORT_SYMBOL(console_unlock);