summaryrefslogtreecommitdiffstats
path: root/include/asm-i386/spinlock.h
diff options
context:
space:
mode:
authorChuck Ebbert <76306.1226@compuserve.com>2006-03-23 11:59:55 +0100
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 16:38:06 +0100
commit42c059e04d507802006911e316d86aa8ef75eb73 (patch)
tree42eb9e4d5f0a578dca12a26beeae4b27d968cb4a /include/asm-i386/spinlock.h
parent[PATCH] x86: deterine xapic using apic version (diff)
downloadlinux-42c059e04d507802006911e316d86aa8ef75eb73.tar.xz
linux-42c059e04d507802006911e316d86aa8ef75eb73.zip
[PATCH] i386 spinlocks: disable interrupts only if we enabled them
_raw_spin_lock_flags() is entered with interrupts disabled. If it cannot obtain a spinlock, it checks the flags that were passed and re-enables interrupts before spinning if that's how the flags are set. When the spinlock might be available, it disables interrupts (even if they are already disabled) before trying to get the lock. Change that so interrupts are only disabled if they have been enabled. This costs nine bytes of duplicated spinloop code. Fastpath before patch: jle <keep looping> not-taken conditional jump cli disable interrupts jmp <try for lock> unconditional jump Fastpath after patch, if interrupts were not enabled: jg <try for lock> taken conditional branch Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-i386/spinlock.h')
-rw-r--r--include/asm-i386/spinlock.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/asm-i386/spinlock.h b/include/asm-i386/spinlock.h
index a1b8a8a30e21..d76b7693cf1d 100644
--- a/include/asm-i386/spinlock.h
+++ b/include/asm-i386/spinlock.h
@@ -35,18 +35,23 @@
#define __raw_spin_lock_string_flags \
"\n1:\t" \
"lock ; decb %0\n\t" \
- "jns 4f\n\t" \
+ "jns 5f\n" \
"2:\t" \
"testl $0x200, %1\n\t" \
- "jz 3f\n\t" \
- "sti\n\t" \
+ "jz 4f\n\t" \
+ "sti\n" \
"3:\t" \
"rep;nop\n\t" \
"cmpb $0, %0\n\t" \
"jle 3b\n\t" \
"cli\n\t" \
"jmp 1b\n" \
- "4:\n\t"
+ "4:\t" \
+ "rep;nop\n\t" \
+ "cmpb $0, %0\n\t" \
+ "jg 1b\n\t" \
+ "jmp 4b\n" \
+ "5:\n\t"
#define __raw_spin_lock_string_up \
"\n\tdecb %0"