Re: [PATCH printk v4 17/27] printk: nbcon: Use nbcon consoles in console_flush_all()
From: John Ogness
Date: Wed Apr 17 2024 - 17:59:45 EST
On 2024-04-11, Petr Mladek <pmladek@xxxxxxxx> wrote:
> console_flush_all() is called from console_unlock().
> It might be called in atomic context. But the current
> owner might be theoretically scheduled out.
Nice catch. This problem was introduced in this series after you pointed
out that return value of nbcon_legacy_emit_next_record() did not match
the semantics of console_emit_next_record().
> I see 3 possible solutions:
>
> 1. Enforce that nbcon context can be acquired only with preemtion
> disabled.
Not acceptable.
> 2. Enforce that nbcon context can be acquired only with
> interrupts. It would prevent deadlock when some future
> code interrupt flush in NBCON_PRIO_EMERGENCY context.
> And then a potential nested console_flush_all() won't be
> able to takeover the interrupted NBCON_PRIO_CONTEXT
> and there will be no progress.
Not acceptable.
> 3. console_flush_all() should ignore nbcon console when
> it is not able to get the context, aka no progress.
This was the previous implementation, but as you point out, it is an
issue that console_flush_all() is no longer reliable.
I will continue this topic by responding to your follow-up message.
John