Re: [PATCH printk v2 1/2] printk/nbcon: Flush nbcon_irq_work in nbcon_free()

From: Petr Mladek

Date: Tue Sep 01 2026 - 03:44:38 EST


On Mon 2026-08-31 17:15:35, John Ogness wrote:
> On 2026-08-31, Petr Mladek <pmladek@xxxxxxxx> wrote:
> >> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> >> index a5921a84a80ed..218b1922a58de 100644
> >> --- a/kernel/printk/nbcon.c
> >> +++ b/kernel/printk/nbcon.c
> >> @@ -1849,6 +1849,8 @@ void nbcon_free(struct console *con)
> >> printk_kthreads_running = false;
> >> }
> >>
> >> + irq_work_sync(&con->irq_work);
> >
> > The irq_work work tries to wake up the printk kthread which
> > has been destroyed above.
>
> Note that the irq_work only wakes up con->rcuwait waiters. Since the
> kthread has already ended, it certainly is not waiting and there is no
> wakeup.

Yes, but this is an implementation detail.

> The irq_work_sync() call is literally just to clear out the irq_work
> queue, not to actually wake anything.

I still believe that this should rather be done before the kthread
is destroyed. IMHO, it would be more logical there. Or is there any
reason why you would prefer to flush it later?

I am sorry for being so stubborn. It is not a big deal.
The current ordering just looks suspicious and weird.
I could live with it. This is my last attempt to convince you ;-)

Best Regards,
Petr