Re: [PATCH printk v3 11/19] printk: nbcon: Rely on kthreads for normal operation

From: Petr Mladek
Date: Thu Aug 01 2024 - 05:52:51 EST


On Thu 2024-08-01 11:36:53, Petr Mladek wrote:
> On Wed 2024-07-31 17:31:02, John Ogness wrote:
> > On 2024-07-31, Petr Mladek <pmladek@xxxxxxxx> wrote:
> > >> @@ -4102,8 +4139,10 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
> > >> * that they make forward progress, so only increment
> > >> * @diff for usable consoles.
> > >> */
> > >> - if (!console_is_usable(c, flags, true))
> > >> + if (!console_is_usable(c, flags, true) &&
> > >> + !console_is_usable(c, flags, false)) {
> > >
> > > This looks weird. nbcon console can't make progress when
> > > "write_atomic" is not implemented and the kthreads are not
> > > running.
> > >
> > > I should be:
> > >
> > > if (!((console_is_usable(c, flags, true)) ||
> > > (console_is_usable(c, flags, false) && printk_kthreads_running))) {
> >
> > I would prefer to have the printk_kthreads_running check within
> > console_is_usable() for the !use_atomic case.
>
> Makes sense.

I have realized right after sending the reply that it actually did
not make sense.

We try to use con->write_thread also in

+ console_flush_all()
+ nbcon_legacy_emit_next_record()
+ nbcon_emit_one()
+ nbcon_emit_next_record()

when (@do_cond_resched == true) => (@use_atomic == false)

=> __pr_flush() actually should be able to flush the messages using
con->write_thread() even when the kthreads are not running.


Result:

IMHO, we should not check @printk_kthreads_running at all after all.

Sigh, it might make sense to document the design from a top level
view somewhere. We should do it at the end before we forget
the details.

Best Regards,
Petr