Re: [PATCH printk v2 04/18] printk: nbcon: Introduce printing kthreads

From: Petr Mladek
Date: Fri Jun 14 2024 - 03:40:50 EST


On Thu 2024-06-13 17:27:33, John Ogness wrote:
> On 2024-06-11, Petr Mladek <pmladek@xxxxxxxx> wrote:
> > Honestly, if the system is not able to start the kthread then
> > it is probably useless anyway. I would prefer if printk keeps working
> > so that people know what is going on ;-)
>
> I have been looking into and thinking about this some more. I do not
> like the idea of the system doing some sort of fallback if some of the
> kthreads fail to start. Not only does it complicate the code, but it
> greatly increases the variants of how the system during runtime.

Fair enough.

> I (strongly) suggest the following:
>
> - The kthread is created in nbcon_alloc(). If the kthread fails, then
> nbcon_alloc() fails and the console will not register.
>
> - nbcon_kthread_should_wakeup() will return false if the console is not
> registered or if @have_boot_console=1.

I like this.

I guess that this would require moving some pieces from nbcon_init
to nbcon_alloc(). It might make sense to move there everything except
for setting the initial seq number.

> Then there would be no need to ever check con->kthread. Instead we can
> rely on the global state of the system transitioning to relying on
> threading.
>
> I think it is totally appropriate that register_console() fails if the
> kthread cannot be created, just as it already fails if the kmalloc() for
> the pbufs fails.
>
> Any objections?

Not from my side ;-)

Best Regards,
Petr