On Thu, Jan 29, 2015 at 11:14:40PM -0800, Davidlohr Bueso wrote:
> > +bool mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner)
> >  {
> > +   bool ret;
> > +
> >     rcu_read_lock();
> > -   while (owner_running(lock, owner)) {
> > -           if (need_resched())
> > +   while (true) {
> > +           /* Return success when the lock owner changed */
> > +           if (lock->owner != owner) {
> 
> Shouldn't this be a READ_ONCE(lock->owner)? We're in a loop and need to
> avoid gcc giving us stale data if the owner is updated after a few
> iterations, no?

There's a barrier() in that loop, and cpu_relax() also implies
barrier(). I'm pretty sure that's more than sufficient to make GCC emit
loads.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to