Re: [PATCH 2/2] events: callchain: Use RCU API to access RCU pointer

From: Peter Zijlstra
Date: Thu Jan 30 2020 - 08:33:08 EST


On Thu, Jan 30, 2020 at 03:44:51PM +0530, Amol Grover wrote:
> > > > diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
> > > > index f91e1f41d25d..a672d02a1b3a 100644
> > > > --- a/kernel/events/callchain.c
> > > > +++ b/kernel/events/callchain.c
> > > > @@ -62,7 +62,8 @@ static void release_callchain_buffers(void)
> > > > {
> > > > struct callchain_cpus_entries *entries;
> > > >
> > > > - entries = callchain_cpus_entries;
> > > > + entries = rcu_dereference_protected(callchain_cpus_entries,
> > > > + lockdep_is_held(&callchain_mutex));
> > >
> > >
> > > Reviewed-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
> >
> > Do we really need that smp_read_barrier_depends() here? Then again, I
> > don't suppose this is a fast path.
> >
>
> rcu_dereference_protected is actually a lightweight API and IIRC it
> omits the READ_ONCE() and hence the memory barriers.

Oh argh, indeed. I suppose I should've had more tea this morning.