--- include/linux/percpu.h | 255 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) Index: linux-2.6/include/linux/percpu.h =================================================================== --- linux-2.6.orig/include/linux/percpu.h 2009-09-16 18:27:47.000000000 -0500 +++ linux-2.6/include/linux/percpu.h 2009-09-16 19:13:13.000000000 -0500 @@ -243,6 +243,36 @@ do { \ # define percpu_xor(var, val) __percpu_generic_to_op(var, (val), ^=) #endif +/* + * Branching function to split up a function into a set of functions that + * are called for different sizes of the objects handled. + */ + +extern void __bad_size_call_parameter(void); + +#define __size_call_return(stem, variable) \ +({ \ + switch(sizeof(variable)) { \ + case 1: return stem##1(variable); \ + case 2: return stem##2(variable); \ + case 4: return stem##4(variable); \ + case 8: return stem##8(variable); \ + default: \ + __bad_size_call_parameter(); \ + } \ +}) + +#define __size_call(stem, variable, ...) \ +do { \ + switch(sizeof(variable)) { \ + case 1: stem##1(variable, __VA_ARGS__);break; \ + case 2: stem##2(variable, __VA_ARGS__);break; \ + case 4: stem##4(variable, __VA_ARGS__);break; \ + case 8: stem##8(variable, __VA_ARGS__);break; \ + default: \ + __bad_size_call_parameter();break; \ + } \ +} while (0) /* * Optimized manipulation for memory allocated through the per cpu @@ -263,6 +293,21 @@ do { \ ({ \ *this_cpu_ptr(&(pcp)); \ }) +#else +# ifndef this_cpu_read_1 +# define this_cpu_read_1(pcp) (*this_cpu_ptr(&(pcp)) +# endif +# ifndef this_cpu_read_2 +# define this_cpu_read_2(pcp) (*this_cpu_ptr(&(pcp)) +# endif +# ifndef this_cpu_read_4 +# define this_cpu_read_4(pcp) (*this_cpu_ptr(&(pcp)) +# endif +# ifndef this_cpu_read_8 +/* Double word fetch which may require two fetches */ +# define this_cpu_read_8(pcp) (preempt_disable();*this_cpu_ptr(&(pcp);preempt_enable()) +# endif +# define this_cpu_read(pcp) __size_call_return(this_cpu_read_, (pcp) #endif #define _this_cpu_generic_to_op(pcp, val, op) \ @@ -274,10 +319,38 @@ do { \ #ifndef this_cpu_write # define this_cpu_write(pcp, val) _this_cpu_generic_to_op((pcp), (val), =) +#else +# ifndef this_cpu_write_1 +# define this_cpu_write_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), =) +# endif +# ifndef this_cpu_write_2 +# define this_cpu_write_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), =) +# endif +# ifndef this_cpu_write_4 +# define this_cpu_write_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), =) +# endif +# ifndef this_cpu_write_8 +# define this_cpu_write_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), =) +# endif +# define this_cpu_write(pcp, val) __size_call(this_cpu_write_, (pcp), (val)) #endif #ifndef this_cpu_add # define this_cpu_add(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=) +#else +# ifndef this_cpu_add_1 +# define this_cpu_add_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef this_cpu_add_2 +# define this_cpu_add_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef this_cpu_add_4 +# define this_cpu_add_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef this_cpu_add_8 +# define this_cpu_add_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=) +# endif +# define this_cpu_add(pcp, val) __size_call(this_cpu_add_, (pcp), (val)) #endif #ifndef this_cpu_sub @@ -294,14 +367,56 @@ do { \ #ifndef this_cpu_and # define this_cpu_and(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=) +#else +# ifndef this_cpu_and_1 +# define this_cpu_and_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef this_cpu_and_2 +# define this_cpu_and_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef this_cpu_and_4 +# define this_cpu_and_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef this_cpu_and_8 +# define this_cpu_and_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=) +# endif +# define this_cpu_and(pcp, val) __size_call(this_cpu_and_, (pcp), (val)) #endif #ifndef this_cpu_or # define this_cpu_or(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=) +#else +# ifndef this_cpu_or_1 +# define this_cpu_or_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef this_cpu_or_2 +# define this_cpu_or_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef this_cpu_or_4 +# define this_cpu_or_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef this_cpu_or_8 +# define this_cpu_or_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=) +# endif +# define this_cpu_or(pcp, val) __size_call(this_cpu_or_, (pcp), (val)) #endif #ifndef this_cpu_xor # define this_cpu_xor(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=) +#else +# ifndef this_cpu_xor_1 +# define this_cpu_xor_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef this_cpu_xor_2 +# define this_cpu_xor_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef this_cpu_xor_4 +# define this_cpu_xor_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef this_cpu_xor_8 +# define this_cpu_xor_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# define this_cpu_xor(pcp, val) __size_call(this_cpu_or_, (pcp), (val)) #endif @@ -321,6 +436,20 @@ do { \ ({ \ *__this_cpu_ptr(&(pcp)); \ }) +#else +# ifndef __this_cpu_read_1 +# define __this_cpu_read_1(pcp) (*this_cpu_ptr(&(pcp)) +# endif +# ifndef __this_cpu_read_2 +# define __this_cpu_read_2(pcp) (*this_cpu_ptr(&(pcp)) +# endif +# ifndef __this_cpu_read_4 +# define __this_cpu_read_4(pcp) (*this_cpu_ptr(&(pcp)) +# endif +# ifndef this_cpu_read_8 +# define this_cpu_read_8(pcp) (*this_cpu_ptr(&(pcp)) +# endif +# define __this_cpu_read(pcp) __size_call_return(__this_cpu_read_, (pcp) #endif #define __this_cpu_generic_to_op(pcp, val, op) \ @@ -330,10 +459,38 @@ do { \ #ifndef __this_cpu_write # define __this_cpu_write(pcp, val) __this_cpu_generic_to_op((pcp), (val), =) +#else +# ifndef __this_cpu_write_1 +# define __this_cpu_write_1(pcp,, val) __this_cpu_generic_to_op((pcp), (val), =) +# endif +# ifndef __this_cpu_write_2 +# define __this_cpu_write_2(pcp,, val) __this_cpu_generic_to_op((pcp), (val), =) +# endif +# ifndef __this_cpu_write_4 +# define __this_cpu_write_4(pcp,, val) __this_cpu_generic_to_op((pcp), (val), =) +# endif +# ifndef __this_cpu_write_8 +# define __this_cpu_write_8(pcp,, val) __this_cpu_generic_to_op((pcp), (val), =) +# endif +# define __this_cpu_write(pcp, val) __size_call(__this_cpu_write_, pcp, val) #endif #ifndef __this_cpu_add # define __this_cpu_add(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=) +#else +# ifndef __this_cpu_add_1 +# define __this_cpu_add_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef __this_cpu_add_2 +# define __this_cpu_add_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef __this_cpu_add_4 +# define __this_cpu_add_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef __this_cpu_add_8 +# define __this_cpu_add_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=) +# endif +# define __this_cpu_add(pcp, val) __size_call(__this_cpu_add_, pcp, val) #endif #ifndef __this_cpu_sub @@ -350,14 +507,56 @@ do { \ #ifndef __this_cpu_and # define __this_cpu_and(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=) +#else +# ifndef __this_cpu_and_1 +# define __this_cpu_and_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef __this_cpu_and_2 +# define __this_cpu_and_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef __this_cpu_and_4 +# define __this_cpu_and_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef __this_cpu_and_8 +# define __this_cpu_and_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=) +# endif +# define __this_cpu_and(pcp, val) __size_call(__this_cpu_and_, pcp, val) #endif #ifndef __this_cpu_or # define __this_cpu_or(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=) +#else +# ifndef __this_cpu_or_1 +# define __this_cpu_or_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef __this_cpu_or_2 +# define __this_cpu_or_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef __this_cpu_or_4 +# define __this_cpu_or_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef __this_cpu_or_8 +# define __this_cpu_or_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=) +# endif +# define __this_cpu_or(pcp, val) __size_call(__this_cpu_or_, pcp, val) #endif #ifndef __this_cpu_xor # define __this_cpu_xor(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=) +#else +# ifndef __this_cpu_xor_1 +# define __this_cpu_xor_1(pcp,, val) __this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef __this_cpu_xor_2 +# define __this_cpu_xor_2(pcp,, val) __this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef __this_cpu_xor_4 +# define __this_cpu_xor_4(pcp,, val) __this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef __this_cpu_xor_8 +# define __this_cpu_xor_8(pcp,, val) __this_cpu_generic_to_op((pcp), (val), ^=) +# endif +# define __this_cpu_xor(pcp, val) __size_call(__this_cpu_xor_, pcp, val) #endif /* @@ -376,6 +575,20 @@ do { \ #ifndef irqsafe_this_cpu_add # define irqsafe_this_cpu_add(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=) +#else +# ifndef irqsafe_this_cpu_add_1 +# define(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef irqsafe_this_cpu_add_2 +# define(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef irqsafe_this_cpu_add_4 +# define(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=) +# endif +# ifndef irqsafe_this_cpu_add_8 +# define(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=) +# endif +# define irqsafe_this_cpu_add(pcp, val) __size_call(irqsafe_this_cpu_add_, (val)) #endif #ifndef irqsafe_this_cpu_sub @@ -392,14 +605,56 @@ do { \ #ifndef irqsafe_this_cpu_and # define irqsafe_this_cpu_and(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=) +#else +# ifndef irqsafe_this_cpu_and_1 +# define irqsafe_this_cpu_and_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef irqsafe_this_cpu_and_2 +# define irqsafe_this_cpu_and_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef irqsafe_this_cpu_and_4 +# define irqsafe_this_cpu_and_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=) +# endif +# ifndef irqsafe_this_cpu_and_8 +# define irqsafe_this_cpu_and_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=) +# endif +# define irqsafe_this_cpu_and(pcp, val) __size_call(irqsafe_this_cpu_and_, (val)) #endif #ifndef irqsafe_this_cpu_or # define irqsafe_this_cpu_or(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=) +#else +# ifndef irqsafe_this_cpu_or_1 +# define irqsafe_this_cpu_or_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef irqsafe_this_cpu_or_2 +# define irqsafe_this_cpu_or_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef irqsafe_this_cpu_or_4 +# define irqsafe_this_cpu_or_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=) +# endif +# ifndef irqsafe_this_cpu_or_8 +# define irqsafe_this_cpu_or(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=) +# endif +# define irqsafe_this_cpu_or(pcp, val) __size_call(irqsafe_this_cpu_or_, (val)) #endif #ifndef irqsafe_this_cpu_xor # define irqsafe_this_cpu_xor(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=) +#else +# ifndef irqsafe_this_cpu_xor_1 +# define irqsafe_this_cpu_xor_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef irqsafe_this_cpu_xor_2 +# define irqsafe_this_cpu_xor_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef irqsafe_this_cpu_xor_4 +# define irqsafe_this_cpu_xor_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=) +# endif +# ifndef irqsafe_this_cpu_xor_8 +# define irqsafe_this_cpu_xor_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=) +# endif +# define irqsafe_this_cpu_add(pcp, val) __size_call(irqsafe_this_cpu_add_, (val)) #endif #endif /* __LINUX_PERCPU_H */