Re: [PATCH printk v4 6/8] console: Support unsafe flushing for panic/emergency restarts
From: John Ogness
Date: Thu Nov 26 2026 - 05:45:36 EST
On 2026-11-25, Petr Mladek <pmladek@xxxxxxxx> wrote:
> Many different flags are mixed in this function:
>
> 1. CON_NBCON_ATOMIC_UNSAFE from enum cons_flags
> 2. NBCON_PRIO_* from enum nbcon_prio
> 3. PR_FLUSH_* from enum pr_flush_reason
> 4. NBCON_*_FLUSH from enum nbcon_unsafe_flush_flags (flush policy)
>
> It is easy to get lost. I wonder if we could do better. ;-)
>
> Ad 1st: CON_NBCON_ATOMIC_UNSAFE is not ideal. But it is done. And
> I am not sure how to make it better.
>
> Ad 2nd: NBCON_PRIO matches nbcon_prio. It look good.
>
> Ad 3rd: PR_FLUSH is not that good. It would be better to
> emphasize that it is a "reason".
>
> I would prefer to use the longer PR_FLUSH_REASON_ prefix.
> It will be consistent with "enum pr_flush_reason" type name
> and more clear.
OK.
> Ad 4th: Both NBCON_*_FLUSH and enum nbcon_unsafe_flush_flags are far
> from clear. And they are not consistent. Sigh, it would be
> great to emphasize "unsafe", "flush" and "policy".
>
> I think about:
>
> enum nbcon_unsafe_flush_policy {
> NBCON_UFP_PANIC_RESTART = BIT(0),
> NBCON_UFP_EMERGENCY_RESTART = BIT(1),
> };
>
> or maybe even better
>
> enum nbcon_unsafe_flush_policy {
> NBCON_UF_POLICY_PANIC_RESTART = BIT(0),
> NBCON_UF_POLICY_EMERGENCY_RESTART = BIT(1),
> };
I am fine with the latter.
> plus use:
>
> struct console {
> [...]
> unsigned int unsafe_flush_policy;
OK.
> and finally the local variable "uf_policy".
OK.
John