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

Signed-off-by: Peter Zijlstra <[EMAIL PROTECTED]>
---
 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

--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to