• Guenter Roeck's avatar
    locking/ww_mutex: Fix runtime warning in the WW mutex selftest · e4a02ed2
    Guenter Roeck authored
    If CONFIG_WW_MUTEX_SELFTEST=y is enabled, booting an image
    in an arm64 virtual machine results in the following
    traceback if 8 CPUs are enabled:
      DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current)
      WARNING: CPU: 2 PID: 537 at kernel/locking/mutex.c:1033 __mutex_unlock_slowpath+0x1a8/0x2e0
      Call trace:
    If requesting b_mutex fails with -EDEADLK, the error variable
    is reassigned to the return value from calling ww_mutex_lock
    on a_mutex again. If this call fails, a_mutex is not locked.
    It is, however, unconditionally unlocked subsequently, causing
    the reported warning. Fix the problem by using two error variables.
    With this change, the selftest still fails as follows:
      cyclic deadlock not resolved, ret[7/8] = -35
    However, the traceback is gone.
    Signed-off-by: default avatarGuenter Roeck <[email protected]>
    Cc: Chris Wilson <[email protected]>
    Cc: Linus Torvalds <[email protected]>
    Cc: Peter Zijlstra <[email protected]>
    Cc: Thomas Gleixner <[email protected]>
    Cc: Will Deacon <[email protected]>
    Fixes: d1b42b80 ("locking/ww_mutex: Add kselftests for resolving ww_mutex cyclic deadlocks")
    Link: http://lkml.kernel.org/r/[email protected]Signed-off-by: default avatarIngo Molnar <[email protected]>
test-ww_mutex.c 12.9 KB