Skip to contentSkip to conversation

spinlock __raw_spin_unlock : comment disagrees with Wikipedia article

DISCUSSION David Schwartz 1 participant 1 message Feb 23, 2006

lore
Share & tools
lore
#0 lore raw

The code for __raw_spin_unlock contains the following comment:

/*
* __raw_spin_unlock based on writing $1 to the low byte.
* This method works. Despite all the confusion.
* (except on PPro SMP or if we are using OOSTORE, so we use xchgb there)
* (PPro errata 66, 92)
*/

Yet the Wikipedia article on spinlocks says:

http://en.wikipedia.org/wiki/Spinlock
"In theory, spin_unlock could use an unlocked MOV instead of the locked XCHG, however some processors (notably, some Cyrix processors and some revisions of the Intel Pentium III) will do the wrong thing and data protected by the lock could be corrupted."

Does anyone know for sure who is right? I assume if the Linux kernel was
wrong, it would probably be blowing up by now. Or does it rely on something that isn't guaranteed but happens to work on all current hardware? Or perhaps it's some kind of very rare issue. What is the source for the comment about "some revisions of the Intel Pentium II"? Does one know?

Is 'movb' okay, but perhaps some other type of instructions might not
work, such as a 32-bit operation?

DS