[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/3] xen/rcu: simplify RCU implementation



On Mon, Sep 28, 2026 at 11:05:10AM +0200, Alejandro Vallejo wrote:
> On Fri Sep 25, 2026 at 6:30 PM CEST, Roger Pau Monne wrote:
> >  bool rcu_needs_cpu(unsigned int cpu)
> >  {
> > -    struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
> > -
> > -    return (rdp->curlist && !rdp->idle_timer_active) || rcu_pending(cpu);
> > +    return !!per_cpu(rcu_data, cpu).nr;
> 
> Local reads are fine to be relaxed with IRQs off because they can't
> change. But remote reads and reads with IRQs on are subject to data
> races.
> 
> This read should be atomic. And the writes should be atomic too because
> the field is read from remote CPUs.

Sorry, this is a leftover from a further change I wanted to do.
rcu_needs_cpu() is never called against remote CPUs (as is
rcu_pending()), so I wanted to get rid of the cpu parameter and
instead use this_cpu(rcu_data).nr.  Then decided it was too much
churn (and extra logic to fetch the current cpu repeatedly) and forgot
to add the ACCESS_ONCE().

I will add the ACCESS_ONCE() and keep the function interface as-is.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.