dynamic_debug: factor vpr_info_dq out of ddebug_parse_query
[linux-2.6.git] / lib / spinlock_debug.c
index 2acd501..5f3eacd 100644 (file)
@@ -13,8 +13,8 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 
-void __spin_lock_init(spinlock_t *lock, const char *name,
-                     struct lock_class_key *key)
+void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
+                         struct lock_class_key *key)
 {
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
        /*
@@ -23,13 +23,13 @@ void __spin_lock_init(spinlock_t *lock, const char *name,
        debug_check_no_locks_freed((void *)lock, sizeof(*lock));
        lockdep_init_map(&lock->dep_map, name, key, 0);
 #endif
-       lock->raw_lock = (arch_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+       lock->raw_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
        lock->magic = SPINLOCK_MAGIC;
        lock->owner = SPINLOCK_OWNER_INIT;
        lock->owner_cpu = -1;
 }
 
-EXPORT_SYMBOL(__spin_lock_init);
+EXPORT_SYMBOL(__raw_spin_lock_init);
 
 void __rwlock_init(rwlock_t *lock, const char *name,
                   struct lock_class_key *key)
@@ -41,7 +41,7 @@ void __rwlock_init(rwlock_t *lock, const char *name,
        debug_check_no_locks_freed((void *)lock, sizeof(*lock));
        lockdep_init_map(&lock->dep_map, name, key, 0);
 #endif
-       lock->raw_lock = (raw_rwlock_t) __RAW_RW_LOCK_UNLOCKED;
+       lock->raw_lock = (arch_rwlock_t) __ARCH_RW_LOCK_UNLOCKED;
        lock->magic = RWLOCK_MAGIC;
        lock->owner = SPINLOCK_OWNER_INIT;
        lock->owner_cpu = -1;
@@ -49,13 +49,10 @@ void __rwlock_init(rwlock_t *lock, const char *name,
 
 EXPORT_SYMBOL(__rwlock_init);
 
-static void spin_bug(spinlock_t *lock, const char *msg)
+static void spin_dump(raw_spinlock_t *lock, const char *msg)
 {
        struct task_struct *owner = NULL;
 
-       if (!debug_locks_off())
-               return;
-
        if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT)
                owner = lock->owner;
        printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n",
@@ -70,10 +67,18 @@ static void spin_bug(spinlock_t *lock, const char *msg)
        dump_stack();
 }
 
+static void spin_bug(raw_spinlock_t *lock, const char *msg)
+{
+       if (!debug_locks_off())
+               return;
+
+       spin_dump(lock, msg);
+}
+
 #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
 
 static inline void
-debug_spin_lock_before(spinlock_t *lock)
+debug_spin_lock_before(raw_spinlock_t *lock)
 {
        SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic");
        SPIN_BUG_ON(lock->owner == current, lock, "recursion");
@@ -81,16 +86,16 @@ debug_spin_lock_before(spinlock_t *lock)
                                                        lock, "cpu recursion");
 }
 
-static inline void debug_spin_lock_after(spinlock_t *lock)
+static inline void debug_spin_lock_after(raw_spinlock_t *lock)
 {
        lock->owner_cpu = raw_smp_processor_id();
        lock->owner = current;
 }
 
-static inline void debug_spin_unlock(spinlock_t *lock)
+static inline void debug_spin_unlock(raw_spinlock_t *lock)
 {
        SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic");
-       SPIN_BUG_ON(!spin_is_locked(lock), lock, "already unlocked");
+       SPIN_BUG_ON(!raw_spin_is_locked(lock), lock, "already unlocked");
        SPIN_BUG_ON(lock->owner != current, lock, "wrong owner");
        SPIN_BUG_ON(lock->owner_cpu != raw_smp_processor_id(),
                                                        lock, "wrong CPU");
@@ -98,7 +103,7 @@ static inline void debug_spin_unlock(spinlock_t *lock)
        lock->owner_cpu = -1;
 }
 
-static void __spin_lock_debug(spinlock_t *lock)
+static void __spin_lock_debug(raw_spinlock_t *lock)
 {
        u64 i;
        u64 loops = loops_per_jiffy * HZ;
@@ -106,18 +111,14 @@ static void __spin_lock_debug(spinlock_t *lock)
 
        for (;;) {
                for (i = 0; i < loops; i++) {
-                       if (__raw_spin_trylock(&lock->raw_lock))
+                       if (arch_spin_trylock(&lock->raw_lock))
                                return;
                        __delay(1);
                }
                /* lockup suspected: */
                if (print_once) {
                        print_once = 0;
-                       printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, "
-                                       "%s/%d, %p\n",
-                               raw_smp_processor_id(), current->comm,
-                               task_pid_nr(current), lock);
-                       dump_stack();
+                       spin_dump(lock, "lockup");
 #ifdef CONFIG_SMP
                        trigger_all_cpu_backtrace();
 #endif
@@ -125,17 +126,17 @@ static void __spin_lock_debug(spinlock_t *lock)
        }
 }
 
