Re: [PATCH tip/core/rcu 04/13] rcu: Don't disable preemption for Tiny and Tree RCU readers
From: Peter Zijlstra
Date: Wed Oct 07 2015 - 03:20:14 EST
On Tue, Oct 06, 2015 at 02:05:39PM -0700, Paul E. McKenney wrote:
> On Tue, Oct 06, 2015 at 10:52:00PM +0200, Peter Zijlstra wrote:
> > On Tue, Oct 06, 2015 at 01:18:01PM -0700, Paul E. McKenney wrote:
> > > On Tue, Oct 06, 2015 at 10:05:38PM +0200, Peter Zijlstra wrote:
> >
> > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > > > > index b9d9e0249e2f..93c0f23c3e45 100644
> > > > > --- a/kernel/rcu/tree.c
> > > > > +++ b/kernel/rcu/tree.c
> > > > > @@ -337,12 +337,14 @@ static void rcu_momentary_dyntick_idle(void)
> > > > > */
> > > > > void rcu_note_context_switch(void)
> > > > > {
> > > > > + barrier(); /* Avoid RCU read-side critical sections leaking down. */
> > > > > trace_rcu_utilization(TPS("Start context switch"));
> > > > > rcu_sched_qs();
> > > > > rcu_preempt_note_context_switch();
> > > > > if (unlikely(raw_cpu_read(rcu_sched_qs_mask)))
> > > > > rcu_momentary_dyntick_idle();
> > > > > trace_rcu_utilization(TPS("End context switch"));
> > > > > + barrier(); /* Avoid RCU read-side critical sections leaking up. */
> > > > > }
> > > > > EXPORT_SYMBOL_GPL(rcu_note_context_switch);
> > > >
> > > > These OTOH could be fixed with a noinline, such that the compiler may
> > > > never inline it, even with whole-program-optimizations, thereby
> > > > guaranteeing a function call boundary or compiler barrier.
> > >
> > > I like the barrier() with the comment. I expect it will be a bit more
> > > robust against toolchain changes.
> >
> > Don't you in fact already rely on the fact that schedule() is a function
> > call and will not be inlined? (it doesn't have noinline and I suppose
> > whole program optimizers could go funny on it).
>
> Probably pretty much everywhere I call schedule(). But I was thinking
> that barrier() and the beginning and end of an external function didn't
> need to do anything. Is that incorrect?
No. My point was more that by removing barrier() from
rcu_read_{un,}lock() you hard rely on schedule() being a compiler
barrier, and I was thinking you need it to be a function call for that,
but this is incorrect.
Even without it being a function call, there's explicit compiler
barriers in there that even whole program optimizers cannot make go
away, so my bad for creating confusion.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/