All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Christoph Lameter <cl@linux.com>, Tejun Heo <tj@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [RFC][PATCH 5/5] percpu: Add preempt checks back into this_cpu_read/write()
Date: Mon, 19 Sep 2011 17:20:45 -0400	[thread overview]
Message-ID: <20110919212641.527742267@goodmis.org> (raw)
In-Reply-To: 20110919212040.745370781@goodmis.org

[-- Attachment #1: 0005-percpu-Add-preempt-checks-back-into-this_cpu_read-wr.patch --]
[-- Type: text/plain, Size: 2106 bytes --]

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



  parent reply	other threads:[~2011-09-19 21:26 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 21:20 [RFC][PATCH 0/5] Introduce checks for preemptable code for this_cpu_read/write() Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 1/5] x86: Remove const_udelay() caring about which cpu var it uses Steven Rostedt
2011-09-19 21:51   ` Christoph Lameter
2011-09-19 23:31     ` Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 2/5] mm: Switch mod_state() to __this_cpu_read() Steven Rostedt
2011-09-19 22:02   ` Christoph Lameter
2011-09-19 23:48     ` Steven Rostedt
2011-09-20 14:46       ` Christoph Lameter
2011-09-20 15:16         ` Steven Rostedt
2011-09-20 15:54           ` Christoph Lameter
2011-09-20 16:07             ` Steven Rostedt
2011-09-20 22:19             ` Valdis.Kletnieks
2011-09-20 13:49     ` Thomas Gleixner
2011-09-20 14:01       ` Steven Rostedt
2011-09-20 14:51       ` Christoph Lameter
2011-09-20 15:11         ` Steven Rostedt
2011-09-20 15:59           ` Christoph Lameter
2011-09-20 16:03             ` Steven Rostedt
2011-09-20 16:07               ` Christoph Lameter
2011-09-20 15:27         ` Thomas Gleixner
2011-09-20 16:02           ` Christoph Lameter
2011-09-20 16:51             ` Thomas Gleixner
2011-09-20 17:08               ` Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 3/5] memcg: Disable preemption in memcg_check_events() Steven Rostedt
2011-09-20 14:20   ` Johannes Weiner
2011-09-20 14:24     ` Johannes Weiner
2011-09-20 14:33       ` Steven Rostedt
2011-09-24  0:46   ` Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 4/5] printk: Have wake_up_klogd() use __this_cpu_write() Steven Rostedt
2011-09-19 21:54   ` Christoph Lameter
2011-09-19 23:33     ` Steven Rostedt
2011-09-20 14:54       ` Christoph Lameter
2011-09-20 14:55         ` Peter Zijlstra
2011-09-19 21:20 ` Steven Rostedt [this message]
2011-09-19 21:49 ` [RFC][PATCH 0/5] Introduce checks for preemptable code for this_cpu_read/write() Christoph Lameter
2011-09-20  3:06   ` Steven Rostedt
2011-09-20 12:44     ` Valdis.Kletnieks
2011-09-20 13:51       ` Thomas Gleixner
2011-09-20 14:58         ` Christoph Lameter
2011-09-20 15:17           ` Steven Rostedt
2011-09-20 14:57       ` Christoph Lameter
2011-09-20 15:19         ` Steven Rostedt
2011-09-20 16:08           ` Christoph Lameter
2011-09-20 16:31             ` Steven Rostedt
2011-09-20 16:56               ` Steven Rostedt
2011-09-20 17:09                 ` Peter Zijlstra
2011-09-20 17:15                   ` Steven Rostedt
2011-09-20 17:25                     ` Mathieu Desnoyers
2011-09-20 18:03                       ` Steven Rostedt
2011-09-20 18:12                         ` Mathieu Desnoyers
2011-09-20 18:27                           ` Steven Rostedt
2011-09-20 18:34                             ` Mathieu Desnoyers
2011-09-20 22:32             ` Valdis.Kletnieks
2011-09-20 22:17           ` Valdis.Kletnieks
2011-09-21  1:33             ` Steven Rostedt
2011-09-20 15:46     ` Mathieu Desnoyers
2011-09-20 16:00       ` Steven Rostedt
2011-09-20 16:10         ` Christoph Lameter
2011-09-20 16:50           ` Peter Zijlstra
2011-09-20 18:54           ` Steven Rostedt
2011-09-21 15:16             ` Christoph Lameter
2011-09-21 15:31               ` Steven Rostedt
2011-09-21 15:59                 ` Christoph Lameter
2011-09-21 16:12                   ` Steven Rostedt
2011-09-21 16:32               ` Thomas Gleixner
2011-09-20  2:20 ` Andi Kleen
2011-09-20  3:12   ` Steven Rostedt
2011-09-20  3:17     ` Steven Rostedt
2011-09-20  8:32     ` Thomas Gleixner
2011-09-20 12:10       ` Steven Rostedt
2011-09-20 15:03       ` Christoph Lameter
2011-09-20 15:07         ` Peter Zijlstra
2011-09-20 16:05           ` Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110919212641.527742267@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.