diff options
author | Jan Beulich <jbeulich@novell.com> | 2008-09-05 08:27:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-05 11:06:20 -0400 |
commit | 74e91604b2452c15bbe72d77b37cf47ed0310d13 (patch) | |
tree | 4308d55a7b19bdd390805c50e2ce9d283825522a /include | |
parent | 08f5fcbe6e0ea029c7e9b1b1c338700ab7809daf (diff) |
x86: ticket spin locks: reduce instruction dependencies
Reduce the amount of partial register accesses in the NR_CPUS < 256
case, and slightly weaken resource dependencies in the other case.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-x86/spinlock.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/asm-x86/spinlock.h b/include/asm-x86/spinlock.h index 63d3b610a5ef..b5a4551fd565 100644 --- a/include/asm-x86/spinlock.h +++ b/include/asm-x86/spinlock.h | |||
@@ -21,8 +21,10 @@ | |||
21 | 21 | ||
22 | #ifdef CONFIG_X86_32 | 22 | #ifdef CONFIG_X86_32 |
23 | # define LOCK_PTR_REG "a" | 23 | # define LOCK_PTR_REG "a" |
24 | # define REG_PTR_MODE "k" | ||
24 | #else | 25 | #else |
25 | # define LOCK_PTR_REG "D" | 26 | # define LOCK_PTR_REG "D" |
27 | # define REG_PTR_MODE "q" | ||
26 | #endif | 28 | #endif |
27 | 29 | ||
28 | #if defined(CONFIG_X86_32) && \ | 30 | #if defined(CONFIG_X86_32) && \ |
@@ -77,19 +79,17 @@ static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock) | |||
77 | 79 | ||
78 | static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock) | 80 | static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock) |
79 | { | 81 | { |
80 | int tmp; | 82 | int tmp, new; |
81 | short new; | ||
82 | 83 | ||
83 | asm volatile("movw %2,%w0\n\t" | 84 | asm volatile("movzwl %2, %0\n\t" |
84 | "cmpb %h0,%b0\n\t" | 85 | "cmpb %h0,%b0\n\t" |
86 | "leal 0x100(%" REG_PTR_MODE "0), %1\n\t" | ||
85 | "jne 1f\n\t" | 87 | "jne 1f\n\t" |
86 | "movw %w0,%w1\n\t" | ||
87 | "incb %h1\n\t" | ||
88 | LOCK_PREFIX "cmpxchgw %w1,%2\n\t" | 88 | LOCK_PREFIX "cmpxchgw %w1,%2\n\t" |
89 | "1:" | 89 | "1:" |
90 | "sete %b1\n\t" | 90 | "sete %b1\n\t" |
91 | "movzbl %b1,%0\n\t" | 91 | "movzbl %b1,%0\n\t" |
92 | : "=&a" (tmp), "=&Q" (new), "+m" (lock->slock) | 92 | : "=&a" (tmp), "=&q" (new), "+m" (lock->slock) |
93 | : | 93 | : |
94 | : "memory", "cc"); | 94 | : "memory", "cc"); |
95 | 95 | ||
@@ -136,8 +136,8 @@ static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock) | |||
136 | "movl %0,%1\n\t" | 136 | "movl %0,%1\n\t" |
137 | "roll $16, %0\n\t" | 137 | "roll $16, %0\n\t" |
138 | "cmpl %0,%1\n\t" | 138 | "cmpl %0,%1\n\t" |
139 | "leal 0x00010000(%" REG_PTR_MODE "0), %1\n\t" | ||
139 | "jne 1f\n\t" | 140 | "jne 1f\n\t" |
140 | "addl $0x00010000, %1\n\t" | ||
141 | LOCK_PREFIX "cmpxchgl %1,%2\n\t" | 141 | LOCK_PREFIX "cmpxchgl %1,%2\n\t" |
142 | "1:" | 142 | "1:" |
143 | "sete %b1\n\t" | 143 | "sete %b1\n\t" |