Re: [PATCH printk v2 1/6] printk: Introduce and specify flush reasons

From: John Ogness

Date: Mon Nov 16 2026 - 12:20:29 EST


On 2026-11-13, Petr Mladek <pmladek@xxxxxxxx> wrote:
> This entire patchset adds a lot of complexity just to enable all
> 4 new policy flags for netconsole in the last patch.
>
> There already have few dimensions which affect console flushing:
>
> + console_loglevel
> + nbcon_prio

"Dimensions" is the correct word. These are orthogonal:

+ console_loglevel: which messages to print
+ nbcon_prio: which context is allowed access to hardware
+ pr_flush_reason: reason for atomic flushing
+ unsafe_flush_flags: policy when unsafe flushing is acceptable

I do not see a single property above where a value in one implies a
value in another.

> This patchset adds 8 new terms in pr_flush_reason and
> nbcon_unsafe_flush_flags just to explicitly set all
> flush_flags in netconsole.
>
> Let's start with pr_flush_reason. I am not sure if it is worth it:
>
> + PR_FLUSH_RUNTIME is the default
>
> + PR_FLUSH_RESTART can be detected by system_state > SYSTEM_RUNNING

This does not cover the panic-restart case.

> + PR_FLUSH_HANG has only one caller currently distinguished by
> the global panic_nbcon_allow_unsafe_takeover

In my series there is another user:

arch/loongarch/kernel/reset.c:machine_halt()

> + PR_FLUSH_KDB can be detected by kdb_trap_printk and
> kdb_printf_cpu, see vprintk() implementation.

Ack. PR_FLUSH_RUNTIME could cover this case.

> IMHO, it makes things worse because nbcon_atomic_flush_pending() has
> to use PR_FLUSH_RUNTIME in vprintk_emit(). But I think that we
> would like to flush it the same way as an explicit flush called
> in the given context.

You write it backwards. vprintk_emit() uses
nbcon_atomic_flush_pending(). Calling printk() (a single record) is
quite different than calling printk_trigger_flush() (flushing a
backlog).

Let us discuss this after I respond to your comments on patch 2/6. There
you include many details and suggestions that require closer inspection.

John