Re: [PATCH 2/2] printk: make sure to print log on console.

From: Sergey Senozhatsky
Date: Fri Jun 01 2018 - 05:18:39 EST


On (06/01/18 10:53), Petr Mladek wrote:
> [...]
>
> > So I'd say that most likely the following scenarios can suffer:
> >
> > - NMI comes in, sets loglevel to X, printk-s some data, restores the
> > loglevel back to Y
> > - IRQ comes in [like sysrq, etc] comes in and does the same thing
> > - software exception comes in and does the same thing [e.g. bust_spinlocks()
> > at arch/s390/mm/fault.c]
>
>
> My view is:
>
> The race with another printk() (console_lock owner) is much more
> likely than a race between two CPUs manipulating console_loglevel.

The race with console_loglevel manipulation from another CPU was not
the main point [it is unlikely, like I said in my "nitpick"].
The point was

NMI / printk_safe section

saved_console_loglevel = console_loglevel
console_loglevel = A

printk
printk
printk

console_loglevel = saved_console_loglevel
iret

Is not handled.

> The proposed patch seems to be in the right direction. It is supposed
> to fix the most likely scenario.

Could be.

> I am personally fine with this partial solution for now. We could
> always make it better if people meet the other scenarios.

I don't have objections. But I'd prefer to see real uses cases and
to know why partial solution is good enough in this case, even though
we know that NMI / printk_safe() messages may be lost due to very same
problem.

-ss