Re: [PATCH] events: Annotate parent_ctx with __rcu

From: Peter Zijlstra
Date: Mon Feb 10 2020 - 08:35:17 EST


On Mon, Feb 10, 2020 at 06:29:48PM +0530, Amol Grover wrote:
> On Mon, Feb 10, 2020 at 10:36:24AM +0100, Peter Zijlstra wrote:
> > On Sat, Feb 08, 2020 at 08:16:49PM +0530, Amol Grover wrote:

> > > @@ -3106,26 +3106,31 @@ static void ctx_sched_out(struct perf_event_context *ctx,
> > > static int context_equiv(struct perf_event_context *ctx1,
> > > struct perf_event_context *ctx2)
> > > {
> > > + struct perf_event_context *parent_ctx1, *parent_ctx2;
> > > +
> > > lockdep_assert_held(&ctx1->lock);
> > > lockdep_assert_held(&ctx2->lock);
> > >
> > > + parent_ctx1 = rcu_dereference(ctx1->parent_ctx);
> > > + parent_ctx2 = rcu_dereference(ctx2->parent_ctx);
> >
> > Bah.
> >
> > Why are you fixing all this sparse crap and making the code worse?
>
> Hi Peter,
>
> Sparse is quite noisy and we need to eliminate false-positives, right?

Dunno, I've been happy just ignoring it all.

> __rcu will tell the developer, this pointer could change and he needs to
> take the required steps to make sure the code doesn't break.

I know what it does; what I don't know is why you need to make the code
worse. In paricular, __rcu doesn't mandate rcu_dereference(), esp. not
when you're actually holding the write side lock.