Re: [patch 134/149] x86, paravirt: Add a global synchronization point for pvclock

Linus Torvalds
2010-07-13T17:51:24Z

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

On Tue, Jul 13, 2010 at 10:25 AM, Peter Palfrader <peter@palfrader.org> wrote:
>
> Linus's patch touches __xchg() whereas we're using __cmpxchg() in this
> particular case I think.
>
> At least, applying it to my 2.6.32.16 tree didn't help, last_value was
> still read-only.  Or I backported it wrong.

No, you didn't back-port it wrong. I just didn't fix the right part. I
thought the PV code used xchg, not cmpxchg, so I only patched that.
But cmpxchg has the exact same issue.

Does this fix it?

Again: UNTESTED.

Linus

[-- Attachment #2: diff --]
[-- Type: application/octet-stream, Size: 1738 bytes --]

arch/x86/include/asm/cmpxchg_64.h | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h
index 485ae41..f6face7 100644
--- a/arch/x86/include/asm/cmpxchg_64.h
+++ b/arch/x86/include/asm/cmpxchg_64.h
@@ -71,28 +71,24 @@ extern void __cmpxchg_wrong_size(void);
__typeof__(*(ptr)) __new = (new); \
switch (size) { \
case 1: \
- asm volatile(lock "cmpxchgb %b1,%2" \
- : "=a"(__ret) \
- : "q"(__new), "m"(*__xg(ptr)), "0"(__old) \
- : "memory"); \
+ asm volatile(lock "cmpxchgb %b2,%1" \
+ : "=a"(__ret), "+m" (*ptr) \
+ : "q"(__new), "0"(__old)); \
break; \
case 2: \
- asm volatile(lock "cmpxchgw %w1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
- : "memory"); \
+ asm volatile(lock "cmpxchgw %w2,%1" \
+ : "=a"(__ret), "+m" (*ptr) \
+ : "r"(__new), "0"(__old)); \
break; \
case 4: \
- asm volatile(lock "cmpxchgl %k1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
- : "memory"); \
+ asm volatile(lock "cmpxchgl %k2,%1" \
+ : "=a"(__ret), "+m" (*ptr) \
+ : "r"(__new), "0"(__old)); \
break; \
case 8: \
- asm volatile(lock "cmpxchgq %1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
- : "memory"); \
+ asm volatile(lock "cmpxchgq %2,%1" \
+ : "=a"(__ret), "+m" (*ptr) \
+ : "r"(__new), "0"(__old)); \
break; \
default: \
__cmpxchg_wrong_size(); \