Looking for an emulation for CMOV* instructions.
H. Peter Anvin wrote, in response to Andi Kleen:
Quoted 4 lines
You don't need CMPXCHG8B to do efficient inline mutexes. In fact, the pthreads code for i386 uses the same mutexes the kernel does (LOCK INC based, I believe), complete with section hacking to make them efficiently inlinable -- and then they're put inside a function call.
[...]
Your comment prompted me to look atlinux-2.5.2-pre11/include/asm-i386/spinlock.h, and I now believe that the "lock; decb" that it uses for grabbing spinlocks will return an incorrect success if 255 or more processors are waiting on the same spinlock. I don't know if anybody has ever built a shared memory x86 multiprocessor with 257 (not a typo) or more CPU's, but it's possible to imagine. It's also possible to imagine this scenario happening with even just one processor and a preemtable kernel. I believe that the current preemtable kernel patch limits the number of preempted processes to something like four or six, but that's just a temporary limitation of the current version.
If we get the point where this scenario really could happen,
then maybe the spin lock counter type should be expanded from one byte to four. I think we already assume four byte alignment in asm-i386/semaphore.h, which uses a four byte count (I think "lock" is not guaranteed to work across page boundaries).
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104 [email protected] \ / San Jose, California 95129-1034 +1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."
Quoted 7 lines · Adam J. Richter
H. Peter Anvin wrote, in response to Andi Kleen:
Quoted 4 lines
You don't need CMPXCHG8B to do efficient inline mutexes. In fact, the pthreads code for i386 uses the same mutexes the kernel does (LOCK INC based, I believe), complete with section hacking to make them efficiently inlinable -- and then they're put inside a function call.
[...]
Quoted 11 lines
Your comment prompted me to look at
linux-2.5.2-pre11/include/asm-i386/spinlock.h, and I now believe that the "lock; decb" that it uses for grabbing spinlocks will return an incorrect success if 255 or more processors are waiting on the same spinlock. I don't know if anybody has ever built a shared memory x86 multiprocessor with 257 (not a typo) or more CPU's, but it's possible to imagine. It's also possible to imagine this scenario happening with even just one processor and a preemtable kernel. I believe that the current preemtable kernel patch limits the number of preempted processes to something like four or six, but that's just a temporary limitation of the current version.
AFAIK, there's more code than this that won't work with >255 processors... It's not like each and every person on this list has such a beast to test with (and probably most never will even if they do exist, or come to existance...)
Regards: David Weinehall
_ _
// David Weinehall <[email protected]> /> Northern lights wander \\
// Maintainer of the v2.0 kernel // Dance across the winter sky // \> http://www.acc.umu.se/~tao/ </ Full colour fire </
Quoted 6 lines · Adam J. Richter
H. Peter Anvin wrote, in response to Andi Kleen:
Quoted 4 lines
You don't need CMPXCHG8B to do efficient inline mutexes. In fact, the pthreads code for i386 uses the same mutexes the kernel does (LOCK INC based, I believe), complete with section hacking to make them efficiently inlinable -- and then they're put inside a function call.
Quoted 7 lines
[...]
Your comment prompted me to look at
linux-2.5.2-pre11/include/asm-i386/spinlock.h, and I now believe that the "lock; decb" that it uses for grabbing spinlocks will return an incorrect success if 255 or more processors are waiting on the same spinlock.
Implementation detail. You could just as easily use a long instead of a char and have room for 2^32 processors.
--
Brian Gerst
Quoted 13 lines · Adam J. Richter
Your comment prompted me to look at
linux-2.5.2-pre11/include/asm-i386/spinlock.h, and I now believe that the "lock; decb" that it uses for grabbing spinlocks will return an incorrect success if 255 or more processors are waiting on the same spinlock. I don't know if anybody has ever built a shared memory x86 multiprocessor with 257 (not a typo) or more CPU's, but it's possible to imagine. It's also possible to imagine this scenario happening with even just one processor and a preemtable kernel. I believe that the current preemtable kernel patch limits the number of preempted processes to something like four or six, but that's just a temporary limitation of the current version.
Linux specificially does not allow for more processors than there are bits in a long (32 or 64). Libc, however, since it counts processes, not CPUs, uses a 4-byte word.
-hpa