Re: [PATCH v1] panic: push panic() messages to the console even from the MCE nmi handler

From: Petr Mladek
Date: Fri Jan 08 2021 - 08:00:24 EST


On Fri 2021-01-08 01:26:06, William Roche wrote:
> On 06/01/2021 05:35, Sergey Senozhatsky wrote:
> > On (21/01/04 16:15), “William Roche wrote:
> >> @@ -271,9 +280,8 @@ void panic(const char *fmt, ...)
> >> */
> >> atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
> >>
> >> - /* Call flush even twice. It tries harder with a single online CPU */
> >> - printk_safe_flush_on_panic();
> >> kmsg_dump(KMSG_DUMP_PANIC);
> >> + panic_flush_to_console();

This is wrong. kmsg_dump() flushes the messages into the registered
dumpers, e.g. pstore. It handles only messages in the main
log buffer.

printk_safe_flush_on_panic() must be called before. It moves any
pending messages from the temporary per-CPU buffers into the main
log buffer so that they are visible for the dumpers.

> > Why?
>
> Here, we are supposed to push the pending messages, as I could verify
> that they don't reach the console until the console_unblank(). So I
> wanted to push them with panic_flush_to_console() before the possible
> upcoming __crash_kexec() call.

I do not see how the ordering of printk_safe_flush_on_panic()
and kmsg_dump() would change anything for the upcoming
__crash_kexec() call.

Best Regards,
Petr