Re: [PATCH 1/4] rcu/nocb: Protect lazy shrinker against concurrent (de-)offloading

From: Frederic Weisbecker
Date: Wed Mar 29 2023 - 17:18:36 EST


On Wed, Mar 29, 2023 at 01:44:53PM -0700, Paul E. McKenney wrote:
> On Wed, Mar 29, 2023 at 06:02:00PM +0200, Frederic Weisbecker wrote:
> > + /*
> > + * But really don't insist if barrier_mutex is contended since we
> > + * can't guarantee that it will never engage in a dependency
> > + * chain involving memory allocation. The lock is seldom contended
> > + * anyway.
> > + */
> > + return 0;
> > + }
> > +
> > /* Snapshot count of all CPUs */
> > for_each_possible_cpu(cpu) {
> > struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
> > - int _count = READ_ONCE(rdp->lazy_len);
> > + int _count;
> > +
> > + if (!rcu_rdp_is_offloaded(rdp))
> > + continue;
> > +
> > + _count = READ_ONCE(rdp->lazy_len);
> >
> > if (_count == 0)
> > continue;
> > +
>
> And I just might have unconfused myself here. We get here only if this
> CPU is offloaded, in which case it might also have non-zero ->lazy_len,
> so this is in fact *not* dead code.

Right. Now whether it's really alive remains to be proven ;)