Skip to contentSkip to conversation

x86: adjust placement of pause insn in _raw_spin_lock()

PATCH In review Jan Beulich 2 participants 4 messages Aug 8, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: adjust placement of pause insn in _raw_spin_lock()

xen/include/asm-x86/spinlock.h +2 -2
Index: 2008-08-06/xen/include/asm-x86/spinlock.h
===================================================================
@@ -23,8 +23,8 @@ static inline void _raw_spin_lock(spinlo
         "1:  lock; decb %0         \n"
         "    js 2f                 \n"
         ".section .text.lock,\"ax\"\n"
-        "2:  cmpb $0,%0            \n"
-        "    rep; nop              \n"
+        "2:  rep; nop              \n"
+        "    cmpb $0,%0            \n"
         "    jle 2b                \n"
         "    jmp 1b                \n"
         ".previous"
#1 lore raw

Why?

-- Keir

Quoted 27 lines · Jan Beulich

Index: 2008-08-06/xen/include/asm-x86/spinlock.h
===================================================================
--- 2008-08-06.orig/xen/include/asm-x86/spinlock.h 2007-09-10 09:59:37.000000000 +0200
+++ 2008-08-06/xen/include/asm-x86/spinlock.h 2008-08-07 12:36:13.000000000 +0200

xen/include/asm-x86/spinlock.h +2 -2
@@ -23,8 +23,8 @@ static inline void _raw_spin_lock(spinlo
         "1:  lock; decb %0         \n"
         "    js 2f                 \n"
         ".section .text.lock,\"ax\"\n"
-        "2:  cmpb $0,%0            \n"
-        "    rep; nop              \n"
+        "2:  rep; nop              \n"
+        "    cmpb $0,%0            \n"
         "    jle 2b                \n"
         "    jmp 1b                \n"
         ".previous"

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Ah, I suppose it reduce lock acquisition latency slightly. I'll apply it.

-- Keir

Quoted 33 lines · Keir Fraser

Why?

-- Keir

Quoted 27 lines · Jan Beulich

Index: 2008-08-06/xen/include/asm-x86/spinlock.h
===================================================================
--- 2008-08-06.orig/xen/include/asm-x86/spinlock.h 2007-09-10 09:59:37.000000000 +0200
+++ 2008-08-06/xen/include/asm-x86/spinlock.h 2008-08-07 12:36:13.000000000 +0200

xen/include/asm-x86/spinlock.h +2 -2
@@ -23,8 +23,8 @@ static inline void _raw_spin_lock(spinlo
         "1:  lock; decb %0         \n"
         "    js 2f                 \n"
         ".section .text.lock,\"ax\"\n"
-        "2:  cmpb $0,%0            \n"
-        "    rep; nop              \n"
+        "2:  rep; nop              \n"
+        "    cmpb $0,%0            \n"
         "    jle 2b                \n"
         "    jmp 1b                \n"
         ".previous"

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw

Re: [PATCH] x86: adjust placement of pause insn in_raw_spin_lock()

In reply to Keir Fraser

That's the way it's done elsewhere and it's recommended (i.e. pause immediately preceding the memory reference of the possibly contended location). Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 08.08.08 15:12 >>>

Why?

-- Keir

Quoted 27 lines · Jan Beulich

Index: 2008-08-06/xen/include/asm-x86/spinlock.h
===================================================================
--- 2008-08-06.orig/xen/include/asm-x86/spinlock.h 2007-09-10 09:59:37.000000000 +0200
+++ 2008-08-06/xen/include/asm-x86/spinlock.h 2008-08-07 12:36:13.000000000 +0200

xen/include/asm-x86/spinlock.h +2 -2
@@ -23,8 +23,8 @@ static inline void _raw_spin_lock(spinlo
         "1:  lock; decb %0         \n"
         "    js 2f                 \n"
         ".section .text.lock,\"ax\"\n"
-        "2:  cmpb $0,%0            \n"
-        "    rep; nop              \n"
+        "2:  rep; nop              \n"
+        "    cmpb $0,%0            \n"
         "    jle 2b                \n"
         "    jmp 1b                \n"
         ".previous"

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel