• john stultz's avatar
    rtmutex: Fix CONFIG_DEBUG_RT_MUTEX lock underflow warnings · 2c237cf3
    john stultz authored
    So if I enable CONFIG_DEBUG_RT_MUTEXES with 2.6.24.7-rt14, I tend to
    quickly see a number of BUG warnings when running Java tests:
    
    BUG: jxeinajar/3383: lock count underflow!
    Pid: 3383, comm: jxeinajar Not tainted 2.6.24-ibmrt2.5john #3
    
    Call Trace:
     [<ffffffff8107208d>] rt_mutex_deadlock_account_unlock+0x5d/0x70
     [<ffffffff817d6aa5>] rt_read_slowunlock+0x35/0x550
     [<ffffffff8107173d>] rt_mutex_up_read+0x3d/0xc0
     [<ffffffff81072a99>] rt_up_read+0x29/0x30
     [<ffffffff8106e34e>] do_futex+0x32e/0xd40
     [<ffffffff8107173d>] ? rt_mutex_up_read+0x3d/0xc0
     [<ffffffff81072a99>] ? rt_up_read+0x29/0x30
     [<ffffffff8106f370>] compat_sys_futex+0xa0/0x110
     [<ffffffff81010a36>] ? syscall_trace_enter+0x86/0xb0
     [<ffffffff8102ff04>] cstar_do_call+0x1b/0x65
    
    INFO: lockdep is turned off.
    ---------------------------
    | preempt count: 00000001 ]
    | 1-level deep critical section nesting:
    ----------------------------------------
    ... [<ffffffff817d8e42>] .... __spin_lock_irqsave+0x22/0x60
    ......[<ffffffff817d6a93>] ..   ( <= rt_read_slowunlock+0x23/0x550)
    
    After some debugging and with Steven's help, we realized that with
    rwlocks, rt_mutex_deadlock_account_lock can be called multiple times in
    parallel (where as in most cases the mutex must be held by the caller to
    to call the function). This can cause integer lock_count value being
    used to be non-atomically incremented.
    
    The following patch converts lock_count to a atomic_t and resolves the
    warnings.
    Signed-off-by: default avatarJohn Stultz <johnstul@us.ibm.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: dvhltc <dvhltc@linux.vnet.ibm.com>
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    2c237cf3
rtmutex-debug.c 5.35 KB