-void _raw_spin_lock(spinlock_t *lock)
+void do_raw_spin_lock(raw_spinlock_t *lock)
 {
        debug_spin_lock_before(lock);
-       if (unlikely(!__raw_spin_trylock(&lock->raw_lock)))
+       if (unlikely(!arch_spin_trylock(&lock->raw_lock)))
                __spin_lock_debug(lock);
        debug_spin_lock_after(lock);
 }
 
-int _raw_spin_trylock(spinlock_t *lock)
+int do_raw_spin_trylock(raw_spinlock_t *lock)
 {
-       int ret = __raw_spin_trylock(&lock->raw_lock);
+       int ret = arch_spin_trylock(&lock->raw_lock);
 
        if (ret)
                debug_spin_lock_after(lock);
@@ -148,10 +149,10 @@ int _raw_spin_trylock(spinlock_t *lock)
        return ret;
 }
 
-void _raw_spin_unlock(spinlock_t *lock)
+void do_raw_spin_unlock(raw_spinlock_t *lock)
 {
        debug_spin_unlock(lock);
-       __raw_spin_unlock(&lock->raw_lock);
+       arch_spin_unlock(&lock->raw_lock);
 }
 
 static void rwlock_bug(rwlock_t *lock, const char *msg)
@@ -176,7 +177,7 @@ static void __read_lock_debug(rwlock_t *lock)
 
        for (;;) {
                for (i = 0; i < loops; i++) {
-                       if (__raw_read_trylock(&lock->raw_lock))
+                       if (arch_read_trylock(&lock->raw_lock))
                                return;
                        __delay(1);
                }
@@ -193,15 +194,15 @@ static void __read_lock_debug(rwlock_t *lock)
 }
 #endif
 
-void _raw_read_lock(rwlock_t *lock)
+void do_raw_read_lock(rwlock_t *lock)
 {
        RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
-       __raw_read_lock(&lock->raw_lock);
+       arch_read_lock(&lock->raw_lock);
 }
 
-int _raw_read_trylock(rwlock_t *lock)
+int do_raw_read_trylock(rwlock_t *lock)
 {
-       int ret = __raw_read_trylock(&lock->raw_lock);
+       int ret = arch_read_trylock(&lock->raw_lock);
 
 #ifndef CONFIG_SMP
        /*
@@ -212,10 +213,10 @@ int _raw_read_trylock(rwlock_t *lock)
        return ret;
 }
 
-void _raw_read_unlock(rwlock_t *lock)
+void do_raw_read_unlock(rwlock_t *lock)
 {
        RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
-       __raw_read_unlock(&lock->raw_lock);
+       arch_read_unlock(&lock->raw_lock);
 }
 
 static inline void debug_write_lock_before(rwlock_t *lock)
@@ -251,7 +252,7 @@ static void __write_lock_debug(rwlock_t *lock)
 
        for (;;) {
                for (i = 0; i < loops; i++) {
-                       if (__raw_write_trylock(&lock->raw_lock))
+                       if (arch_write_trylock(&lock->raw_lock))
                                return;
                        __delay(1);
                }
@@ -268,16 +269,16 @@ static void __write_lock_debug(rwlock_t *lock)
 }
 #endif
 
-void _raw_write_lock(rwlock_t *lock)
+void do_raw_write_lock(rwlock_t *lock)
 {
        debug_write_lock_before(lock);
-       __raw_write_lock(&lock->raw_lock);
+       arch_write_lock(&lock->raw_lock);
        debug_write_lock_after(lock);
 }
 
-int _raw_write_trylock(rwlock_t *lock)
+int do_raw_write_trylock(rwlock_t *lock)
 {
-       int ret = __raw_write_trylock(&lock->raw_lock);
+       int ret = arch_write_trylock(&lock->raw_lock);
 
        if (ret)
                debug_write_lock_after(lock);
@@ -290,8 +291,8 @@ int _raw_write_trylock(rwlock_t *lock)
        return ret;
 }
 
-void _raw_write_unlock(rwlock_t *lock)
+void do_raw_write_unlock(rwlock_t *lock)
 {
        debug_write_unlock(lock);
-       __raw_write_unlock(&lock->raw_lock);
+       arch_write_unlock(&lock->raw_lock);
 }