lkml.org 
[lkml]   [2010]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [cpuops cmpxchg V1 2/4] x86: this_cpu_cmpxchg and this_cpu_xchg operations
Argh. I included __this_cpu_cmpxchg_8 done with cmpxchg8b for 32 bit. That
has some issues....


Subject: Fixup __this_cpu_cmpxchg_8

__this_cpu_cmpxchg_8 can cause compilation failure since it is expanded
for any this_cpu_cmpxchg independent of the size or type of argument.
However. __this_cpu_cmpxchg_8 only generates code for the 8 byte
case. Use a union to get around the compilation failures.

Signed-off-by: Christoph Lameter <cl@linux.com>

---
arch/x86/include/asm/percpu.h | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

Index: linux-2.6/arch/x86/include/asm/percpu.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/percpu.h 2010-12-08 14:48:02.000000000 -0600
+++ linux-2.6/arch/x86/include/asm/percpu.h 2010-12-08 16:01:24.000000000 -0600
@@ -391,15 +391,23 @@ do { \

#ifndef CONFIG_X86_64
#ifdef CONFIG_X86_CMPXCHG64
-/* We can support a 8 byte cmpxchg with a special instruction on 32 bit */
+/*
+ * We can support a 8 byte cmpxchg with a special instruction on 32 bit.
+ *
+ * Note that some of the strangeness here with the __new variable is due to
+ * the need to expand and compile this function for arbitary types even
+ * though the code will not be included in the .o file if used for a smaller
+ * type.
+ */
#define __this_cpu_cmpxchg_8(pcp, oval, nval) \
({ \
- typeof(var) __ret; \
- typeof(var) __old = (oval); \
- typeof(var) __new = (nval); \
+ typeof(pcp) __ret; \
+ typeof(pcp) __old = (oval); \
+ union x { typeof(pcp) n;u64 m; } __new; \
+ __new.n = (nval); \
asm("cmpxchg8b %2, "__percpu_arg(1) \
- : "=A" (__ret), "+m" (&pcp) \
- : "b" (((u32)new), "c" ((u32)(new >> 32)), "0" (__old) \
+ : "=A" (__ret), "+m" (pcp) \
+ : "b" ((u32)__new.m), "c" ((u32)(__new.m >> 32)), "0" (__old) \
: "memory"); \
__ret; \
})


\
 
 \ /
  Last update: 2010-12-08 23:23    [W:0.052 / U:10.828 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site