From: Steven Rostedt The conversion of per_cpu() and get_cpu_var() to this_cpu_read/write() removed the debug check against using cpu variables in non atomic sections. There are few cases where that is fine, but 99% of the time, if a per cpu variable is going to be played with, it had better happen in an atomic area, otherwise hard to find bugs may occur. Right now only this_cpu_read/write() were updated. Maybe it would be a good idea to handle the other this_cpu_*() functions as well. Cc: Christoph Lameter Cc: Tejun Heo Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Ingo Molnar Signed-off-by: Steven Rostedt --- include/linux/percpu.h | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 9ca008f..a4048de 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -22,6 +22,13 @@ PERCPU_MODULE_RESERVE) #endif +#ifdef CONFIG_DEBUG_PREEMPT +# define debug_check_cpu() smp_processor_id() +#else +# define debug_check_cpu() +#endif + + /* * Must be an lvalue. Since @var must be a simple identifier, * we force a syntax error here if it isn't. @@ -342,7 +349,10 @@ do { \ # ifndef this_cpu_read_8 # define this_cpu_read_8(pcp) _this_cpu_generic_read(pcp) # endif -# define this_cpu_read(pcp) __pcpu_size_call_return(this_cpu_read_, (pcp)) +# define this_cpu_read(pcp) ({ \ + debug_check_cpu(); \ + __pcpu_size_call_return(this_cpu_read_, (pcp)); \ + }) #endif #define _this_cpu_generic_to_op(pcp, val, op) \ @@ -365,7 +375,10 @@ do { \ # 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) __pcpu_size_call(this_cpu_write_, (pcp), (val)) +# define this_cpu_write(pcp, val) ({ \ + debug_check_cpu(); \ + __pcpu_size_call(this_cpu_write_, (pcp), (val)); \ + }) #endif #ifndef this_cpu_add -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/