[PATCH] i386 spinlocks: disable interrupts only if we enabled them
authorChuck Ebbert <76306.1226@compuserve.com>
Thu, 23 Mar 2006 10:59:55 +0000 (02:59 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 23 Mar 2006 15:38:06 +0000 (07:38 -0800)
commit42c059e04d507802006911e316d86aa8ef75eb73
tree42eb9e4d5f0a578dca12a26beeae4b27d968cb4a
parent7c5c1e427b5e83807fd05419d1cf6991b9d87247
[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>
include/asm-i386/spinlock.h