]> err.no Git - linux-2.6/blobdiff - kernel/mutex-debug.c
Merge branch 'nommu' of master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6] / kernel / mutex-debug.c
index 3dec75363786b5a811908113138bef2ac3b32e74..e38e4bac97cac6dde3cacd552f189ef77882bb62 100644 (file)
@@ -16,6 +16,7 @@
 #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>
@@ -153,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");
 }
 
@@ -316,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);
@@ -325,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);
 }
 
 /*
@@ -333,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;
@@ -351,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);
@@ -361,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);
 }
 
 /*
@@ -380,7 +382,7 @@ 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);
 }
@@ -396,7 +398,7 @@ void debug_mutex_wake_waiter(struct mutex *lock, struct mutex_waiter *waiter)
 void debug_mutex_free_waiter(struct mutex_waiter *waiter)
 {
        DEBUG_WARN_ON(!list_empty(&waiter->list));
-       memset(waiter, 0x22, sizeof(*waiter));
+       memset(waiter, MUTEX_DEBUG_FREE, sizeof(*waiter));
 }
 
 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
@@ -437,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;
@@ -459,4 +461,3 @@ void fastcall mutex_destroy(struct mutex *lock)
 }
 
 EXPORT_SYMBOL_GPL(mutex_destroy);
-