Skip to content

Commit 0302d2f

Browse files
Thomas HellströmPeter Zijlstra
authored andcommitted
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: 823a566 ("locking/ww_mutex: Adjust to lockdep nest_lock requirements") Reported-by: Boqun Feng <[email protected]> Suggested-by: Boqun Feng <[email protected]> Signed-off-by: Thomas Hellström <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 40384c8 commit 0302d2f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/linux/ww_mutex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ static inline void ww_acquire_init(struct ww_acquire_ctx *ctx,
156156
debug_check_no_locks_freed((void *)ctx, sizeof(*ctx));
157157
lockdep_init_map(&ctx->dep_map, ww_class->acquire_name,
158158
&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);
161161
mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_);
162162
mutex_acquire_nest(&ctx->first_lock_dep_map, 0, 0, &ctx->dep_map, _RET_IP_);
163163
#endif

lib/locking-selftest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,8 +1720,6 @@ static void ww_test_normal(void)
17201720
{
17211721
int ret;
17221722

1723-
WWAI(&t);
1724-
17251723
/*
17261724
* None of the ww_mutex codepaths should be taken in the 'normal'
17271725
* mutex calls. The easiest way to verify this is by using the
@@ -1770,6 +1768,8 @@ static void ww_test_normal(void)
17701768
ww_mutex_base_unlock(&o.base);
17711769
WARN_ON(o.ctx != (void *)~0UL);
17721770

1771+
WWAI(&t);
1772+
17731773
/* nest_lock */
17741774
o.ctx = (void *)~0UL;
17751775
ww_mutex_base_lock_nest_lock(&o.base, &t);

0 commit comments

Comments
 (0)