Re: [RFC PATCH v1] panic: Flush unsafe consoles before panic reboot
From: John Ogness
Date: Mon Nov 02 2026 - 18:23:11 EST
On 2026-11-02, Petr Mladek <pmladek@xxxxxxxx> wrote:
> I have a crazy idea and do this:
>
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -1688,7 +1688,20 @@ static void __nbcon_atomic_flush_pending(u64 stop_seq)
> */
> void nbcon_atomic_flush_pending(void)
> {
> - __nbcon_atomic_flush_pending(prb_next_reserve_seq(prb));
> + u64 stop_seq = prb_next_reserve_seq(prb);
> +
> + __nbcon_atomic_flush_pending(stop_seq, false);
> +
> + /*
> + * This is a compromise. Otherwise, NBCON consoles would never
> + * have a chance to show messages in the panic paths where
> + * the unsafe flush is not explicitely called.
> + */
> + if (panic_on_this_cpu() && oops_in_progress) {
> + panic_nbcon_allow_unsafe_takeover = true;
> + __nbcon_atomic_flush_pending(stop_seq, true);
> + panic_nbcon_allow_unsafe_takeover = false;
> + }
> }
>
> It would allow to flush the messages directly by printk().
>
> I know that it would be a step back in the reliability. But showing
> the messages looks more important to me than a reliable reboot.
> And we could make it configurable when needed.
>
> Also we could add more checks. For example, do the unsafe flush only
> when "num_online_cpus == 1" or so.
I can accept this, since legacy-netconsole had these risks anyway. My
only concern is when we add an interface for the unsafe flushing policy,
will we continue to have unsafe flushing be the default for netconsole?
I guess we would need to keep it the same to avoid regressions (just as
we need to have it on by default now).
John