lkml.org 
[lkml]   [2019]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] panic: add an option to replay all the printk message in buffer
On Thu 2019-04-25 21:32:17, Feng Tang wrote:
> Currently on panic, kernel will lower the loglevel and print out
> pending printk msg only with console_flush_on_panic().
>
> Add an option for users to configure the "panic_print" to replay
> all dmesg in buffer, some of which they may have never seen due
> to the loglevel setting, which will help panic debugging .
>
> @@ -2539,6 +2540,11 @@ void console_flush_on_panic(void)
> */
> console_trylock();
> console_may_schedule = 0;
> +
> + if (mode == CONSOLE_REPLAY_ALL) {
> + console_seq = log_first_seq;
> + console_idx = log_first_idx;

Ah, log_first_seq and log_first_idx are synchronized by
logbuf_log.

console_flush_on_panic(CONSOLE_REPLAY_ALL) is called
when only one CPU is running but it is not guaranteed.

Therefore we should use:

if (mode == CONSOLE_REPLAY_ALL) {
unsigned long flags;

logbuf_lock_irqsave(flags);
console_seq = log_first_seq;
console_idx = log_first_idx;
logbuf_unlock_irqrestore(flags);
}

I am really sorry that I have missed it yesterday.

Anyway, with the above locking, feel free to add:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

\
 
 \ /
  Last update: 2019-04-26 09:50    [W:0.082 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site