Re: printk: selective deactivation of feature ignoring non panic cpu's messages

From: John Ogness
Date: Tue Mar 04 2025 - 09:01:03 EST


On 2025-03-04, Petr Mladek <pmladek@xxxxxxxx> wrote:
> I mean something like:
>
> --- a/kernel/printk/printk_ringbuffer.c
> +++ b/kernel/printk/printk_ringbuffer.c
> @@ -2143,7 +2143,9 @@ static bool _prb_read_valid(struct printk_ringbuffer *rb, u64 *seq,
> * But it would have the sequence number returned
> * by "prb_next_reserve_seq() - 1".
> */
> - if (this_cpu_in_panic() && ((*seq + 1) < prb_next_reserve_seq(rb)))
> + if (this_cpu_in_panic() &&
> + (!printk_debug_non_panic_cpus || legacy_allow_panic_sync) &&
> + ((*seq + 1) < prb_next_reserve_seq(rb)))
> (*seq)++;
> else
> return false;

Ah, OK. Thanks for the clarification

> OK, I propose the following changes:
>
> + rename the option to "printk_debug_non_panic_cpus"
>
> + do not skip the messages in _prb_read_valid() when this option
> is used before the non-panic CPUs are stopped.

And of course:

+ allow non-panic CPUs in panic to store messages when this option
is set

I would also keep the dump_stack_lvl() implementation as it is, even if
it could lead to interweaving of backtraces. Anyone using
printk_debug_non_panic_cpus should have CONFIG_PRINTK_CALLER enabled.

John