]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] mutex subsystem, more debugging code
authorIngo Molnar <mingo@elte.hu>
Mon, 9 Jan 2006 23:59:21 +0000 (15:59 -0800)
committerIngo Molnar <mingo@hera.kernel.org>
Mon, 9 Jan 2006 23:59:21 +0000 (15:59 -0800)
more mutex debugging: check for held locks during memory freeing,
task exit, enable sysrq printouts, etc.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
arch/i386/mm/pageattr.c
drivers/char/sysrq.c
include/linux/mm.h
kernel/exit.c
kernel/sched.c
mm/page_alloc.c
mm/slab.c

index c30a16df6440d7c82af7df6c434295e07204cc54..e8a53552b13df147753efed1084b8a96744d667f 100644 (file)
@@ -222,6 +222,10 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
 {
        if (PageHighMem(page))
                return;
+       if (!enable)
+               mutex_debug_check_no_locks_freed(page_address(page),
+                                                page_address(page+numpages));
+
        /* the return value is ignored - the calls cannot fail,
         * large pages are disabled at boot time.
         */
index 145275ebdd7ee2d6b0a43062838baa6e82ba8ea3..5765f672e853b5c7a0c50232f96970cf336f4789 100644 (file)
@@ -153,6 +153,21 @@ static struct sysrq_key_op sysrq_mountro_op = {
 
 /* END SYNC SYSRQ HANDLERS BLOCK */
 
+#ifdef CONFIG_DEBUG_MUTEXES
+
+static void
+sysrq_handle_showlocks(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
+{
+       mutex_debug_show_all_locks();
+}
+
+static struct sysrq_key_op sysrq_showlocks_op = {
+       .handler        = sysrq_handle_showlocks,
+       .help_msg       = "show-all-locks(D)",
+       .action_msg     = "Show Locks Held",
+};
+
+#endif
 
 /* SHOW SYSRQ HANDLERS BLOCK */
 
@@ -294,7 +309,11 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
 #else
 /* c */        NULL,
 #endif
+#ifdef CONFIG_DEBUG_MUTEXES
+/* d */ &sysrq_showlocks_op,
+#else
 /* d */ NULL,
+#endif
 /* e */        &sysrq_term_op,
 /* f */        &sysrq_moom_op,
 /* g */        NULL,
index df80e63903b570b4ee79c7b8862e14284037870d..3f1fafc0245e7eebf0ee45334d3c7c3ff77f4a89 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/rbtree.h>
 #include <linux/prio_tree.h>
 #include <linux/fs.h>
+#include <linux/mutex.h>
 
 struct mempolicy;
 struct anon_vma;
@@ -1024,6 +1025,9 @@ static inline void vm_stat_account(struct mm_struct *mm,
 static inline void
 kernel_map_pages(struct page *page, int numpages, int enable)
 {
+       if (!PageHighMem(page) && !enable)
+               mutex_debug_check_no_locks_freed(page_address(page),
+                                                page_address(page + numpages));
 }
 #endif
 
index caceabf3f2305a0b1c6679b72c9abbf74528dfa7..309a46fa16f8e7b76af222e61336ee49ea4acb78 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/syscalls.h>
 #include <linux/signal.h>
 #include <linux/cn_proc.h>
+#include <linux/mutex.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -869,6 +870,10 @@ fastcall NORET_TYPE void do_exit(long code)
        mpol_free(tsk->mempolicy);
        tsk->mempolicy = NULL;
 #endif
+       /*
+        * If DEBUG_MUTEXES is on, make sure we are holding no locks:
+        */
+       mutex_debug_check_no_locks_held(tsk);
 
        /* PF_DEAD causes final put_task_struct after we schedule. */
        preempt_disable();
index 92733091154c48e0502732deac9fa2905b3b3a31..34a945bcc022a6767ae2ed4adbcd5d56716db98b 100644 (file)
@@ -4386,6 +4386,7 @@ void show_state(void)
        } while_each_thread(g, p);
 
        read_unlock(&tasklist_lock);
+       mutex_debug_show_all_locks();
 }
 
 /**
index e0e84924171b4f28fc0c9c054d5668f4a7036916..a5e6891f7bb6f366025e56dd701f9794d29ce67d 100644 (file)
@@ -415,6 +415,9 @@ static void __free_pages_ok(struct page *page, unsigned int order)
        int reserved = 0;
 
        arch_free_page(page, order);
+       if (!PageHighMem(page))
+               mutex_debug_check_no_locks_freed(page_address(page),
+                       page_address(page+(1<<order)));
 
 #ifndef CONFIG_MMU
        for (i = 1 ; i < (1 << order) ; ++i)
index 1c46c6383552ffa82921934bb6ce05715dd0fd88..33aab345cd4a0fddbd0c20b5763cfe9aae194162 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3071,6 +3071,7 @@ void kfree(const void *objp)
        local_irq_save(flags);
        kfree_debugcheck(objp);
        c = page_get_cache(virt_to_page(objp));
+       mutex_debug_check_no_locks_freed(objp, objp+obj_reallen(c));
        __cache_free(c, (void *)objp);
        local_irq_restore(flags);
 }