spin_unlock optimization(i386)

Manfred Spraul (manfreds@colorfullife.com)
Sat, 20 Nov 1999 23:05:54 +0100


the current spin_unlock asm code is
"lock; btrl $0,%0"
it takes ~ 22 ticks on my PII/350.

I think it's possible to replace that with
"movl $0,%0"
which would be a simple, pairable single-tick instruction.

before spin_unlock(), spinlock_t.lock is _always_ 0x0000 0001, ie btrl
is identical to "movl $0,".
--> the only difference is the memory ordering effect of "lock;".

IA32 never reorders write operations, ie even without the "lock;" prefix
spin_unlock() is still a write memory barrier.
Few places will need the read memory barrier, and most of them should
use set_current_state() anyway.

--> What about defining that "spin_unlock()" is only a write memory
barrier and replacing "lock;btrl" with "mov"?

[I guess it's to late to change that for the 2.4 timeframe, but
release_kernel_lock() for i386 could be simplified, perhaps even
unlock_kernel()]

--
	Manfred

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/