[this_cpu_xx V8 09/16] Allow arch to provide inc/dec functionality for each size separately

From: Christoph Lameter
Date: Fri Dec 18 2009 - 19:27:18 EST


Current this_cpu ops only allow an arch to specify add RMW operations or inc
and dec for all sizes. Some arches can do more efficient inc and dec
operations. Allow size specific override of fallback functions like with
the other operations.

Signed-off-by: Christoph Lameter <cl@xxxxxxxxxxxxxxxxxxxx>

---
include/linux/percpu.h | 96 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 90 insertions(+), 6 deletions(-)

Index: linux-2.6/include/linux/percpu.h
===================================================================
--- linux-2.6.orig/include/linux/percpu.h 2009-12-18 13:34:13.000000000 -0600
+++ linux-2.6/include/linux/percpu.h 2009-12-18 14:19:25.000000000 -0600
@@ -257,6 +257,18 @@ do { \
} \
} while (0)

+#define __pcpu_size_call_noparam(stem, variable) \
+do { \
+ switch(sizeof(variable)) { \
+ case 1: stem##1(variable);break; \
+ case 2: stem##2(variable);break; \
+ case 4: stem##4(variable);break; \
+ case 8: stem##8(variable);break; \
+ default: \
+ __bad_size_call_parameter();break; \
+ } \
+} while (0)
+
/*
* Optimized manipulation for memory allocated through the per cpu
* allocator or for addresses of per cpu variables (can be determined
@@ -352,11 +364,35 @@ do { \
#endif

#ifndef this_cpu_inc
-# define this_cpu_inc(pcp) this_cpu_add((pcp), 1)
+# ifndef this_cpu_inc_1
+# define this_cpu_inc_1(pcp) __this_cpu_add((pcp), 1)
+# endif
+# ifndef this_cpu_inc_2
+# define this_cpu_inc_2(pcp) __this_cpu_add((pcp), 1)
+# endif
+# ifndef this_cpu_inc_4
+# define this_cpu_inc_4(pcp) __this_cpu_add((pcp), 1)
+# endif
+# ifndef this_cpu_inc_8
+# define this_cpu_inc_8(pcp) __this_cpu_add((pcp), 1)
+# endif
+# define this_cpu_inc(pcp) __pcpu_size_call_noparam(this_cpu_inc_, (pcp))
#endif

#ifndef this_cpu_dec
-# define this_cpu_dec(pcp) this_cpu_sub((pcp), 1)
+# ifndef this_cpu_dec_1
+# define this_cpu_dec_1(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# ifndef this_cpu_dec_2
+# define this_cpu_dec_2(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# ifndef this_cpu_dec_4
+# define this_cpu_dec_4(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# ifndef this_cpu_dec_8
+# define this_cpu_dec_8(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# define this_cpu_dec(pcp) __pcpu_size_call_noparam(this_cpu_dec_, (pcp))
#endif

#ifndef this_cpu_and
@@ -479,11 +515,35 @@ do { \
#endif

#ifndef __this_cpu_inc
-# define __this_cpu_inc(pcp) __this_cpu_add((pcp), 1)
+# ifndef __this_cpu_inc_1
+# define __this_cpu_inc_1(pcp) __this_cpu_add_1((pcp), 1)
+# endif
+# ifndef __this_cpu_inc_2
+# define __this_cpu_inc_2(pcp) __this_cpu_add_2((pcp), 1)
+# endif
+# ifndef __this_cpu_inc_4
+# define __this_cpu_inc_4(pcp) __this_cpu_add_4((pcp), 1)
+# endif
+# ifndef __this_cpu_inc_8
+# define __this_cpu_inc_8(pcp) __this_cpu_add_8((pcp), 1)
+# endif
+# define __this_cpu_inc(pcp) __pcpu_size_call_noparam(__this_cpu_inc_, (pcp))
#endif

#ifndef __this_cpu_dec
-# define __this_cpu_dec(pcp) __this_cpu_sub((pcp), 1)
+# ifndef __this_cpu_dec_1
+# define __this_cpu_dec_1(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# ifndef __this_cpu_dec_2
+# define __this_cpu_dec_2(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# ifndef __this_cpu_dec_4
+# define __this_cpu_dec_4(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# ifndef __this_cpu_dec_8
+# define __this_cpu_dec_8(pcp) __this_cpu_sub((pcp), 1)
+# endif
+# define __this_cpu_dec(pcp) __pcpu_size_call_noparam(__this_cpu_dec_, (pcp))
#endif

#ifndef __this_cpu_and
@@ -570,11 +630,35 @@ do { \
#endif

#ifndef irqsafe_cpu_inc
-# define irqsafe_cpu_inc(pcp) irqsafe_cpu_add((pcp), 1)
+# ifndef irqsafe_cpu_inc_1
+# define irqsafe_cpu_inc_1(pcp) irqsafe_cpu_add_1((pcp), 1)
+# endif
+# ifndef irqsafe_cpu_inc_2
+# define irqsafe_cpu_inc_2(pcp) irqsafe_cpu_add_2((pcp), 1)
+# endif
+# ifndef irqsafe_cpu_inc_4
+# define irqsafe_cpu_inc_4(pcp) irqsafe_cpu_add_4((pcp), 1)
+# endif
+# ifndef irqsafe_cpu_inc_8
+# define irqsafe_cpu_inc_8(pcp) irqsafe_cpu_add_8((pcp), 1)
+# endif
+# define irqsafe_cpu_inc(pcp) __pcpu_size_call_noparam(irqsafe_cpu_inc_, (pcp))
#endif

#ifndef irqsafe_cpu_dec
-# define irqsafe_cpu_dec(pcp) irqsafe_cpu_sub((pcp), 1)
+# ifndef irqsafe_cpu_dec_1
+# define irqsafe_cpu_dec_1(pcp) irqsafe_cpu_sub_1((pcp), 1)
+# endif
+# ifndef irqsafe_cpu_dec_2
+# define irqsafe_cpu_dec_2(pcp) irqsafe_cpu_sub_2((pcp), 1)
+# endif
+# ifndef irqsafe_cpu_dec_4
+# define irqsafe_cpu_dec_4(pcp) irqsafe_cpu_sub_4((pcp), 1)
+# endif
+# ifndef irqsafe_cpu_dec_8
+# define irqsafe_cpu_dec_8(pcp) irqsafe_cpu_sub_8((pcp), 1)
+# endif
+# define irqsafe_cpu_dec(pcp) __pcpu_size_call_noparam(irqsafe_cpu_dec_, (pcp))
#endif

#ifndef irqsafe_cpu_and

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/