Skip to content

Commit

Permalink
locking/ww_mutex: Fix ww_mutex dummy lockdep map selftest warnings
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
Thomas Hellström authored and Peter Zijlstra committed Dec 2, 2024
1 parent 40384c8 commit 0302d2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/linux/ww_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ static inline void ww_acquire_init(struct ww_acquire_ctx *ctx,
debug_check_no_locks_freed((void *)ctx, sizeof(*ctx));
lockdep_init_map(&ctx->dep_map, ww_class->acquire_name,
&ww_class->acquire_key, 0);
lockdep_init_map(&ctx->first_lock_dep_map, ww_class->mutex_name,
&ww_class->mutex_key, 0);
lockdep_init_map_wait(&ctx->first_lock_dep_map, ww_class->mutex_name,
&ww_class->mutex_key, 0, LD_WAIT_SLEEP);
mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_);
mutex_acquire_nest(&ctx->first_lock_dep_map, 0, 0, &ctx->dep_map, _RET_IP_);
#endif
Expand Down
4 changes: 2 additions & 2 deletions lib/locking-selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,8 +1720,6 @@ static void ww_test_normal(void)
{
int ret;

WWAI(&t);

/*
* None of the ww_mutex codepaths should be taken in the 'normal'
* mutex calls. The easiest way to verify this is by using the
Expand Down Expand Up @@ -1770,6 +1768,8 @@ static void ww_test_normal(void)
ww_mutex_base_unlock(&o.base);
WARN_ON(o.ctx != (void *)~0UL);

WWAI(&t);

/* nest_lock */
o.ctx = (void *)~0UL;
ww_mutex_base_lock_nest_lock(&o.base, &t);
Expand Down

0 comments on commit 0302d2f

Please sign in to comment.