Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking/ww_mutex: Fix ww_mutex dummy lockdep map selftest warnings

The below commit introduces a dummy lockdep map, but didn't get
the initialization quite right (it should mimic the initialization
of the real ww_mutex lockdep maps). It also introduced a separate
locking api selftest failure. Fix these.

Closes: https://lore.kernel.org/lkml/Zw19sMtnKdyOVQoh@boqun-archlinux/
Fixes: 823a566221a5 ("locking/ww_mutex: Adjust to lockdep nest_lock requirements")
Reported-by: Boqun Feng <boqun.feng@gmail.com>
Suggested-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20241127085430.3045-1-thomas.hellstrom@linux.intel.com

authored by

Thomas Hellström and committed by
Peter Zijlstra
0302d2fd 40384c84

+4 -4
+2 -2
include/linux/ww_mutex.h
··· 156 156 debug_check_no_locks_freed((void *)ctx, sizeof(*ctx)); 157 157 lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, 158 158 &ww_class->acquire_key, 0); 159 - lockdep_init_map(&ctx->first_lock_dep_map, ww_class->mutex_name, 160 - &ww_class->mutex_key, 0); 159 + lockdep_init_map_wait(&ctx->first_lock_dep_map, ww_class->mutex_name, 160 + &ww_class->mutex_key, 0, LD_WAIT_SLEEP); 161 161 mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); 162 162 mutex_acquire_nest(&ctx->first_lock_dep_map, 0, 0, &ctx->dep_map, _RET_IP_); 163 163 #endif
+2 -2
lib/locking-selftest.c
··· 1720 1720 { 1721 1721 int ret; 1722 1722 1723 - WWAI(&t); 1724 - 1725 1723 /* 1726 1724 * None of the ww_mutex codepaths should be taken in the 'normal' 1727 1725 * mutex calls. The easiest way to verify this is by using the ··· 1767 1769 WARN_ON(ret); 1768 1770 ww_mutex_base_unlock(&o.base); 1769 1771 WARN_ON(o.ctx != (void *)~0UL); 1772 + 1773 + WWAI(&t); 1770 1774 1771 1775 /* nest_lock */ 1772 1776 o.ctx = (void *)~0UL;