lkml.org 
[lkml]   [2019]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v1 20/25] serial: 8250: implement write_atomic
On Tue 2019-02-12 15:29:58, John Ogness wrote:
> Implement a non-sleeping NMI-safe write_atomic console function in
> order to support emergency printk messages.

It uses console_atomic_lock() added in 18th patch. That one uses
prb_lock() added by 2nd patch.

Now, prb_lock() allows recursion on the same CPU. But it still needs
to wait until it is released on another CPU.

It means that it is not completely save when NMIs happen on more CPUs in
parallel, for example, when calling nmi_trigger_cpumask_backtrace().

OK, it would be safe when prb_lock() is the only lock taken
in the NMI handler. But printk() should not make such limitation
to the rest of the system. Not to say, that we would most
likely need to add a lock back into nmi_cpu_backtrace()
to keep the output sane.


Peter Zijlstra several times talked about fully lockless
consoles. He is using the early console for debugging, see
the patchset
https://lkml.kernel.org/r/20170928121823.430053219@infradead.org

I am not sure if it is always possible. I personally see
the following way:

1. Make the printk ring buffer fully lockless. Then we reduce
the problem only to console locking. And we could
have a per-console-driver lock (no the big lock like
prb_lock()).

2. I am afraid that we need to add some locking between CPUs
to avoid mixing characters from directly printed messages.
This would be safe everywhere expect in NMI. Then we could
either risk ignoring the lock in NMI (there should be few
messages anyway, the backtraces would get synchronized
another way). Or we might need a compromise between
handling console using the current owner and offload.


Best Regards,
Petr

\
 
 \ /
  Last update: 2019-02-27 10:48    [W:0.417 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site