Re: [PATCH RFC tip/core/rcu 01/14] rcu/nocb: Atomic ->len field in rcu_segcblist structure

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

 



On Sun, Aug 04, 2019 at 04:52:46PM +0200, Peter Zijlstra wrote:
> On Sun, Aug 04, 2019 at 04:50:51PM +0200, Peter Zijlstra wrote:
> > On Fri, Aug 02, 2019 at 08:14:48AM -0700, Paul E. McKenney wrote:
> > > +/*
> > > + * Exchange the numeric length of the specified rcu_segcblist structure
> > > + * with the specified value.  This can cause the ->len field to disagree
> > > + * with the actual number of callbacks on the structure.  This exchange is
> > > + * fully ordered with respect to the callers accesses both before and after.
> > > + */
> > > +long rcu_segcblist_xchg_len(struct rcu_segcblist *rsclp, long v)
> > > +{
> > > +#ifdef CONFIG_RCU_NOCB_CPU
> > > +	return atomic_long_xchg(&rsclp->len, v);
> > > +#else
> > > +	long ret = rsclp->len;
> > > +
> > > +	smp_mb(); /* Up to the caller! */
> > > +	WRITE_ONCE(rsclp->len, v);
> > > +	smp_mb(); /* Up to the caller! */
> > > +	return ret;
> > > +#endif
> > > +}
> > 
> > That one's weird; for matching semantics the load needs to be between
> > the memory barriers.
> 
> Also, since you WRITE_ONCE() the thing, the load needs to be a
> READ_ONCE().

Not in this case, because ->len is written only by the CPU in question
in the !RCU_NOCB_CPU case.

It would not be hard to convince me that adding READ_ONCE() would be
cheap and easy future-proofing, but Linus has objected to that sort of
thing in the past.

							Thanx, Paul



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux