Skip to contentSkip to conversation

locking/ww_mutex: Fix ww_mutex dummy lockdep map selftest warnings

PATCH Applied Thomas Hellström 3 participants 3 messages Nov 27, 2024 – Dec 2, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Will Deacon <[email protected]>
Cc Waiman Long <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Christian König <[email protected]>
Fixes 823a566221a5 ("locking/ww_mutex: Adjust to lockdep nest_lock requirements")
---
 include/linux/ww_mutex.h | 4 ++--
 lib/locking-selftest.c   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/ww_mutex.h +2 -2
index a401a2f31a77..45ff6f7a872b 100644
@@ -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
lib/locking-selftest.c +2 -2
index 6e0c019f71b6..ed99344317f5 100644
@@ -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
@@ -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);
Signature · 1 line
2.47.0
#1 lore raw

✗ CI.Patch_applied: failure for locking/ww_mutex: Fix ww_mutex dummy lockdep map selftest warnings

== Series Details ==

== Series Details ==

Series: locking/ww_mutex: Fix ww_mutex dummy lockdep map selftest warnings
URL : https://patchwork.freedesktop.org/series/141827/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 441e225c838a drm-tip: 2024y-11m-27d-08h-24m-28s UTC integration manifest === git am output follows ===
error: patch failed: include/linux/ww_mutex.h:156
error: include/linux/ww_mutex.h: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: locking/ww_mutex: Fix ww_mutex dummy lockdep map selftest warnings Patch failed at 0001 locking/ww_mutex: Fix ww_mutex dummy lockdep map selftest warnings When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

#2 lore raw
In reply to Thomas Hellström
The following commit has been merged into the locking/core branch of tip:

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     0302d2fd6efb0c386e521df0134eb2679a9a138f
Gitweb:        https://git.kernel.org/tip/0302d2fd6efb0c386e521df0134eb2679a9a138f
Author:        Thomas Hellström <[email protected]>
AuthorDate:    Wed, 27 Nov 2024 09:54:30 +01:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Mon, 02 Dec 2024 12:16:57 +01:00

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.

---
 include/linux/ww_mutex.h | 4 ++--
 lib/locking-selftest.c   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/ww_mutex.h +2 -2
index a401a2f..45ff6f7 100644
@@ -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
lib/locking-selftest.c +2 -2
index 6e0c019..ed99344 100644
@@ -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
@@ -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);