[PATCH] lockdep: remove DEBUG_BUG_ON()
[pandora-kernel.git] / kernel / mutex-debug.c
index 4fcb051..fe0e9f2 100644 (file)
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/poison.h>
 #include <linux/spinlock.h>
 #include <linux/kallsyms.h>
 #include <linux/interrupt.h>
 
-#include <asm/mutex.h>
-
 #include "mutex-debug.h"
 
 /*
@@ -155,13 +154,13 @@ next:
                        continue;
                count++;
                cursor = curr->next;
-               debug_spin_lock_restore(&debug_mutex_lock, flags);
+               debug_spin_unlock_restore(&debug_mutex_lock, flags);
 
                printk("\n#%03d:            ", count);
                printk_lock(lock, filter ? 0 : 1);
                goto next;
        }
-       debug_spin_lock_restore(&debug_mutex_lock, flags);
+       debug_spin_unlock_restore(&debug_mutex_lock, flags);
        printk("\n");
 }
 
@@ -318,7 +317,7 @@ void mutex_debug_check_no_locks_held(struct task_struct *task)
                        continue;
                list_del_init(curr);
                DEBUG_OFF();
-               debug_spin_lock_restore(&debug_mutex_lock, flags);
+               debug_spin_unlock_restore(&debug_mutex_lock, flags);
 
                printk("BUG: %s/%d, lock held at task exit time!\n",
                        task->comm, task->pid);
@@ -327,7 +326,7 @@ void mutex_debug_check_no_locks_held(struct task_struct *task)
                        printk("exiting task is not even the owner??\n");
                return;
        }
-       debug_spin_lock_restore(&debug_mutex_lock, flags);
+       debug_spin_unlock_restore(&debug_mutex_lock, flags);
 }
 
 /*
@@ -335,9 +334,10 @@ void mutex_debug_check_no_locks_held(struct task_struct *task)
  * is destroyed or reinitialized - this code checks whether there is
  * any held lock in the memory range of <from> to <to>:
  */
-void mutex_debug_check_no_locks_freed(const void *from, const void *to)
+void mutex_debug_check_no_locks_freed(const void *from, unsigned long len)
 {
        struct list_head *curr, *next;
+       const void *to = from + len;
        unsigned long flags;
        struct mutex *lock;
        void *lock_addr;
@@ -353,7 +353,7 @@ void mutex_debug_check_no_locks_freed(const void *from, const void *to)
                        continue;
                list_del_init(curr);
                DEBUG_OFF();
-               debug_spin_lock_restore(&debug_mutex_lock, flags);
+               debug_spin_unlock_restore(&debug_mutex_lock, flags);
 
                printk("BUG: %s/%d, active lock [%p(%p-%p)] freed!\n",
                        current->comm, current->pid, lock, from, to);
@@ -363,7 +363,7 @@ void mutex_debug_check_no_locks_freed(const void *from, const void *to)
                        printk("freeing task is not even the owner??\n");
                return;
        }
-       debug_spin_lock_restore(&debug_mutex_lock, flags);
+       debug_spin_unlock_restore(&debug_mutex_lock, flags);
 }
 
 /*
@@ -373,7 +373,7 @@ void debug_mutex_set_owner(struct mutex *lock,
                           struct thread_info *new_owner __IP_DECL__)
 {
        lock->owner = new_owner;
-       DEBUG_WARN_ON(!list_empty(&lock->held_list));
+       DEBUG_LOCKS_WARN_ON(!list_empty(&lock->held_list));
        if (debug_mutex_on) {
                list_add_tail(&lock->held_list, &debug_mutex_held_locks);
                lock->acquire_ip = ip;
@@ -382,29 +382,29 @@ void debug_mutex_set_owner(struct mutex *lock,
 
 void debug_mutex_init_waiter(struct mutex_waiter *waiter)
 {
-       memset(waiter, 0x11, sizeof(*waiter));
+       memset(waiter, MUTEX_DEBUG_INIT, sizeof(*waiter));
        waiter->magic = waiter;
        INIT_LIST_HEAD(&waiter->list);
 }
 
 void debug_mutex_wake_waiter(struct mutex *lock, struct mutex_waiter *waiter)
 {
-       SMP_DEBUG_WARN_ON(!spin_is_locked(&lock->wait_lock));
-       DEBUG_WARN_ON(list_empty(&lock->wait_list));
-       DEBUG_WARN_ON(waiter->magic != waiter);
-       DEBUG_WARN_ON(list_empty(&waiter->list));
+       SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
+       DEBUG_LOCKS_WARN_ON(list_empty(&lock->wait_list));
+       DEBUG_LOCKS_WARN_ON(waiter->magic != waiter);
+       DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
 }
 
 void debug_mutex_free_waiter(struct mutex_waiter *waiter)
 {
-       DEBUG_WARN_ON(!list_empty(&waiter->list));
-       memset(waiter, 0x22, sizeof(*waiter));
+       DEBUG_LOCKS_WARN_ON(!list_empty(&waiter->list));
+       memset(waiter, MUTEX_DEBUG_FREE, sizeof(*waiter));
 }
 
 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
                            struct thread_info *ti __IP_DECL__)
 {
-       SMP_DEBUG_WARN_ON(!spin_is_locked(&lock->wait_lock));
+       SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
        check_deadlock(lock, 0, ti, ip);
        /* Mark the current thread as blocked on the lock: */
        ti->task->blocked_on = waiter;
@@ -414,9 +414,9 @@ void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
                         struct thread_info *ti)
 {
-       DEBUG_WARN_ON(list_empty(&waiter->list));
-       DEBUG_WARN_ON(waiter->task != ti->task);
-       DEBUG_WARN_ON(ti->task->blocked_on != waiter);
+       DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
+       DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
+       DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
        ti->task->blocked_on = NULL;
 
        list_del_init(&waiter->list);
@@ -425,11 +425,11 @@ void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
 
 void debug_mutex_unlock(struct mutex *lock)
 {
-       DEBUG_WARN_ON(lock->magic != lock);
-       DEBUG_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
-       DEBUG_WARN_ON(lock->owner != current_thread_info());
+       DEBUG_LOCKS_WARN_ON(lock->magic != lock);
+       DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
+       DEBUG_LOCKS_WARN_ON(lock->owner != current_thread_info());
        if (debug_mutex_on) {
-               DEBUG_WARN_ON(list_empty(&lock->held_list));
+               DEBUG_LOCKS_WARN_ON(list_empty(&lock->held_list));
                list_del_init(&lock->held_list);
        }
 }
@@ -439,7 +439,7 @@ void debug_mutex_init(struct mutex *lock, const char *name)
        /*
         * Make sure we are not reinitializing a held lock:
         */
-       mutex_debug_check_no_locks_freed((void *)lock, (void *)(lock + 1));
+       mutex_debug_check_no_locks_freed((void *)lock, sizeof(*lock));
        lock->owner = NULL;
        INIT_LIST_HEAD(&lock->held_list);
        lock->name = name;
@@ -456,9 +456,8 @@ void debug_mutex_init(struct mutex *lock, const char *name)
  */
 void fastcall mutex_destroy(struct mutex *lock)
 {
-       DEBUG_WARN_ON(mutex_is_locked(lock));
+       DEBUG_LOCKS_WARN_ON(mutex_is_locked(lock));
        lock->magic = NULL;
 }
 
 EXPORT_SYMBOL_GPL(mutex_destroy);
-