Re: [PATCH v5 tip/core/locking 5/7]Documentation/memory-barriers.txt: Downgrade UNLOCK+LOCK

From: Paul E. McKenney
Date: Tue Dec 10 2013 - 12:49:22 EST


On Tue, Dec 10, 2013 at 06:25:28PM +0100, Peter Zijlstra wrote:
> On Tue, Dec 10, 2013 at 09:12:47AM -0800, Paul E. McKenney wrote:
> > > The way I read the above it says that you need
> > > smp_mb__after_unlock_lock() when the UNLOCK and LOCK are on the same
> > > variable. That doesn't make sense, I thought that was the one case we
> > > all agreed on it would indeed be a full barrier without extra trickery.
> >
> > On x86, sure, but smp_mb__after_unlock_lock() is nothingness on x86
> > anyway. Other architectures might benefit from requiring that the
> > smp_mb__after_unlock_lock() be used in this case.
>
> Confused, UNLOCK X, LOCK X, must always be fully serializing. That's the
> entire purpose of the thing.

>From the viewpoint of some CPU holding the lock, yes. If some CPU does
not hold the lock, the guarantee is a choice.

> The only place you can go play games (and clearly we are going there) is
> when the UNLOCK and LOCK are on different variables.

I agree that if UNLOCK and LOCK are on different variables, we do not
need to guarantee ordering of the two critical sections. But if they
are on the same variable, why would it be different from the viewpoint
of some CPU not holding the lock?

Thanx, Paul

--
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/