[PATCH] Document Linux's memory barriers [try #2]

David Howells dhowells at redhat.com
Thu Mar 9 23:27:54 EST 2006

Linus Torvalds <torvalds at osdl.org> wrote:

> > A spin_lock does show up on the bus, doesn't it?
> Nope.

Yes, sort of, under some circumstances. If the CPU doing the spin_lock()
doesn't own the cacheline with the lock, it'll have to resort to the bus to
grab the cacheline from the current owner (so another CPU would at least see a

The effect of the spin_lock() might not be seen outside of the CPU before the
spin_unlock() occurs, but it *will* be committed to the CPU's cache, and given
cache coherency mechanisms, that's effectively the same as main memory.

So it's in effect visible on the bus, given that it will be transferred to
another CPU when requested; and as long as the other CPUs expect to see the
effects and the ordering imposed, it's immaterial whether the content of the
spinlock is actually ever committed to SDRAM or whether it remains perpetually
in one or another's CPU cache.


More information about the Linuxppc64-dev mailing list