diff -urN oldtree/include/linux/init_task.h newtree/include/linux/init_task.h --- oldtree/include/linux/init_task.h 2006-09-26 14:32:04.000000000 -0400 +++ newtree/include/linux/init_task.h 2006-09-26 15:06:32.000000000 -0400 @@ -189,6 +189,7 @@ .signal = {{0}}}, \ .blocked = {{0}}, \ .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ + .mutexes_held = 0, \ .journal_info = NULL, \ .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ .fs_excl = ATOMIC_INIT(0), \ diff -urN oldtree/include/linux/sched.h newtree/include/linux/sched.h --- oldtree/include/linux/sched.h 2006-09-26 14:34:25.000000000 -0400 +++ newtree/include/linux/sched.h 2006-09-26 15:06:32.000000000 -0400 @@ -1041,6 +1041,7 @@ struct held_lock held_locks[MAX_LOCK_DEPTH]; unsigned int lockdep_recursion; #endif + unsigned long mutexes_held; /* journalling filesystem info */ void *journal_info; diff -urN oldtree/kernel/fork.c newtree/kernel/fork.c --- oldtree/kernel/fork.c 2006-09-24 17:03:56.000000000 -0400 +++ newtree/kernel/fork.c 2006-09-26 15:06:32.000000000 -0400 @@ -1053,6 +1053,7 @@ p->io_context = NULL; p->io_wait = NULL; p->audit_context = NULL; + p->mutexes_held = 0; cpuset_fork(p); #ifdef CONFIG_NUMA p->mempolicy = mpol_copy(p->mempolicy); diff -urN oldtree/kernel/mutex.c newtree/kernel/mutex.c --- oldtree/kernel/mutex.c 2006-09-24 17:03:56.000000000 -0400 +++ newtree/kernel/mutex.c 2006-09-26 15:06:32.000000000 -0400 @@ -60,6 +60,16 @@ static void fastcall noinline __sched __mutex_lock_slowpath(atomic_t *lock_count); +static inline void inc_mutex_count(void) +{ + current->mutexes_held++; +} + +static inline void dec_mutex_count(void) +{ + current->mutexes_held--; +} + /*** * mutex_lock - acquire the mutex * @lock: the mutex to be acquired @@ -89,6 +99,7 @@ * 'unlocked' into 'locked' state. */ __mutex_fastpath_lock(&lock->count, __mutex_lock_slowpath); + inc_mutex_count(); } EXPORT_SYMBOL(mutex_lock); @@ -114,6 +125,7 @@ * into 'unlocked' state: */ __mutex_fastpath_unlock(&lock->count, __mutex_unlock_slowpath); + dec_mutex_count(); } EXPORT_SYMBOL(mutex_unlock); @@ -274,9 +286,14 @@ */ int fastcall __sched mutex_lock_interruptible(struct mutex *lock) { + int ret; + might_sleep(); - return __mutex_fastpath_lock_retval + ret = __mutex_fastpath_lock_retval (&lock->count, __mutex_lock_interruptible_slowpath); + if (likely(!ret)) + inc_mutex_count(); + return ret; } EXPORT_SYMBOL(mutex_lock_interruptible); @@ -331,8 +348,12 @@ */ int fastcall __sched mutex_trylock(struct mutex *lock) { - return __mutex_fastpath_trylock(&lock->count, + int ret = __mutex_fastpath_trylock(&lock->count, __mutex_trylock_slowpath); + + if (likely(ret)) + inc_mutex_count(); + return ret; } EXPORT_SYMBOL(mutex_trylock); Files oldtree/scripts/kconfig/mconf and newtree/scripts/kconfig/mconf differ