Re: [PATCH v2 1/2] printk: Introduce FORCE_CON flag
From: Petr Mladek
Date: Thu Nov 07 2024 - 10:22:48 EST
On Tue 2024-11-05 16:45:08, Marcos Paulo de Souza wrote:
> Introduce FORCE_CON flag to printk. The new flag will make it possible to
> create a context where printk messages will never be suppressed.
>
> This mechanism will be used in the next patch to create a force_con
> context on sysrq handling, removing an existing workaround on the
> loglevel global variable. The workaround existed to make sure that sysrq
> header messages were sent to all consoles, but this doesn't work with
> deferred messages because the loglevel might be restored to its original
> value before a console flushes the messages.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@xxxxxxxx>
Looks good:
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Just a nit below.
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1319,11 +1319,11 @@ static void boot_delay_msec(int level)
> {
> unsigned long long k;
> unsigned long timeout;
> + bool suppress = !is_printk_force_console() &&
> + suppress_message_printing(level);
>
> - if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
> - || suppress_message_printing(level)) {
> + if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING) || suppress)
> return;
These spaghetti conditions are hard to follow. I would personally
prefer:
if ((boot_delay == 0)
return;
if (system_state >= SYSTEM_RUNNING)
return;
if (suppress_message_printing(level) && !is_printk_force_console())
return;
But I do not resist on it.
Best Regards,
Petr