Re: [PATCH] printk: restore flushing of NMI buffers on remote CPUs after NMI backtraces

From: Petr Mladek
Date: Wed Nov 10 2021 - 10:25:59 EST


On Sun 2021-11-07 14:51:16, Nicholas Piggin wrote:
> printk from NMI context relies on irq work being raised on the local CPU
> to print to console. This can be a problem if the NMI was raised by a
> lockup detector to print lockup stack and regs, because the CPU may not
> enable irqs (because it is locked up).
>
> Introduce printk_trigger_flush() that can be called another CPU to try
> to get those messages to the console, call that where printk_safe_flush
> was previously called.
>
> --- a/arch/powerpc/kernel/watchdog.c
> +++ b/arch/powerpc/kernel/watchdog.c
> @@ -227,6 +227,12 @@ static void watchdog_smp_panic(int cpu)
> cpumask_clear(&wd_smp_cpus_ipi);
> }

The above context did not apply. I guess that it is a pending change
that did not even reached linux-next yet.

The pushed code might be seen at
https://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git/commit/?h=rework/printk_safe-removal&id=5d5e4522a7f404d1a96fd6c703989d32a9c9568d

>
> + /*
> + * Force flush any remote buffers that might be stuck in IRQ context
> + * and therefore could not run their irq_work.
> + */
> + printk_trigger_flush();
> +
> if (hardlockup_panic)
> nmi_panic(NULL, "Hard LOCKUP");
>

The patch has been committed into printk/linux.git,
branch rework/printk_safe-removal.

I am going to add it into the pull request for 5.16-rc2 following week.

Best Regards,
Petr