From: Ingo Molnar With the lock validator we detect mutex deadlocks (and more), the mutex deadlock checking code is both redundant and slower. So remove it. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton --- kernel/mutex-debug.c | 126 ----------------------------------------- lib/Kconfig.debug | 8 -- 2 files changed, 1 insertion(+), 133 deletions(-) diff -puN kernel/mutex-debug.c~better-lock-debugging-remove-mutex-deadlock-checking-code kernel/mutex-debug.c --- devel/kernel/mutex-debug.c~better-lock-debugging-remove-mutex-deadlock-checking-code 2006-06-09 15:23:06.000000000 -0700 +++ devel-akpm/kernel/mutex-debug.c 2006-06-09 15:23:06.000000000 -0700 @@ -24,128 +24,6 @@ #include "mutex-debug.h" -static void printk_task(struct task_struct *p) -{ - if (p) - printk("%16s:%5d [%p, %3d]", p->comm, p->pid, p, p->prio); - else - printk(""); -} - -static void printk_ti(struct thread_info *ti) -{ - if (ti) - printk_task(ti->task); - else - printk(""); -} - -static void printk_lock(struct mutex *lock, int print_owner) -{ -#ifdef CONFIG_PROVE_MUTEX_LOCKING - printk(" [%p] {%s}\n", lock, lock->dep_map.name); -#else - printk(" [%p]\n", lock); -#endif - - if (print_owner && lock->owner) { - printk(".. held by: "); - printk_ti(lock->owner); - printk("\n"); - } -} - -static void report_deadlock(struct task_struct *task, struct mutex *lock, - struct mutex *lockblk) -{ - printk("\n%s/%d is trying to acquire this lock:\n", - current->comm, current->pid); - printk_lock(lock, 1); - debug_show_held_locks(current); - - if (lockblk) { - printk("but %s/%d is deadlocking current task %s/%d!\n\n", - task->comm, task->pid, current->comm, current->pid); - printk("\n%s/%d is blocked on this lock:\n", - task->comm, task->pid); - printk_lock(lockblk, 1); - - debug_show_held_locks(task); - - printk("\n%s/%d's [blocked] stackdump:\n\n", - task->comm, task->pid); - show_stack(task, NULL); - } - - printk("\n%s/%d's [current] stackdump:\n\n", - current->comm, current->pid); - dump_stack(); - debug_show_all_locks(); - printk("[ turning off deadlock detection. Please report this. ]\n\n"); - local_irq_disable(); -} - -/* - * Recursively check for mutex deadlocks: - */ -static int check_deadlock(struct mutex *lock, int depth, struct thread_info *ti) -{ - struct mutex *lockblk; - struct task_struct *task; - - if (!debug_locks) - return 0; - - ti = lock->owner; - if (!ti) - return 0; - - task = ti->task; - /* - * In the PROVE_MUTEX_LOCKING we are tracking all held - * locks already, which allows us to optimize this: - */ -#ifdef CONFIG_PROVE_MUTEX_LOCKING - if (!task->lockdep_depth) - return 0; -#endif - lockblk = NULL; - if (task->blocked_on) - lockblk = task->blocked_on->lock; - - /* Self-deadlock: */ - if (current == task) { - debug_locks_off(); - if (depth) - return 1; - printk("\n==========================================\n"); - printk( "[ BUG: lock recursion deadlock detected! |\n"); - printk( "------------------------------------------\n"); - report_deadlock(task, lock, NULL); - return 0; - } - - /* Ugh, something corrupted the lock data structure? */ - if (depth > 20) { - debug_locks_off(); - printk("\n===========================================\n"); - printk( "[ BUG: infinite lock dependency detected!? |\n"); - printk( "-------------------------------------------\n"); - report_deadlock(task, lock, lockblk); - return 0; - } - - /* Recursively check for dependencies: */ - if (lockblk && check_deadlock(lockblk, depth+1, ti)) { - printk("\n============================================\n"); - printk( "[ BUG: circular locking deadlock detected! ]\n"); - printk( "--------------------------------------------\n"); - report_deadlock(task, lock, lockblk); - return 0; - } - return 0; -} - /* * Must be called with lock->wait_lock held. */ @@ -179,9 +57,7 @@ void debug_mutex_add_waiter(struct mutex struct thread_info *ti) { SMP_DEBUG_WARN_ON(!spin_is_locked(&lock->wait_lock)); -#ifdef CONFIG_DEBUG_MUTEX_DEADLOCKS - check_deadlock(lock, 0, ti); -#endif + /* Mark the current thread as blocked on the lock: */ ti->task->blocked_on = waiter; waiter->lock = lock; diff -puN lib/Kconfig.debug~better-lock-debugging-remove-mutex-deadlock-checking-code lib/Kconfig.debug --- devel/lib/Kconfig.debug~better-lock-debugging-remove-mutex-deadlock-checking-code 2006-06-09 15:23:06.000000000 -0700 +++ devel-akpm/lib/Kconfig.debug 2006-06-09 15:23:06.000000000 -0700 @@ -133,14 +133,6 @@ config DEBUG_MUTEX_ALLOC (kfree(), kmem_cache_free(), free_pages(), vfree(), etc.), or whether there is any lock held during task exit. -config DEBUG_MUTEX_DEADLOCKS - bool "Detect mutex related deadlocks" - default y - depends on DEBUG_MUTEXES - help - This feature will automatically detect and report mutex related - deadlocks, as they happen. - config DEBUG_RT_MUTEXES bool "RT Mutex debugging, deadlock detection" depends on DEBUG_KERNEL && RT_MUTEXES _