summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2008-10-24 16:53:33 +0200
committerH. Peter Anvin <hpa@zytor.com>2008-11-05 18:51:02 +0100
commit838e8bb71dc0c892bf8f84abd3c709d8fe3a8d3c (patch)
tree3cae439c32d1e046aba1f0cb6fa81aeed482a91c
parentx86: avoid duplicate running of pud_offset and pmd_offset in one_md_table_init() (diff)
downloadlinux-838e8bb71dc0c892bf8f84abd3c709d8fe3a8d3c.tar.xz
linux-838e8bb71dc0c892bf8f84abd3c709d8fe3a8d3c.zip
x86: Implement change_bit with immediate operand as "lock xorb"
Impact: Minor optimization. Implement change_bit with immediate bit count as "lock xorb". This is similar to "lock orb" and "lock andb" for set_bit and clear_bit functions. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--arch/x86/include/asm/bitops.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 360010322711..9fa9dcdf344b 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -168,7 +168,15 @@ static inline void __change_bit(int nr, volatile unsigned long *addr)
*/
static inline void change_bit(int nr, volatile unsigned long *addr)
{
- asm volatile(LOCK_PREFIX "btc %1,%0" : ADDR : "Ir" (nr));
+ if (IS_IMMEDIATE(nr)) {
+ asm volatile(LOCK_PREFIX "xorb %1,%0"
+ : CONST_MASK_ADDR(nr, addr)
+ : "iq" ((u8)CONST_MASK(nr)));
+ } else {
+ asm volatile(LOCK_PREFIX "btc %1,%0"
+ : BITOP_ADDR(addr)
+ : "Ir" (nr));
+ }
}
/**