KVM: Drop useless atomic test from timer function
[safe/jmp/linux-2.6] / kernel / lockdep.c
index cb70c1d..8bbeef9 100644 (file)
 #include <linux/hash.h>
 #include <linux/ftrace.h>
 #include <linux/stringify.h>
-#include <trace/lockdep.h>
 
 #include <asm/sections.h>
 
 #include "lockdep_internals.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/lockdep.h>
+
 #ifdef CONFIG_PROVE_LOCKING
 int prove_locking = 1;
 module_param(prove_locking, int, 0644);
@@ -434,13 +436,6 @@ atomic_t nr_find_usage_forwards_checks;
 atomic_t nr_find_usage_forwards_recursions;
 atomic_t nr_find_usage_backwards_checks;
 atomic_t nr_find_usage_backwards_recursions;
-# define debug_atomic_inc(ptr)         atomic_inc(ptr)
-# define debug_atomic_dec(ptr)         atomic_dec(ptr)
-# define debug_atomic_read(ptr)                atomic_read(ptr)
-#else
-# define debug_atomic_inc(ptr)         do { } while (0)
-# define debug_atomic_dec(ptr)         do { } while (0)
-# define debug_atomic_read(ptr)                0
 #endif
 
 /*
@@ -800,6 +795,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
 
                printk("BUG: MAX_LOCKDEP_KEYS too low!\n");
                printk("turning off the locking correctness validator.\n");
+               dump_stack();
                return NULL;
        }
        class = lock_classes + nr_lock_classes++;
@@ -863,6 +859,7 @@ static struct lock_list *alloc_list_entry(void)
 
                printk("BUG: MAX_LOCKDEP_ENTRIES too low!\n");
                printk("turning off the locking correctness validator.\n");
+               dump_stack();
                return NULL;
        }
        return list_entries + nr_list_entries++;
@@ -1689,6 +1686,7 @@ cache_hit:
 
                printk("BUG: MAX_LOCKDEP_CHAINS too low!\n");
                printk("turning off the locking correctness validator.\n");
+               dump_stack();
                return 0;
        }
        chain = lock_chains + nr_lock_chains++;
@@ -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)
 {
        /*
@@ -2477,13 +2492,20 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
 void lockdep_init_map(struct lockdep_map *lock, const char *name,
                      struct lock_class_key *key, int subclass)
 {
-       if (unlikely(!debug_locks))
+       lock->class_cache = NULL;
+#ifdef CONFIG_LOCK_STAT
+       lock->cpu = raw_smp_processor_id();
+#endif
+
+       if (DEBUG_LOCKS_WARN_ON(!name)) {
+               lock->name = "NULL";
                return;
+       }
+
+       lock->name = name;
 
        if (DEBUG_LOCKS_WARN_ON(!key))
                return;
-       if (DEBUG_LOCKS_WARN_ON(!name))
-               return;
        /*
         * Sanity check, the lock-class key must be persistent:
         */
@@ -2492,12 +2514,11 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
                DEBUG_LOCKS_WARN_ON(1);
                return;
        }
-       lock->name = name;
        lock->key = key;
-       lock->class_cache = NULL;
-#ifdef CONFIG_LOCK_STAT
-       lock->cpu = raw_smp_processor_id();
-#endif
+
+       if (unlikely(!debug_locks))
+               return;
+
        if (subclass)
                register_lock_class(lock, subclass, 1);
 }
@@ -2531,6 +2552,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
                debug_locks_off();
                printk("BUG: MAX_LOCKDEP_SUBCLASSES too low!\n");
                printk("turning off the locking correctness validator.\n");
+               dump_stack();
                return 0;
        }
 
@@ -2627,6 +2649,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
                debug_locks_off();
                printk("BUG: MAX_LOCK_DEPTH too low!\n");
                printk("turning off the locking correctness validator.\n");
+               dump_stack();
                return 0;
        }
 
@@ -2914,8 +2937,6 @@ void lock_set_class(struct lockdep_map *lock, const char *name,
 }
 EXPORT_SYMBOL_GPL(lock_set_class);
 
-DEFINE_TRACE(lock_acquire);
-
 /*
  * We are not always called with irqs disabled - do that here,
  * and also avoid lockdep recursion:
@@ -2942,8 +2963,6 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
 }
 EXPORT_SYMBOL_GPL(lock_acquire);
 
-DEFINE_TRACE(lock_release);
-
 void lock_release(struct lockdep_map *lock, int nested,
                          unsigned long ip)
 {
@@ -3084,6 +3103,8 @@ found_it:
                hlock->holdtime_stamp = now;
        }
 
+       trace_lock_acquired(lock, ip, waittime);
+
        stats = get_lock_stats(hlock_class(hlock));
        if (waittime) {
                if (hlock->read)
@@ -3099,8 +3120,6 @@ found_it:
        lock->ip = ip;
 }
 
-DEFINE_TRACE(lock_contended);
-
 void lock_contended(struct lockdep_map *lock, unsigned long ip)
 {
        unsigned long flags;
@@ -3122,14 +3141,10 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
 }
 EXPORT_SYMBOL_GPL(lock_contended);
 
-DEFINE_TRACE(lock_acquired);
-
 void lock_acquired(struct lockdep_map *lock, unsigned long ip)
 {
        unsigned long flags;
 
-       trace_lock_acquired(lock, ip);
-
        if (unlikely(!lock_stat))
                return;