Re: [PATCH -printk] printk, tracing: fix console tracepoint

From: Petr Mladek
Date: Thu Jul 14 2022 - 10:53:31 EST


On Wed 2022-07-13 07:05:50, Paul E. McKenney wrote:
> On Wed, Jul 13, 2022 at 01:25:41PM +0200, Petr Mladek wrote:
> > On Tue 2022-07-12 08:16:55, Paul E. McKenney wrote:
> > > Maybe printk() is supposed to be invoked from noinstr. It might be a
> > > special case in the tooling. I have no idea. ;-)
> >
> > I think that it is ok to do _not_ support printk() in noinstr parts.
> >
> > > However, the current SRCU read-side algorithm will tolerate being invoked
> > > from noinstr as long as it is not also an NMI handler. Much though
> > > debugging tools might (or might not) complain.
> > >
> > > Don't get me wrong, I can make SRCU tolerate being called while RCU is
> > > not watching. It is not even all that complicated. The cost is that
> > > architectures that have NMIs but do not have NMI-safe this_cpu*()
> > > operations have an SRCU reader switch from explicit smp_mb() and
> > > interrupt disabling to a cmpxchg() loop relying on the implicit barriers
> > > in cmpxchg().
> > >
> > > For arm64, this was reportedly a win.
> >
> > IMHO, the tracepoint in printk() is not worth slowing down other
> > important fast paths.
> >
> > The tracepoint was moved into vprintk_store() in 5.19-rc1. It used
> > to be in console_unlock() before. The previous location was not
> > reliable by definition. Old messages might be overridden by new
> > ones before they reach console. Also messages in NMI context
> > used to be stored in per-CPU buffers. There was even bigger
> > risk that they would not reach the console.
>
> Fair enough, works for me!

The remaining question is how to make the code safe and calm
down the warning.

My understanding is that Peter Zijlstra wants to reduce the scope
of the rcuidle code even more in the future. So, we could
do something like: