Re: [PATCH printk v3 10/14] printk: ringbuffer: Skip non-finalized records in panic

From: Petr Mladek
Date: Thu Feb 01 2024 - 11:57:02 EST


On Thu 2023-12-14 22:47:57, John Ogness wrote:
> Normally a reader will stop once reaching a non-finalized
> record. However, when a panic happens, writers from other CPUs
> (or an interrupted context on the panic CPU) may have been
> writing a record and were unable to finalize it. The panic CPU
> will reserve/commit/finalize its panic records, but these will
> be located after the non-finalized records. This results in
> panic() not flushing the panic messages.
>
> Extend _prb_read_valid() to skip over non-finalized records if
> on the panic CPU.
>
> Fixes: 896fbe20b4e2 ("printk: use the lockless ringbuffer")
> Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>

Makes sense.

The most interesting information from other CPUs are backtraces. But
they should be finalized before reaching panic().
trigger_all_cpu_backtrace() waits until all CPUs print the backtrace.

In fact, it might be even useful because other CPUs might just spam
the ring buffer with mess caused by the panic() situation.
Messages which caused the panic() situation should be in the ring
buffer before panic() gets called.

Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>

Best Regards,
Petr