Re: [PATCH] printk: CON_PRINTBUFFER console registration is a bit racy

From: Petr Mladek
Date: Wed Sep 26 2018 - 07:37:20 EST


On Fri 2018-09-14 20:19:53, Sergey Senozhatsky wrote:
> On (09/14/18 10:59), Petr Mladek wrote:
> >
> > Well, I am not sure if it is worth the code complexity.
> >
>
> Well, I don't think we need to bother that much here. Besides,
> exclusive_console is cleared under logbuf_lock with preemption
> disabled now. So we set it under logbuf_lock and !irq and we
> clear it under logbuf_lock and !irq. Looks quite OK to me.

I wanted to say that you moved exclusive_console handling under
a locked section from a reason. This reason is far from clear
from the code.

If you really want this change, please add a comment, for example:

/*
* Set exclusive_console still with disabled interrupts to
* reduce race window with eventual console_flush_on_panic()
* that ignores console_lock.
*/

I am not against the change. It makes some sense and it does
not break anything. It is just not obvious and might either
get easily lost again or it might cause confusion. I mean that
it might cause false feeling that exclusive_console is
synchronized by logbuf_lock.

printk code already is complex enough without this subtle
tricks.

Best Regards,
Petr