Subject: x86_64: Support for cpu ops Support fast cpu ops in x86_64 by providing a series of functions that generate the proper instructions. Define CONFIG_HAVE_CPU_OPS so that core code can exploit the availability of fast per cpu operations. Signed-off-by: Christoph Lameter --- arch/x86/Kconfig | 4 ++++ include/asm-x86/percpu.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) Index: linux-2.6/arch/x86/Kconfig =================================================================== --- linux-2.6.orig/arch/x86/Kconfig 2008-05-23 23:48:28.756488290 -0700 +++ linux-2.6/arch/x86/Kconfig 2008-05-24 00:16:50.240238389 -0700 @@ -175,6 +175,10 @@ config GENERIC_PENDING_IRQ depends on GENERIC_HARDIRQS && SMP default y +config HAVE_CPU_OPS + bool + default y + config X86_SMP bool depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64) Index: linux-2.6/include/asm-x86/percpu.h =================================================================== --- linux-2.6.orig/include/asm-x86/percpu.h 2008-05-24 00:14:25.500237639 -0700 +++ linux-2.6/include/asm-x86/percpu.h 2008-05-24 00:17:11.296486294 -0700 @@ -196,5 +201,36 @@ do { \ #define x86_cmpxchg_percpu(var, old, new) \ percpu_cmpxchg_op(per_cpu_var(var), old, new) +#define CPU_READ(obj) percpu_from_op("mov", obj) +#define CPU_WRITE(obj,val) percpu_to_op("mov", obj, val) +#define CPU_ADD(obj,val) percpu_to_op("add", obj, val) +#define CPU_SUB(obj,val) percpu_to_op("sub", obj, val) +#define CPU_INC(obj) percpu_addr_op("inc", obj) +#define CPU_DEC(obj) percpu_addr_op("dec", obj) +#define CPU_XCHG(obj,val) percpu_to_op("xchg", var, val) +#define CPU_CMPXCHG(obj, old, new) percpu_cmpxchg_op(var, old, new) + +/* + * All cpu operations are interrupt safe and do not need to disable + * preempt. So the other variants all reduce to the same instruction. + */ +#define _CPU_READ CPU_READ +#define _CPU_WRITE CPU_WRITE +#define _CPU_ADD CPU_ADD +#define _CPU_SUB CPU_SUB +#define _CPU_INC CPU_INC +#define _CPU_DEC CPU_DEC +#define _CPU_XCHG CPU_XCHG +#define _CPU_CMPXCHG CPU_CMPXCHG + +#define __CPU_READ CPU_READ +#define __CPU_WRITE CPU_WRITE +#define __CPU_ADD CPU_ADD +#define __CPU_SUB CPU_SUB +#define __CPU_INC CPU_INC +#define __CPU_DEC CPU_DEC +#define __CPU_XCHG CPU_XCHG +#define __CPU_CMPXCHG CPU_CMPXCHG + #endif /* !__ASSEMBLY__ */ #endif /* _ASM_X86_PERCPU_H_ */