]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/lockdep.c
lockdep: fix deadlock in lockdep_trace_alloc
[linux-2.6-omap-h63xx.git] / kernel / lockdep.c
index 42dfc28d12ccd53b8b880c4270aee4a420dbedc2..3673a3f44d9d445f7cdf42f2ee5592731a4c0db7 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/utsname.h>
 #include <linux/hash.h>
 #include <linux/ftrace.h>
+#include <linux/stringify.h>
 
 #include <asm/sections.h>
 
@@ -445,14 +446,11 @@ atomic_t nr_find_usage_backwards_recursions;
  * Locking printouts:
  */
 
-#define __STR(foo)     #foo
-#define STR(foo)       __STR(foo)
-
 #define __USAGE(__STATE)                                               \
-       [LOCK_USED_IN_##__STATE] = "IN-"STR(__STATE)"-W",               \
-       [LOCK_ENABLED_##__STATE] = STR(__STATE)"-ON-W",                 \
-       [LOCK_USED_IN_##__STATE##_READ] = "IN-"STR(__STATE)"-R",        \
-       [LOCK_ENABLED_##__STATE##_READ] = STR(__STATE)"-ON-R",
+       [LOCK_USED_IN_##__STATE] = "IN-"__stringify(__STATE)"-W",       \
+       [LOCK_ENABLED_##__STATE] = __stringify(__STATE)"-ON-W",         \
+       [LOCK_USED_IN_##__STATE##_READ] = "IN-"__stringify(__STATE)"-R",\
+       [LOCK_ENABLED_##__STATE##_READ] = __stringify(__STATE)"-ON-R",
 
 static const char *usage_str[] =
 {
@@ -1270,14 +1268,14 @@ check_usage(struct task_struct *curr, struct held_lock *prev,
 
 static const char *state_names[] = {
 #define LOCKDEP_STATE(__STATE) \
-       STR(__STATE),
+       __stringify(__STATE),
 #include "lockdep_states.h"
 #undef LOCKDEP_STATE
 };
 
 static const char *state_rnames[] = {
 #define LOCKDEP_STATE(__STATE) \
-       STR(__STATE)"-READ",
+       __stringify(__STATE)"-READ",
 #include "lockdep_states.h"
 #undef LOCKDEP_STATE
 };
@@ -2262,7 +2260,7 @@ void trace_softirqs_off(unsigned long ip)
                debug_atomic_inc(&redundant_softirqs_off);
 }
 
-void lockdep_trace_alloc(gfp_t gfp_mask)
+static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags)
 {
        struct task_struct *curr = current;
 
@@ -2281,12 +2279,29 @@ void lockdep_trace_alloc(gfp_t gfp_mask)
        if (!(gfp_mask & __GFP_FS))
                return;
 
-       if (DEBUG_LOCKS_WARN_ON(irqs_disabled()))
+       if (DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags)))
                return;
 
        mark_held_locks(curr, RECLAIM_FS);
 }
 
+static void check_flags(unsigned long flags);
+
+void lockdep_trace_alloc(gfp_t gfp_mask)
+{
+       unsigned long flags;
+
+       if (unlikely(current->lockdep_recursion))
+               return;
+
+       raw_local_irq_save(flags);
+       check_flags(flags);
+       current->lockdep_recursion = 1;
+       __lockdep_trace_alloc(gfp_mask, flags);
+       current->lockdep_recursion = 0;
+       raw_local_irq_restore(flags);
+}
+
 static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock)
 {
        /*
@@ -2398,6 +2413,10 @@ static inline int separate_irq_context(struct task_struct *curr,
        return 0;
 }
 
+void lockdep_trace_alloc(gfp_t gfp_mask)
+{
+}
+
 #endif
 
 /*