On Wed 2026-11-11 19:25:17, John Ogness wrote:
> Prepare for per-console atomic flushing policies by introducing
> enum pr_flush_reason to classify various reasons for performing a
> printk backlog flush. The reasons are specified for
> printk_trigger_flush() and console_flush_on_panic().
> 
> For atomic printing from printk_trigger_flush(), propagate the
> reason down to __nbcon_atomic_flush_pending_con(), where the actual
> atomic flushing is executed.
> 
> For legacy printing, use a new global variable @legacy_flush_reason
> to track the reason in case nbcon consoles are using legacy
> printing.
> 
> Update all printk_trigger_flush() and console_flush_on_panic()
> call sites as well as any explicit lower-level atomic flush calls
> to specify the reason.
> 
> Note that PR_FLUSH_RUNTIME is used for cases where the reason for
> the flush is not clearly defined.

> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -145,6 +145,24 @@ void early_printk(const char *s, ...) { }
>  
>  struct dev_printk_info;
>  
> +/**
> + * enum pr_flush_reason - Reason for a flush
> + * @PR_FLUSH_RUNTIME:        A flush while the kernel is running
> + * @PR_FLUSH_RESTART:        The kernel is ending, but another instance 
> should
> + *                   follow (reboot, kexec)
> + * @PR_FLUSH_HANG:   The kernel is ending and will enter an infinite loop
> + * @PR_FLUSH_KDB:    Printing while KDB is active
> + *
> + * Flush reasons are used to determine if unsafe atomic flushing should be
> + * performed, based on individual console policies.
> + */
> +enum pr_flush_reason {
> +     PR_FLUSH_RUNTIME = 0,
> +     PR_FLUSH_RESTART,
> +     PR_FLUSH_HANG,
> +     PR_FLUSH_KDB,
> +};

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

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

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

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


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.

Best Regards,
Petr

Reply via email to