mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-kernel@vger.kernel.org
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Nick Piggin <nickpiggin@yahoo.com.au>
Subject: [RFC][PATCH 3/6] lockdep: rcu_dereference() vs preempt_disable()
Date: Wed, 19 Sep 2007 12:41:28 +0200	[thread overview]
Message-ID: <20070919105054.585517000@chello.nl> (raw)
In-Reply-To: <20070919104125.286538000@chello.nl>

[-- Attachment #1: rcu-lockdep-preempt.patch --]
[-- Type: text/plain, Size: 3392 bytes --]

Don't warn when preemption is disabled using preempt_disable()

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/preempt.h |   19 +++++++++++--------
 kernel/sched.c          |   14 ++++++++++----
 lib/Kconfig.debug       |    1 +
 3 files changed, 22 insertions(+), 12 deletions(-)

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -3396,7 +3396,7 @@ void scheduler_tick(void)
 
 #if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT)
 
-void fastcall add_preempt_count(int val)
+void fastcall __add_preempt_count(int val, int exp)
 {
 	/*
 	 * Underflow?
@@ -3409,10 +3409,13 @@ void fastcall add_preempt_count(int val)
 	 */
 	DEBUG_LOCKS_WARN_ON((preempt_count() & PREEMPT_MASK) >=
 				PREEMPT_MASK - 10);
+
+	if (exp)
+		rcu_read_acquire();
 }
-EXPORT_SYMBOL(add_preempt_count);
+EXPORT_SYMBOL(__add_preempt_count);
 
-void fastcall sub_preempt_count(int val)
+void fastcall __sub_preempt_count(int val, int exp)
 {
 	/*
 	 * Underflow?
@@ -3427,8 +3430,11 @@ void fastcall sub_preempt_count(int val)
 		return;
 
 	preempt_count() -= val;
+
+	if (exp)
+		rcu_read_release();
 }
-EXPORT_SYMBOL(sub_preempt_count);
+EXPORT_SYMBOL(__sub_preempt_count);
 
 #endif
 
Index: linux-2.6/include/linux/preempt.h
===================================================================
--- linux-2.6.orig/include/linux/preempt.h
+++ linux-2.6/include/linux/preempt.h
@@ -11,15 +11,18 @@
 #include <linux/list.h>
 
 #ifdef CONFIG_DEBUG_PREEMPT
-  extern void fastcall add_preempt_count(int val);
-  extern void fastcall sub_preempt_count(int val);
+  extern void fastcall __add_preempt_count(int val, int exp);
+  extern void fastcall __sub_preempt_count(int val, int exp);
 #else
-# define add_preempt_count(val)	do { preempt_count() += (val); } while (0)
-# define sub_preempt_count(val)	do { preempt_count() -= (val); } while (0)
+# define __add_preempt_count(val, exp)	do { preempt_count() += (val); } while (0)
+# define __sub_preempt_count(val, exp)	do { preempt_count() -= (val); } while (0)
 #endif
 
-#define inc_preempt_count() add_preempt_count(1)
-#define dec_preempt_count() sub_preempt_count(1)
+#define add_preempt_count(val) __add_preempt_count(val, 0);
+#define sub_preempt_count(val) __sub_preempt_count(val, 0);
+
+#define inc_preempt_count() __add_preempt_count(1, 0)
+#define dec_preempt_count() __sub_preempt_count(1, 0)
 
 #define preempt_count()	(current_thread_info()->preempt_count)
 
@@ -29,14 +32,14 @@ asmlinkage void preempt_schedule(void);
 
 #define preempt_disable() \
 do { \
-	inc_preempt_count(); \
+	__add_preempt_count(1, 1); \
 	barrier(); \
 } while (0)
 
 #define preempt_enable_no_resched() \
 do { \
 	barrier(); \
-	dec_preempt_count(); \
+	__sub_preempt_count(1, 1); \
 } while (0)
 
 #define preempt_check_resched() \
Index: linux-2.6/lib/Kconfig.debug
===================================================================
--- linux-2.6.orig/lib/Kconfig.debug
+++ linux-2.6/lib/Kconfig.debug
@@ -237,6 +237,7 @@ config DEBUG_SEMAPHORE
 config DEBUG_LOCK_ALLOC
 	bool "Lock debugging: detect incorrect freeing of live locks"
 	depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
+	select DEBUG_PREEMPT
 	select DEBUG_SPINLOCK
 	select DEBUG_MUTEXES
 	select LOCKDEP

--


  parent reply	other threads:[~2007-09-19 10:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-19 10:41 [RFC][PATCH 0/6] using lockdep to validate rcu usage Peter Zijlstra
2007-09-19 10:41 ` [RFC][PATCH 1/6] lockdep: annotate rcu_read_{,un}lock{,_bh} Peter Zijlstra
2007-09-19 23:06   ` Paul E. McKenney
2007-09-19 10:41 ` [RFC][PATCH 2/6] lockdep: validate rcu_dereference() vs rcu_read_lock() Peter Zijlstra
2007-09-19 14:17   ` Dmitry Torokhov
2007-09-19 14:31     ` Peter Zijlstra
2007-09-19 15:16       ` Dmitry Torokhov
2007-09-19 15:25         ` Peter Zijlstra
2007-09-19 15:37         ` Paul E. McKenney
2007-09-19 16:59           ` Dmitry Torokhov
2007-09-19 17:32             ` Paul E. McKenney
2007-09-19 17:48               ` Paul E. McKenney
2007-09-19 18:49                 ` Dmitry Torokhov
2007-09-19 19:41                   ` Peter Zijlstra
2007-09-19 19:49                     ` Dmitry Torokhov
2007-09-19 20:13                       ` Peter Zijlstra
2007-09-19 20:41                         ` Dmitry Torokhov
2007-09-19 21:19                           ` Peter Zijlstra
2007-09-19 21:29                             ` Dmitry Torokhov
2007-09-19 21:47                               ` Peter Zijlstra
2007-09-20 17:31                                 ` Dmitry Torokhov
2007-09-21  0:01                                   ` Paul E. McKenney
2007-09-21 14:15                                     ` Dmitry Torokhov
2007-09-21 14:30                                       ` Peter Zijlstra
2007-09-19 20:48                       ` Paul E. McKenney
2007-09-19 10:41 ` Peter Zijlstra [this message]
2007-09-19 10:41 ` [RFC][PATCH 4/6] implicit vs explicit preempt_disable() Peter Zijlstra
2007-09-19 10:41 ` [RFC][PATCH 5/6] fixup funny preemption tricks in irq_exit Peter Zijlstra
2007-09-19 10:41 ` [RFC][PATCH 6/6] fixup early boot Peter Zijlstra
2007-09-19 13:38 ` [RFC][PATCH 0/6] using lockdep to validate rcu usage Ingo Molnar

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=20070919105054.585517000@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    --cc=paulmck@linux.vnet.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome