Re: [PATCH v2] rwsem: Support optimistic spinning

From: Davidlohr Bueso
Date: Mon Apr 28 2014 - 23:05:26 EST


On Mon, 2014-04-28 at 17:50 -0700, Tim Chen wrote:
> On Mon, 2014-04-28 at 16:10 -0700, Paul E. McKenney wrote:
>
> > > +#ifdef CONFIG_SMP
> > > +static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem)
> > > +{
> > > + int retval;
> > > + struct task_struct *owner;
> > > +
> > > + rcu_read_lock();
> > > + owner = ACCESS_ONCE(sem->owner);
> >
> > OK, I'll bite...
> >
> > Why ACCESS_ONCE() instead of rcu_dereference()?
>
> We're using it as a speculative check on the sem->owner to see
> if the owner is running on the cpu. The rcu_read_lock
> is used for ensuring that the owner->on_cpu memory is
> still valid.

Something worth documenting in the code, imho. I'll add it in an
eventual v3.

Thanks,
Davidlohr

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/