Commit f92b070f authored by Petr Mladek's avatar Petr Mladek

printk: Do not miss new messages when replaying the log

The variable "exclusive_console" is used to reply all existing messages
on a newly registered console. It is cleared when all messages are out.

The problem is that new messages might appear in the meantime. These
are then visible only on the exclusive console.

The obvious solution is to clear "exclusive_console" after we replay
all messages that were already proceed before we started the reply.
Reported-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Link: http://lkml.kernel.org/r/20180913123406.14378-1-pmladek@suse.com
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: linux-kernel@vger.kernel.org
Acked-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
parent a06b0c82
...@@ -423,6 +423,7 @@ static u32 log_next_idx; ...@@ -423,6 +423,7 @@ static u32 log_next_idx;
/* the next printk record to write to the console */ /* the next printk record to write to the console */
static u64 console_seq; static u64 console_seq;
static u32 console_idx; static u32 console_idx;
static u64 exclusive_console_stop_seq;
/* the next printk record to read after the last 'clear' command */ /* the next printk record to read after the last 'clear' command */
static u64 clear_seq; static u64 clear_seq;
...@@ -2009,6 +2010,7 @@ static u64 syslog_seq; ...@@ -2009,6 +2010,7 @@ static u64 syslog_seq;
static u32 syslog_idx; static u32 syslog_idx;
static u64 console_seq; static u64 console_seq;
static u32 console_idx; static u32 console_idx;
static u64 exclusive_console_stop_seq;
static u64 log_first_seq; static u64 log_first_seq;
static u32 log_first_idx; static u32 log_first_idx;
static u64 log_next_seq; static u64 log_next_seq;
...@@ -2376,6 +2378,12 @@ void console_unlock(void) ...@@ -2376,6 +2378,12 @@ void console_unlock(void)
goto skip; goto skip;
} }
/* Output to all consoles once old messages replayed. */
if (unlikely(exclusive_console &&
console_seq >= exclusive_console_stop_seq)) {
exclusive_console = NULL;
}
len += msg_print_text(msg, len += msg_print_text(msg,
console_msg_format & MSG_FORMAT_SYSLOG, console_msg_format & MSG_FORMAT_SYSLOG,
text + len, text + len,
...@@ -2418,10 +2426,6 @@ void console_unlock(void) ...@@ -2418,10 +2426,6 @@ void console_unlock(void)
console_locked = 0; console_locked = 0;
/* Release the exclusive_console once it is used */
if (unlikely(exclusive_console))
exclusive_console = NULL;
raw_spin_unlock(&logbuf_lock); raw_spin_unlock(&logbuf_lock);
up_console_sem(); up_console_sem();
...@@ -2706,6 +2710,7 @@ void register_console(struct console *newcon) ...@@ -2706,6 +2710,7 @@ void register_console(struct console *newcon)
* the already-registered consoles. * the already-registered consoles.
*/ */
exclusive_console = newcon; exclusive_console = newcon;
exclusive_console_stop_seq = console_seq;
} }
console_unlock(); console_unlock();
console_sysfs_notify(); console_sysfs_notify();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment