[PATCH 4/4] test-ww_mutex: Retry lock acquisition after timeout if deadlocked
From: Håkon Bugge
Date: Wed Jun 17 2026 - 08:15:43 EST
stress_inorder_work() terminates when its timeout expires. If the
final lock acquisition attempt returns -EDEADLK at that point, the
test may report a false failure even though the deadlock would have
been resolved shortly thereafter. Retry a limited number of times
after timeout before reporting failure.
Without this commit, we may see in the log:
Beginning ww (wound) mutex selftests
stress (stress_inorder_work) failed with -35
Fixes: cfa92b6d5207 ("locking/ww_mutex/test: Make sure we bail out instead of livelock")
Signed-off-by: Håkon Bugge <haakon.bugge@xxxxxxxxxx>
---
kernel/locking/test-ww_mutex.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 6b29a7a8f5fba..95de03179eac0 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -444,6 +444,7 @@ static void stress_inorder_work(struct work_struct *work)
struct ww_acquire_ctx ctx;
int *order;
int err;
+ int attempts_after_tmout = 10000;
stress->result = -ENOMEM;
@@ -476,7 +477,7 @@ static void stress_inorder_work(struct work_struct *work)
ww_mutex_unlock(&locks[order[n]]);
if (err == -EDEADLK) {
- if (!time_after(jiffies, stress->timeout)) {
+ if ((!time_after(jiffies, stress->timeout)) || attempts_after_tmout--) {
ww_mutex_lock_slow(&locks[order[contended]], &ctx);
goto retry;
}
--
2.43.5