On Fri, Nov 22, 2013 at 4:25 PM, Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx> wrote: > > Start with Tim Chen's most recent patches for MCS locking, the ones that > do the lock handoff using smp_store_release() and smp_load_acquire(). > Add to that Peter Zijlstra's patch that uses PowerPC lwsync for both > smp_store_release() and smp_load_acquire(). Run the resulting lock > at high contention, so that all lock handoffs are done via the queue. > Then you will have something that acts like a lock from the viewpoint > of CPU holding that lock, but which does -not- guarantee that an > unlock+lock acts like a full memory barrier if the unlock and lock run > on two different CPUs, and if the observer is running on a third CPU. Umm. If the unlock and the lock run on different CPU's, then the lock handoff cannot be done through the queue (I assume that what you mean by "queue" is the write buffer). And yes, the write buffer is why running unlock+lock on the *same* CPU is a special case and can generate more re-ordering than is visible externally (and I generally do agree that we should strive for serialization at that point), but even it does not actually violate the rules mentioned in Documentation/memory-barriers.txt wrt an external CPU because the write that releases the lock isn't actually visible at that point in the cache, and if the same CPU re-aquires it by doing a read that bypasses the write and hits in the write buffer or the unlock, the unlocked state in between won't even be seen outside of that CPU. See? The local write buffer is special. It very much bypasses the cache, but the thing about it is that it's local to that CPU. Now, I do have to admit that cache coherency protocols are really subtle, and there may be something else I'm missing, but the thing you brought up is not one of those things, afaik. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>