Skip to content

Commit 5bbd4c3

Browse files
Mathieu DesnoyersH. Peter Anvin
authored andcommitted
x86: spinlock use LOCK_PREFIX
Since we are now using DS prefixes instead of NOP to remove LOCK prefixes, there is no longer any problems with instruction boundaries moving around. * Linus Torvalds ([email protected]) wrote: > > > On Thu, 14 Aug 2008, Mathieu Desnoyers wrote: > > > > Changing the 0x90 (single-byte nop) currently used into a 0x3E DS segment > > override prefix should fix this issue. Since the default of the atomic > > instructions is to use the DS segment anyway, it should not affect the > > behavior. > > Ok, so I think this is an _excellent_ patch, but I'd like to also then use > LOCK_PREFIX in include/asm-x86/futex.h. > > See commit 9d55b99. > > Linus Unless there a rationale for this, I think these be changed to LOCK_PREFIX too. grep "lock ;" include/asm-x86/spinlock.h "lock ; cmpxchgw %w1,%2\n\t" asm volatile("lock ; xaddl %0, %1\n" "lock ; cmpxchgl %1,%2\n\t" Applies to 2.6.27-rc2. Signed-off-by: Mathieu Desnoyers <[email protected]> Acked-by: Linus Torvalds <[email protected]> CC: Linus Torvalds <[email protected]> CC: H. Peter Anvin <[email protected]> CC: Jeremy Fitzhardinge <[email protected]> CC: Roland McGrath <[email protected]> CC: Ingo Molnar <[email protected]> Cc: Steven Rostedt <[email protected]> CC: Steven Rostedt <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Andrew Morton <[email protected]> CC: David Miller <[email protected]> CC: Ulrich Drepper <[email protected]> CC: Rusty Russell <[email protected]> CC: Gregory Haskins <[email protected]> CC: Arnaldo Carvalho de Melo <[email protected]> CC: "Luis Claudio R. Goncalves" <[email protected]> CC: Clark Williams <[email protected]> CC: Christoph Lameter <[email protected]> CC: Andi Kleen <[email protected]> CC: Harvey Harrison <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 1f49a2c commit 5bbd4c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/asm-x86/spinlock.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
9797
"jne 1f\n\t"
9898
"movw %w0,%w1\n\t"
9999
"incb %h1\n\t"
100-
"lock ; cmpxchgw %w1,%2\n\t"
100+
LOCK_PREFIX "cmpxchgw %w1,%2\n\t"
101101
"1:"
102102
"sete %b1\n\t"
103103
"movzbl %b1,%0\n\t"
@@ -135,7 +135,7 @@ static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
135135
int inc = 0x00010000;
136136
int tmp;
137137

138-
asm volatile("lock ; xaddl %0, %1\n"
138+
asm volatile(LOCK_PREFIX "xaddl %0, %1\n"
139139
"movzwl %w0, %2\n\t"
140140
"shrl $16, %0\n\t"
141141
"1:\t"
@@ -162,7 +162,7 @@ static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
162162
"cmpl %0,%1\n\t"
163163
"jne 1f\n\t"
164164
"addl $0x00010000, %1\n\t"
165-
"lock ; cmpxchgl %1,%2\n\t"
165+
LOCK_PREFIX "cmpxchgl %1,%2\n\t"
166166
"1:"
167167
"sete %b1\n\t"
168168
"movzbl %b1,%0\n\t"

0 commit comments

Comments
 (0)