Re: call_rcu from trace_preempt

Steven Rostedt
2015-06-16T15:37:49Z

On Tue, 16 Jun 2015 05:27:33 -0700
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:

> On Mon, Jun 15, 2015 at 10:45:05PM -0700, Alexei Starovoitov wrote:
> > On 6/15/15 7:14 PM, Paul E. McKenney wrote:
> > >
> > >Why do you believe that it is better to fix it within call_rcu()?
> >
> > found it:
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index 8cf7304b2867..a3be09d482ae 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -935,9 +935,9 @@ bool notrace rcu_is_watching(void)
> > {
> > bool ret;
> >
> > - preempt_disable();
> > + preempt_disable_notrace();
> > ret = __rcu_is_watching();
> > - preempt_enable();
> > + preempt_enable_notrace();
> > return ret;
> > }
> >
> > the rcu_is_watching() and __rcu_is_watching() are already marked
> > notrace, so imo it's a good 'fix'.
> > What was happening is that the above preempt_enable was triggering
> > recursive call_rcu that was indeed messing 'rdp' that was
> > prepared by __call_rcu and before __call_rcu_core could use that.
>
> > btw, also noticed that local_irq_save done by note_gp_changes
> > is partially redundant. In __call_rcu_core path the irqs are
> > already disabled.
>

If rcu_is_watching() and __rcu_is_watching() are both marked as
notrace, it makes sense to use preempt_disable/enable_notrace() as it
otherwise defeats the purpose of the notrace markers on rcu_is_watching.

That is regardless of what the rest of this thread is about.

-- Steve