Messages in this thread Patch in this message |  | | | Date | Mon, 19 Sep 2011 17:20:45 -0400 | | From | Steven Rostedt <> | | Subject | [RFC][PATCH 5/5] percpu: Add preempt checks back into this_cpu_read/write() |
| |
From: Steven Rostedt <srostedt@redhat.com>
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 <cl@linux.com> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> --- 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
|  |