Skip to contentSkip to conversation

Regression on linux-next (next-20260324 )

DISCUSSION Borah, Chaitanya Kumar 7 participants 28 messages Mar 27 – Apr 22 Locking primitives

lore
Share & tools
lore
#0 lore raw

Hello Matthew,

Hope you are doing well. I am Chaitanya from the linux graphics team in Intel.

This mail is regarding a regression we are seeing in our CI runs[1] on linux-next repository.

Since the version next-20260324 [2], we are seeing the following regression

`````````````````````````````````````````````````````````````````````````````````
<5>[  157.361977] [IGT] Inactivity timeout exceeded. Killing the current test with SIGQUIT.
<6>[  157.362097] sysrq: HELP : loglevel(0-9) reboot(b) crash(c) show-all-locks(d) terminate-all-tasks(e) memory-full-oom-kill(f) kill-all-tasks(i) thaw-filesystems(j) sak(k) show-backtrace-all-active-cpus(l) show-memory-usage(m) nice-all-RT-tasks(n) poweroff(o) show-registers(p) show-all-timers(q) unraw(r) sync(s) show-task-states(t) unmount(u) force-fb(v) show-blocked-tasks(w) dump-ftrace-buffer(z) replay-kernel-logs(R)
<6>[  157.399543] sysrq: Show State
<6>[  157.403061] task:systemd         state:S stack:0     pid:1 tgid:1     ppid:0      task_flags:0x400100 flags:0x00080000
<6>[  157.403067] Call Trace:
<6>[  157.403069]  <TASK>
<6>[  157.403072]  __schedule+0x5d7/0x1ef0
<6>[  157.403078]  ? lock_acquire+0xc4/0x300
<6>[  157.403084]  ? schedule+0x10e/0x180
<6>[  157.403087]  ? lock_release+0xcd/0x2b0
<6>[  157.403092]  schedule+0x3a/0x180
<6>[  157.403094]  schedule_hrtimeout_range_clock+0x112/0x120
<6>[  157.403097]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403102]  ? lock_release+0xcd/0x2b0
<6>[  157.403104]  ? _raw_spin_unlock_irq+0x27/0x70
<6>[  157.403106]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403110]  schedule_hrtimeout_range+0x13/0x30
`````````````````````````````````````````````````````````````````````````````````

Details log can be found in [3].

After bisecting the tree, the following patch [4] seems to be the first "bad" commit

`````````````````````````````````````````````````````````````````````````````````````````````````````````
commit 25500ba7e77ce9d3d9b5a1929d41a2ee2e23f6fe
Author: Matthew Wilcox (Oracle) [email protected]
Date:   Thu Mar 5 19:55:43 2026 +0000

    locking/mutex: Remove the list_head from struct mutex
`````````````````````````````````````````````````````````````````````````````````````````````````````````

We could not revert the patch because of merge conflict but resetting to the parent of the commit seems to fix the issue.

Could you please check why the patch causes this regression and provide a fix if necessary?

Thank you.

Regards

Chaitanya

[1]
https://intel-gfx-ci.01.org/tree/linux-next/combined-alt.html?
[2] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20260324
[3]
https://intel-gfx-ci.01.org/tree/linux-next/next-20260326/bat-arlh-2/dmesg0.txt
[4] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20231130&id=f4acfcd4deb158b96595250cc332901b282d15b0

maintainer
#1 lore raw
Quoted 50 lines · Chaitanya Kumar

Hello Matthew,

Hope you are doing well. I am Chaitanya from the linux graphics team in Intel.

This mail is regarding a regression we are seeing in our CI runs[1] on linux-next repository.

Since the version next-20260324 [2], we are seeing the following regression

`````````````````````````````````````````````````````````````````````````````````
<5>[  157.361977] [IGT] Inactivity timeout exceeded. Killing the current
test with SIGQUIT.
<6>[  157.362097] sysrq: HELP : loglevel(0-9) reboot(b) crash(c)
show-all-locks(d) terminate-all-tasks(e) memory-full-oom-kill(f)
kill-all-tasks(i) thaw-filesystems(j) sak(k)
show-backtrace-all-active-cpus(l) show-memory-usage(m) nice-all-RT-tasks(n)
poweroff(o) show-registers(p) show-all-timers(q) unraw(r) sync(s)
show-task-states(t) unmount(u) force-fb(v) show-blocked-tasks(w)
dump-ftrace-buffer(z) replay-kernel-logs(R)
<6>[  157.399543] sysrq: Show State
<6>[  157.403061] task:systemd         state:S stack:0     pid:1 tgid:1
ppid:0      task_flags:0x400100 flags:0x00080000
<6>[  157.403067] Call Trace:
<6>[  157.403069]  <TASK>
<6>[  157.403072]  __schedule+0x5d7/0x1ef0
<6>[  157.403078]  ? lock_acquire+0xc4/0x300
<6>[  157.403084]  ? schedule+0x10e/0x180
<6>[  157.403087]  ? lock_release+0xcd/0x2b0
<6>[  157.403092]  schedule+0x3a/0x180
<6>[  157.403094]  schedule_hrtimeout_range_clock+0x112/0x120
<6>[  157.403097]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403102]  ? lock_release+0xcd/0x2b0
<6>[  157.403104]  ? _raw_spin_unlock_irq+0x27/0x70
<6>[  157.403106]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403110]  schedule_hrtimeout_range+0x13/0x30
`````````````````````````````````````````````````````````````````````````````````

Details log can be found in [3].

After bisecting the tree, the following patch [4] seems to be the first "bad" commit

`````````````````````````````````````````````````````````````````````````````````````````````````````````
commit 25500ba7e77ce9d3d9b5a1929d41a2ee2e23f6fe
Author: Matthew Wilcox (Oracle) [email protected]
Date:   Thu Mar 5 19:55:43 2026 +0000

    locking/mutex: Remove the list_head from struct mutex
`````````````````````````````````````````````````````````````````````````````````````````````````````````
Quoted 5 lines

We could not revert the patch because of merge conflict but resetting to the parent of the commit seems to fix the issue.

Could you please check why the patch causes this regression and provide a fix if necessary?

Does this help?

---

kernel/locking/ww_mutex.h +3 -3
@@ -40,10 +40,10 @@ __ww_waiter_last(struct mutex *lock)
 	__must_hold(&lock->wait_lock)
 {
 	struct mutex_waiter *w = lock->first_waiter;
+	if (!w)
+		return NULL;
 
-	if (w)
-		w = list_prev_entry(w, list);
-	return w;
+	return __ww_waiter_prev(lock, w);
 }
 
 static inline void
maintainer
#2 lore raw
Quoted 51 lines · Peter Zijlstra
Quoted 50 lines · Chaitanya Kumar

Hello Matthew,

Hope you are doing well. I am Chaitanya from the linux graphics team in Intel.

This mail is regarding a regression we are seeing in our CI runs[1] on linux-next repository.

Since the version next-20260324 [2], we are seeing the following regression

`````````````````````````````````````````````````````````````````````````````````
<5>[  157.361977] [IGT] Inactivity timeout exceeded. Killing the current
test with SIGQUIT.
<6>[  157.362097] sysrq: HELP : loglevel(0-9) reboot(b) crash(c)
show-all-locks(d) terminate-all-tasks(e) memory-full-oom-kill(f)
kill-all-tasks(i) thaw-filesystems(j) sak(k)
show-backtrace-all-active-cpus(l) show-memory-usage(m) nice-all-RT-tasks(n)
poweroff(o) show-registers(p) show-all-timers(q) unraw(r) sync(s)
show-task-states(t) unmount(u) force-fb(v) show-blocked-tasks(w)
dump-ftrace-buffer(z) replay-kernel-logs(R)
<6>[  157.399543] sysrq: Show State
<6>[  157.403061] task:systemd         state:S stack:0     pid:1 tgid:1
ppid:0      task_flags:0x400100 flags:0x00080000
<6>[  157.403067] Call Trace:
<6>[  157.403069]  <TASK>
<6>[  157.403072]  __schedule+0x5d7/0x1ef0
<6>[  157.403078]  ? lock_acquire+0xc4/0x300
<6>[  157.403084]  ? schedule+0x10e/0x180
<6>[  157.403087]  ? lock_release+0xcd/0x2b0
<6>[  157.403092]  schedule+0x3a/0x180
<6>[  157.403094]  schedule_hrtimeout_range_clock+0x112/0x120
<6>[  157.403097]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403102]  ? lock_release+0xcd/0x2b0
<6>[  157.403104]  ? _raw_spin_unlock_irq+0x27/0x70
<6>[  157.403106]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403110]  schedule_hrtimeout_range+0x13/0x30
`````````````````````````````````````````````````````````````````````````````````

Details log can be found in [3].

After bisecting the tree, the following patch [4] seems to be the first "bad" commit

`````````````````````````````````````````````````````````````````````````````````````````````````````````
commit 25500ba7e77ce9d3d9b5a1929d41a2ee2e23f6fe
Author: Matthew Wilcox (Oracle) [email protected]
Date:   Thu Mar 5 19:55:43 2026 +0000

    locking/mutex: Remove the list_head from struct mutex
`````````````````````````````````````````````````````````````````````````````````````````````````````````
Quoted 7 lines
Quoted 5 lines

We could not revert the patch because of merge conflict but resetting to the parent of the commit seems to fix the issue.

Could you please check why the patch causes this regression and provide a fix if necessary?

Does this help?

More tidy version of the same...

---

kernel/locking/ww_mutex.h +1 -1
index b1834ab7e782..bb8b410779d4 100644
@@ -42,7 +42,7 @@ __ww_waiter_last(struct mutex *lock)
 	struct mutex_waiter *w = lock->first_waiter;
 
 	if (w)
-		w = list_prev_entry(w, list);
+		w = __ww_waiter_prev(lock, w);
 	return w;
 }
 
#3 lore raw
Quoted 68 lines · Peter Zijlstra
Quoted 51 lines · Peter Zijlstra
Quoted 50 lines · Chaitanya Kumar

Hello Matthew,

Hope you are doing well. I am Chaitanya from the linux graphics team in Intel.

This mail is regarding a regression we are seeing in our CI runs[1] on linux-next repository.

Since the version next-20260324 [2], we are seeing the following regression

`````````````````````````````````````````````````````````````````````````````````
<5>[  157.361977] [IGT] Inactivity timeout exceeded. Killing the current
test with SIGQUIT.
<6>[  157.362097] sysrq: HELP : loglevel(0-9) reboot(b) crash(c)
show-all-locks(d) terminate-all-tasks(e) memory-full-oom-kill(f)
kill-all-tasks(i) thaw-filesystems(j) sak(k)
show-backtrace-all-active-cpus(l) show-memory-usage(m) nice-all-RT-tasks(n)
poweroff(o) show-registers(p) show-all-timers(q) unraw(r) sync(s)
show-task-states(t) unmount(u) force-fb(v) show-blocked-tasks(w)
dump-ftrace-buffer(z) replay-kernel-logs(R)
<6>[  157.399543] sysrq: Show State
<6>[  157.403061] task:systemd         state:S stack:0     pid:1 tgid:1
ppid:0      task_flags:0x400100 flags:0x00080000
<6>[  157.403067] Call Trace:
<6>[  157.403069]  <TASK>
<6>[  157.403072]  __schedule+0x5d7/0x1ef0
<6>[  157.403078]  ? lock_acquire+0xc4/0x300
<6>[  157.403084]  ? schedule+0x10e/0x180
<6>[  157.403087]  ? lock_release+0xcd/0x2b0
<6>[  157.403092]  schedule+0x3a/0x180
<6>[  157.403094]  schedule_hrtimeout_range_clock+0x112/0x120
<6>[  157.403097]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403102]  ? lock_release+0xcd/0x2b0
<6>[  157.403104]  ? _raw_spin_unlock_irq+0x27/0x70
<6>[  157.403106]  ? do_epoll_wait+0x3e4/0x5b0
<6>[  157.403110]  schedule_hrtimeout_range+0x13/0x30
`````````````````````````````````````````````````````````````````````````````````

Details log can be found in [3].

After bisecting the tree, the following patch [4] seems to be the first "bad" commit

`````````````````````````````````````````````````````````````````````````````````````````````````````````
commit 25500ba7e77ce9d3d9b5a1929d41a2ee2e23f6fe
Author: Matthew Wilcox (Oracle) [email protected]
Date:   Thu Mar 5 19:55:43 2026 +0000

     locking/mutex: Remove the list_head from struct mutex
`````````````````````````````````````````````````````````````````````````````````````````````````````````
Quoted 7 lines
Quoted 5 lines

We could not revert the patch because of merge conflict but resetting to the parent of the commit seems to fix the issue.

Could you please check why the patch causes this regression and provide a fix if necessary?

Does this help?

More tidy version of the same...

---

kernel/locking/ww_mutex.h +0 -0
index b1834ab7e782..bb8b410779d4 100644

kernel/locking/ww_mutex.h __ww_waiter_last(struct mutex *lock) · line 48

Quoted 8 lines
kernel/locking/ww_mutex.h +1 -1
@@ -42,7 +42,7 @@ __ww_waiter_last(struct mutex *lock)
  	struct mutex_waiter *w = lock->first_waiter;
 
  	if (w)
-		w = list_prev_entry(w, list);
+		w = __ww_waiter_prev(lock, w);
  	return w;
  }
 

Thank you for the response, Peter. Unfortunately, the issue is still seen with this change.

Regards
Chaitanya

maintainer
#4 lore raw
Quoted 5 lines · Chaitanya Kumar
Quoted 5 lines
kernel/locking/ww_mutex.h +0 -0
index b1834ab7e782..bb8b410779d4 100644
@@ -42,7 +42,7 @@ __ww_waiter_last(struct mutex *lock)
Quoted 8 lines

kernel/locking/ww_mutex.h __ww_waiter_last(struct mutex *lock) · line 47

Quoted 6 lines
kernel/locking/ww_mutex.h +1 -1
  	struct mutex_waiter *w = lock->first_waiter;
  	if (w)
-		w = list_prev_entry(w, list);
+		w = __ww_waiter_prev(lock, w);
  	return w;
  }

Thank you for the response, Peter. Unfortunately, the issue is still seen with this change.

Bah, indeed. Looking at this after the weekend I see that it's actually wrong.

But I haven't yet had a new idea. I don't suppose there is a relatively easy way to reproduce this issue outside of your CI robot?

My current working thesis is that since this is graphics, this is ww_mutex related. I'll go over this code once more...

maintainer
#5 lore raw
Quoted 15 lines · Peter Zijlstra
Quoted 5 lines · Chaitanya Kumar
Quoted 5 lines
kernel/locking/ww_mutex.h +0 -0
index b1834ab7e782..bb8b410779d4 100644
@@ -42,7 +42,7 @@ __ww_waiter_last(struct mutex *lock)
Quoted 8 lines

kernel/locking/ww_mutex.h __ww_waiter_last(struct mutex *lock) · line 46

Quoted 6 lines
kernel/locking/ww_mutex.h +1 -1
  	struct mutex_waiter *w = lock->first_waiter;
  	if (w)
-		w = list_prev_entry(w, list);
+		w = __ww_waiter_prev(lock, w);
  	return w;
  }

Thank you for the response, Peter. Unfortunately, the issue is still seen with this change.

Quoted 8 lines

Bah, indeed. Looking at this after the weekend I see that it's actually wrong.

But I haven't yet had a new idea. I don't suppose there is a relatively easy way to reproduce this issue outside of your CI robot?

My current working thesis is that since this is graphics, this is ww_mutex related. I'll go over this code once more...

Since you've not provided a reproducer, can I ask you to try the below?

---

kernel/locking/mutex.c +2 -4
index 186b463fe326..a93e57fc53b1 100644
@@ -229,10 +229,8 @@ __mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter)
 		__mutex_clear_flag(lock, MUTEX_FLAGS);
 		lock->first_waiter = NULL;
 	} else {
-		if (lock->first_waiter == waiter) {
-			lock->first_waiter = list_first_entry(&waiter->list,
-							      struct mutex_waiter, list);
-		}
+		if (lock->first_waiter == waiter)
+			lock->first_waiter = list_next_entry(waiter, list);
 		list_del(&waiter->list);
 	}
 
kernel/locking/ww_mutex.h +48 -12

83 lines not on this page · raw message

#6 lore raw
Quoted 17 lines · Peter Zijlstra
Quoted 15 lines · Peter Zijlstra
Quoted 13 lines · Chaitanya Kumar

kernel/locking/ww_mutex.h __ww_waiter_last(struct mutex *lock) · line 46

Quoted 11 lines
kernel/locking/ww_mutex.h +1 -1
index b1834ab7e782..bb8b410779d4 100644
@@ -42,7 +42,7 @@ __ww_waiter_last(struct mutex *lock)
          struct mutex_waiter *w = lock->first_waiter;
          if (w)
-         w = list_prev_entry(w, list);
+         w = __ww_waiter_prev(lock, w);
          return w;
  }

Thank you for the response, Peter. Unfortunately, the issue is still seen with this change.

Quoted 8 lines
Quoted 8 lines

Bah, indeed. Looking at this after the weekend I see that it's actually wrong.

But I haven't yet had a new idea. I don't suppose there is a relatively easy way to reproduce this issue outside of your CI robot?

My current working thesis is that since this is graphics, this is ww_mutex related. I'll go over this code once more...

So I tripped over this in my own testing today preping proxy patches, bisecting it down to the same problematic commit 25500ba7e77c ("locking/mutex: Remove the list_head from struct mutex").

Inteed it does seem related to ww_mutexes, as I can pretty easily reproduce it with defconfig + CONFIG_WW_MUTEX_SELFTEST=y using qemu-system-x86

Where the test will basically hang on bootup.

Quoted 2 lines

Since you've not provided a reproducer, can I ask you to try the below?

Unfortunately that patch doesn't seem to sort it (see the same behavior). I'm about cooked for tonight so I'll have to look more closely tomorrow.

thanks
-john

maintainer
#7 lore raw
Quoted 9 lines · John Stultz

So I tripped over this in my own testing today preping proxy patches, bisecting it down to the same problematic commit 25500ba7e77c ("locking/mutex: Remove the list_head from struct mutex").

Inteed it does seem related to ww_mutexes, as I can pretty easily reproduce it with defconfig + CONFIG_WW_MUTEX_SELFTEST=y using qemu-system-x86

Where the test will basically hang on bootup.

*groan* indeed. This of course means no CI is running this thing :-(

Anyway, yay for deterministic reproducer. Let me go prod at this.

#8 lore raw
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · John Stultz

So I tripped over this in my own testing today preping proxy patches, bisecting it down to the same problematic commit 25500ba7e77c ("locking/mutex: Remove the list_head from struct mutex").

Inteed it does seem related to ww_mutexes, as I can pretty easily reproduce it with defconfig + CONFIG_WW_MUTEX_SELFTEST=y using qemu-system-x86

Quoted 5 lines
Quoted 1 line

Where the test will basically hang on bootup.

*groan* indeed. This of course means no CI is running this thing :-(

Anyway, yay for deterministic reproducer. Let me go prod at this.

So I managed to unblock the ww-mutext_test with:

kernel/locking/mutex.c +6 -1
index 186b463fe326..623c892c3742 100644
@@ -209,8 +209,13 @@ __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
 	hung_task_set_blocker(lock, BLOCKER_TYPE_MUTEX);
 	debug_mutex_add_waiter(lock, waiter, current);
 
-	if (!first)
+	if (!first) {
 		first = lock->first_waiter;
+	} else if (first == lock->first_waiter) {
+		list_add_tail(&waiter->list, &first->list);
+		lock->first_waiter = waiter;
+		return;
+	}
 
 	if (first) {
 		list_add_tail(&waiter->list, &first->list);
kernel/locking/ww_mutex.h +1 -2
index 016f0db892a5..2fcd6221fc64 100644
@@ -28,10 +28,9 @@ static inline struct mutex_waiter *
 __ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w)
 	__must_hold(&lock->wait_lock)
 {
-	w = list_prev_entry(w, list);
 	if (lock->first_waiter == w)
 		return NULL;
-
+	w = list_prev_entry(w, list);
 	return w;
 }
 

---

First hunk orders the first_waiter if we are attaching to the tail of current first_waiter which would have previously ended up next to list_head.

The second hunk deals with __ww_waiter_prev() - since we are traversing back from w, I guess we must first check if we are at the first_waiter already or not.

I'll let you stare and see if it is correct or not.

Signature · 2 lines
Thanks and Regards,
Prateek
maintainer
#9 lore raw
Quoted 41 lines · K Prateek Nayak
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · John Stultz

So I tripped over this in my own testing today preping proxy patches, bisecting it down to the same problematic commit 25500ba7e77c ("locking/mutex: Remove the list_head from struct mutex").

Inteed it does seem related to ww_mutexes, as I can pretty easily reproduce it with defconfig + CONFIG_WW_MUTEX_SELFTEST=y using qemu-system-x86

Quoted 5 lines
Quoted 1 line

Where the test will basically hang on bootup.

*groan* indeed. This of course means no CI is running this thing :-(

Anyway, yay for deterministic reproducer. Let me go prod at this.

So I managed to unblock the ww-mutext_test with:

kernel/locking/mutex.c +6 -1
index 186b463fe326..623c892c3742 100644
@@ -209,8 +209,13 @@ __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
 	hung_task_set_blocker(lock, BLOCKER_TYPE_MUTEX);
 	debug_mutex_add_waiter(lock, waiter, current);
 
-	if (!first)
+	if (!first) {
 		first = lock->first_waiter;
+	} else if (first == lock->first_waiter) {
+		list_add_tail(&waiter->list, &first->list);
+		lock->first_waiter = waiter;
+		return;
+	}
 
 	if (first) {
 		list_add_tail(&waiter->list, &first->list);
Quoted 3 lines

First hunk orders the first_waiter if we are attaching to the tail of current first_waiter which would have previously ended up next to list_head.

This is the case in __ww_mutex_add_waiter() where pos == first, right?

Argh, I see... yes. Perhaps something like the below though?

Quoted 16 lines
kernel/locking/ww_mutex.h +1 -2
index 016f0db892a5..2fcd6221fc64 100644
@@ -28,10 +28,9 @@ static inline struct mutex_waiter *
 __ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w)
 	__must_hold(&lock->wait_lock)
 {
-	w = list_prev_entry(w, list);
 	if (lock->first_waiter == w)
 		return NULL;
-
+	w = list_prev_entry(w, list);
 	return w;
 }
 
Quoted 3 lines

The second hunk deals with __ww_waiter_prev() - since we are traversing back from w, I guess we must first check if we are at the first_waiter already or not.

Yes, that second hunk is what I found yesterday, although my fix was far more verbose. I like this one better ;-)

---

kernel/locking/mutex.c +22 -11
index 95f1822122a1..7d48d6f49f71 100644
@@ -200,21 +200,34 @@ static inline void __mutex_clear_flag(struct mutex *lock, unsigned long flag)
  */
 static void
 __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
-		   struct mutex_waiter *first)
+		   struct mutex_waiter *pos)
 {
+	struct mutex_waiter *first = lock->first_waiter;
+
 	hung_task_set_blocker(lock, BLOCKER_TYPE_MUTEX);
 	debug_mutex_add_waiter(lock, waiter, current);
 
-	if (!first)
-		first = lock->first_waiter;
+	if (pos) {
+		/*
+		 * Insert @waiter before @pos.
+		 */
+		list_add_tail(&waiter->list, &pos->list);
+		/*
+		 * If @pos == @first, then @waiter will be the new first.
+		 */
+		if (pos == first)
+			lock->first_waiter = waiter;
+		return;
+	}
 
 	if (first) {
 		list_add_tail(&waiter->list, &first->list);
-	} else {
-		INIT_LIST_HEAD(&waiter->list);
-		lock->first_waiter = waiter;
-		__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
+		return;
 	}
+
+	INIT_LIST_HEAD(&waiter->list);
+	lock->first_waiter = waiter;
+	__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
 }
 
 static void
@@ -224,10 +237,8 @@ __mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter)
 		__mutex_clear_flag(lock, MUTEX_FLAGS);
 		lock->first_waiter = NULL;
 	} else {
-		if (lock->first_waiter == waiter) {
-			lock->first_waiter = list_first_entry(&waiter->list,
-							      struct mutex_waiter, list);
-		}
+		if (lock->first_waiter == waiter)
+			lock->first_waiter = list_next_entry(waiter, list);
 		list_del(&waiter->list);
 	}
 
#10 lore raw
Quoted 1 line · Peter Zijlstra

Argh, I see... yes. Perhaps something like the below though?

This is a documentation bug. I thought it was supposed to add *after* pos, not before. So can we clear that up too?

@@ -198,7 +198,7 @@ static inline void __mutex_clear_flag(struct mutex *lock, unsigned long flag)
}

/*
- * Add @waiter to a given location in the lock wait_list and set the
+ * Add @waiter before a given location in the lock wait_list and set the
* FLAG_WAITERS flag if it's the first waiter.
*/
static void

maintainer
#11 lore raw
Quoted 5 lines · Matthew Wilcox
Quoted 1 line · Peter Zijlstra

Argh, I see... yes. Perhaps something like the below though?

This is a documentation bug. I thought it was supposed to add *after* pos, not before. So can we clear that up too?

Sure, that comment is indeed less than clear. The comment in __ww_mutex_add_waiter() is better.

Quoted 11 lines
(quoted diff) +1 -1
@@ -198,7 +198,7 @@ static inline void __mutex_clear_flag(struct mutex *lock, unsigned long flag)
 }
 
 /*
- * Add @waiter to a given location in the lock wait_list and set the
+ * Add @waiter before a given location in the lock wait_list and set the
  * FLAG_WAITERS flag if it's the first waiter.
  */
 static void
Tested-by
#12 lore raw
In reply to Peter Zijlstra

Hello Peter,

Quoted 7 lines · Peter Zijlstra
Quoted 3 lines

First hunk orders the first_waiter if we are attaching to the tail of current first_waiter which would have previously ended up next to list_head.

This is the case in __ww_mutex_add_waiter() where pos == first, right?

Argh, I see... yes. Perhaps something like the below though?

Neat! Thank you for cleaning it up. Those, along with the changes in ww_mutex.h fix the issue of ww-mutex_test hanging in my case. Feel free to include:

Signature · 2 lines
Thanks and Regards,
Prateek
Tested-by
#13 lore raw
Quoted 7 lines · K Prateek Nayak
Quoted 6 lines · Peter Zijlstra
Quoted 3 lines

First hunk orders the first_waiter if we are attaching to the tail of current first_waiter which would have previously ended up next to list_head.

This is the case in __ww_mutex_add_waiter() where pos == first, right?

Quoted 7 lines
Quoted 1 line

Argh, I see... yes. Perhaps something like the below though?

Neat! Thank you for cleaning it up. Those, along with the changes in ww_mutex.h fix the issue of ww-mutex_test hanging in my case. Feel free to include:

Same. With Peter's change and K Prateek's ww_mutex.h change it looks like it's working for me.

Thank you both!

thanks
-john

maintainer
#14 lore raw
Quoted 14 lines · John Stultz
Quoted 13 lines · K Prateek Nayak
Quoted 7 lines · Peter Zijlstra
Quoted 3 lines

First hunk orders the first_waiter if we are attaching to the tail of current first_waiter which would have previously ended up next to list_head.

This is the case in __ww_mutex_add_waiter() where pos == first, right?

Argh, I see... yes. Perhaps something like the below though?

Neat! Thank you for cleaning it up. Those, along with the changes in ww_mutex.h fix the issue of ww-mutex_test hanging in my case. Feel free to include:

Quoted 7 lines
Quoted 1 line

Same. With Peter's change and K Prateek's ww_mutex.h change it looks like it's working for me.

Thank you both!

Excellent, I'll write it up tomorrow.

maintainer
#15 lore raw
Quoted 1 line · Peter Zijlstra

Excellent, I'll write it up tomorrow.

How's this? It 'passes' the ww_mutex selftest thing in so far as that I get the same:

[    2.312369] Beginning ww (wound) mutex selftests
[    4.853240] stress (stress_inorder_work) failed with -35
[    9.379572] Beginning ww (die) mutex selftests
[   16.435831] All ww mutex selftests passed

before the offending commit and after this patch.

---
Subject: Subject: locking/mutex: Fix ww_mutex wait_list operations
From: Peter Zijlstra <[email protected]>
Date: Wed Apr 22 10:38:41 CEST 2026

Chaitanya and John reported commit 25500ba7e77c ("locking/mutex: Remove the list_head from struct mutex") wrecked ww_mutex.

Specifically there were 2 issues:

- __ww_waiter_prev() had the termination condition wrong; it would terminate when the previous entry was the first, which results in a truncated
iteration: W3, W2, (no W1).

- __mutex_add_waiter(@pos != NULL), as used by __ww_waiter_add() / __ww_mutex_add_waiter(); this inserts @waiter before @pos (which is what list_add_tail() does). But this should then also update lock->first_waiter.

Much thanks to Prateek for spotting the __mutex_add_waiter() issue!

---
 kernel/locking/mutex.c    |   40 +++++++++++++++++++++++++++-------------
 kernel/locking/ww_mutex.h |   34 ++++++++++++++++++++++++++++++++--
 2 files changed, 59 insertions(+), 15 deletions(-)
kernel/locking/mutex.c +27 -13
@@ -198,27 +198,43 @@ static inline void __mutex_clear_flag(st
 }
 
 /*
- * Add @waiter to a given location in the lock wait_list and set the
- * FLAG_WAITERS flag if it's the first waiter.
+ * Add @waiter to the @lock wait_list and set the FLAG_WAITERS flag if it's
+ * the first waiter.
+ *
+ * When @pos, @waiter is added before the waiter indicated by @pos. Otherwise
+ * @waiter will be added to the tail of the list.
  */
 static void
 __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
-		   struct mutex_waiter *first)
+		   struct mutex_waiter *pos)
 	__must_hold(&lock->wait_lock)
 {
+	struct mutex_waiter *first = lock->first_waiter;
+
 	hung_task_set_blocker(lock, BLOCKER_TYPE_MUTEX);
 	debug_mutex_add_waiter(lock, waiter, current);
 
-	if (!first)
-		first = lock->first_waiter;
+	if (pos) {
+		/*
+		 * Insert @waiter before @pos.
+		 */
+		list_add_tail(&waiter->list, &pos->list);
+		/*
+		 * If @pos == @first, then @waiter will be the new first.
+		 */
+		if (pos == first)
+			lock->first_waiter = waiter;
+		return;
+	}
 
 	if (first) {
 		list_add_tail(&waiter->list, &first->list);
-	} else {
-		INIT_LIST_HEAD(&waiter->list);
-		lock->first_waiter = waiter;
-		__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
+		return;
 	}
+
+	INIT_LIST_HEAD(&waiter->list);
+	lock->first_waiter = waiter;
+	__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
 }
 
 static void
@@ -229,10 +245,8 @@ __mutex_remove_waiter(struct mutex *lock
 		__mutex_clear_flag(lock, MUTEX_FLAGS);
 		lock->first_waiter = NULL;
 	} else {
-		if (lock->first_waiter == waiter) {
-			lock->first_waiter = list_first_entry(&waiter->list,
-							      struct mutex_waiter, list);
-		}
+		if (lock->first_waiter == waiter)
+			lock->first_waiter = list_next_entry(waiter, list);
 		list_del(&waiter->list);
 	}
 
kernel/locking/ww_mutex.h +32 -2
@@ -6,6 +6,19 @@
 #define MUTEX_WAITER	mutex_waiter
 #define WAIT_LOCK	wait_lock
 
+/*
+ *           +--------+
+ *           | first  |
+ *           +--------+
+ *                |
+ *                v
+ *  +----+     +----+     +----+
+ *  | W3 | <-> | W1 | <-> | W2 |
+ *  +----+     +----+     +----+
+ *    ^                     ^
+ *    +---------------------+
+ */
+
 static inline struct mutex_waiter *
 __ww_waiter_first(struct mutex *lock)
 	__must_hold(&lock->wait_lock)
@@ -13,26 +26,43 @@ __ww_waiter_first(struct mutex *lock)
 	return lock->first_waiter;
 }
 
+/*
+ * for (cur = __ww_waiter_first(); cur; cur = __ww_waiter_next())
+ *
+ * Should iterate like: W1, W2, W3
+ */
 static inline struct mutex_waiter *
 __ww_waiter_next(struct mutex *lock, struct mutex_waiter *w)
 	__must_hold(&lock->wait_lock)
 {
 	w = list_next_entry(w, list);
+	/*
+	 * Terminate if the next entry is the first again, that has already
+	 * been observed.
+	 */
 	if (lock->first_waiter == w)
 		return NULL;
 
 	return w;
 }
 
+/*
+ * for (cur = __ww_waiter_last(); cur; cur = __ww_waiter_prev())
+ *
+ * Should iterate like: W3, W2, W1
+ */
 static inline struct mutex_waiter *
 __ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w)
 	__must_hold(&lock->wait_lock)
 {
-	w = list_prev_entry(w, list);
+	/*
+	 * Terminate at the first entry, the previous entry of first is the
+	 * last and that has already been observed.
+	 */
 	if (lock->first_waiter == w)
 		return NULL;
 
-	return w;
+	return list_prev_entry(w, list);
 }
 
 static inline struct mutex_waiter *
Tested-by
#16 lore raw

Hello Peter,

Quoted 6 lines · Peter Zijlstra
Quoted 1 line · Peter Zijlstra

Excellent, I'll write it up tomorrow.

How's this? It 'passes' the ww_mutex selftest thing in so far as that I get the same:

Quoted 6 lines
[    2.312369] Beginning ww (wound) mutex selftests
[    4.853240] stress (stress_inorder_work) failed with -35
[    9.379572] Beginning ww (die) mutex selftests
[   16.435831] All ww mutex selftests passed

before the offending commit and after this patch.

Yup I see pretty much the same. I think 4k ww-mutexes being fought for by #CPUs threads with a short timeout doesn't sit too well with stress_inorder_work but it does make some forward progress until that timeout hits like before ;-)

Quoted 21 lines

---
Subject: Subject: locking/mutex: Fix ww_mutex wait_list operations
From: Peter Zijlstra <[email protected]>
Date: Wed Apr 22 10:38:41 CEST 2026

Chaitanya and John reported commit 25500ba7e77c ("locking/mutex: Remove the list_head from struct mutex") wrecked ww_mutex.

Specifically there were 2 issues:

- __ww_waiter_prev() had the termination condition wrong; it would terminate when the previous entry was the first, which results in a truncated
iteration: W3, W2, (no W1).

- __mutex_add_waiter(@pos != NULL), as used by __ww_waiter_add() / __ww_mutex_add_waiter(); this inserts @waiter before @pos (which is what list_add_tail() does). But this should then also update lock->first_waiter.

Much thanks to Prateek for spotting the __mutex_add_waiter() issue!

Quoted 7 lines

Still runs as expected! Feel free to include:

Signature · 2 lines
Thanks and Regards,
Prateek
#17 lore raw
In reply to Peter Zijlstra
Quoted 195 lines · Peter Zijlstra

How's this? It 'passes' the ww_mutex selftest thing in so far as that I
get the same:

[    2.312369] Beginning ww (wound) mutex selftests [    4.853240] stress (stress_inorder_work) failed with -35 [    9.379572] Beginning ww (die) mutex selftests [   16.435831] All ww mutex selftests passed

before the offending commit and after this patch.

---
Subject: Subject: locking/mutex: Fix ww_mutex wait_list operations
From: Peter Zijlstra <[email protected]>
Date: Wed Apr 22 10:38:41 CEST 2026

Chaitanya and John reported commit 25500ba7e77c ("locking/mutex:
Remove the
list_head from struct mutex") wrecked ww_mutex.

Specifically there were 2 issues:

 - __ww_waiter_prev() had the termination condition wrong; it would terminate
   when the previous entry was the first, which results in a truncated
   iteration: W3, W2, (no W1).

 - __mutex_add_waiter(@pos != NULL), as used by __ww_waiter_add() / __ww_mutex_add_waiter(); this inserts @waiter before @pos (which is what
   list_add_tail() does). But this should then also update lock-

Quoted 1 line

first_waiter.

Much thanks to Prateek for spotting the __mutex_add_waiter() issue!

Fixes 25500ba7e77c ("locking/mutex: Remove the list_head from struct

mutex")
Reported-by: "Borah, Chaitanya Kumar"
<[email protected]>
Closes:
https://lore.kernel.org/r/af005996-05e9-4336-8450-d14ca652ba5d%40intel.com

Closes:
https://lore.kernel.org/r/CANDhNCq%3Doizzud3hH3oqGzTrcjB8OwGeineJ3mwZuGdDWG8fRQ%40mail.gmail.com

---
 kernel/locking/mutex.c    |   40 +++++++++++++++++++++++++++--------
-----
 kernel/locking/ww_mutex.h |   34 ++++++++++++++++++++++++++++++++--

 2 files changed, 59 insertions(+), 15 deletions(-)
kernel/locking/mutex.c +0 -0
@@ -198,27 +198,43 @@ static inline void __mutex_clear_flag(st
  }


 /*
- * Add @waiter to a given location in the lock wait_list and set the
- * FLAG_WAITERS flag if it's the first waiter.
+ * Add @waiter to the @lock wait_list and set the FLAG_WAITERS flag if it's
+ * the first waiter.
+ *
+ * When @pos, @waiter is added before the waiter indicated by @pos. Otherwise
+ * @waiter will be added to the tail of the list.
  */
 static void
 __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,

kernel/locking/mutex.c +1 -1
-		   struct mutex_waiter *first)
+		   struct mutex_waiter *pos)

  __must_hold(&lock->wait_lock)
 {

kernel/locking/mutex.c +2 -0
+	struct mutex_waiter *first = lock->first_waiter;
+

  hung_task_set_blocker(lock, BLOCKER_TYPE_MUTEX); debug_mutex_add_waiter(lock, waiter, current);

kernel/locking/mutex.c +7 -2
-	if (!first)
-		first = lock->first_waiter;
+	if (pos) {
+		/*
+		 * Insert @waiter before @pos.
+		 */
+		list_add_tail(&waiter->list, &pos->list);
+		/*
+		 * If @pos == @first, then @waiter will be the new

first.

kernel/locking/mutex.c +5 -0
+		 */
+		if (pos == first)
+			lock->first_waiter = waiter;
+		return;
+	}


  if (first) {
  list_add_tail(&waiter->list, &first->list);

kernel/locking/mutex.c +1 -4
-	} else {
-		INIT_LIST_HEAD(&waiter->list);
-		lock->first_waiter = waiter;
-		__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
+		return;

  }

kernel/locking/mutex.c +4 -0
+
+	INIT_LIST_HEAD(&waiter->list);
+	lock->first_waiter = waiter;
+	__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);

 }

 static void

kernel/locking/mutex.c +2 -4
@@ -229,10 +245,8 @@ __mutex_remove_waiter(struct mutex *lock
  		__mutex_clear_flag(lock, MUTEX_FLAGS);
  		lock->first_waiter = NULL;
  	} else {
-		if (lock->first_waiter == waiter) {
-			lock->first_waiter =
 list_first_entry(&waiter->list,
-							      struct
 mutex_waiter, list);
-		}
+		if (lock->first_waiter == waiter)
+			lock->first_waiter = list_next_entry(waiter,
 list);

  list_del(&waiter->list);
  }

kernel/locking/ww_mutex.h +0 -0
@@ -6,6 +6,19 @@
  #define MUTEX_WAITER	mutex_waiter
  #define WAIT_LOCK	wait_lock

kernel/locking/ww_mutex.h +13 -0
+/*
+ *           +--------+
+ *           | first  |
+ *           +--------+
+ *                |
+ *                v
+ *  +----+     +----+     +----+
+ *  | W3 | <-> | W1 | <-> | W2 |
+ *  +----+     +----+     +----+
+ *    ^                     ^
+ *    +---------------------+
+ */
+

 static inline struct mutex_waiter *
 __ww_waiter_first(struct mutex *lock)
  __must_hold(&lock->wait_lock)

kernel/locking/ww_mutex.h +0 -0
@@ -13,26 +26,43 @@ __ww_waiter_first(struct mutex *lock)
  	return lock->first_waiter;
  }


+/*
+ * for (cur = __ww_waiter_first(); cur; cur = __ww_waiter_next())
+ *
+ * Should iterate like: W1, W2, W3
+ */
 static inline struct mutex_waiter * __ww_waiter_next(struct mutex *lock, struct mutex_waiter *w) __must_hold(&lock->wait_lock)
 {
  w = list_next_entry(w, list);

kernel/locking/ww_mutex.h +2 -0
+	/*
+	 * Terminate if the next entry is the first again, that has

already

kernel/locking/ww_mutex.h +2 -0
+	 * been observed.
+	 */

  if (lock->first_waiter == w)
  return NULL;

  return w;
 }

+/*
+ * for (cur = __ww_waiter_last(); cur; cur = __ww_waiter_prev())
+ *
+ * Should iterate like: W3, W2, W1
+ */
 static inline struct mutex_waiter * __ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w) __must_hold(&lock->wait_lock)
 {

kernel/locking/ww_mutex.h +2 -1
-	w = list_prev_entry(w, list);
+	/*
+	 * Terminate at the first entry, the previous entry of first

is the

kernel/locking/ww_mutex.h +2 -0
+	 * last and that has already been observed.
+	 */

  if (lock->first_waiter == w)
  return NULL;

kernel/locking/ww_mutex.h +1 -1
-	return w;
+	return list_prev_entry(w, list);
Quoted 3 lines

 }

 static inline struct mutex_waiter *

Confirmed on an independent userspace-visible reproducer: Resident Evil 2/3/4/9 under Proton on AMD Zen4 + RX 7900 XTX, which hangs deterministically during level load on current master (main thread parked in futex_waitv). With this patch applied on top of master, both RE2 and RE9 complete a full playthrough with save-resume on two independent workstations (ASUS and ASRock B650). No hang, no splats.

Symptom details and third bisect log are in the separate thread at
https://lore.kernel.org/r/CABXGCsO5fKq2nD9nO8yO1z50ZzgCPWqueNXHANjntaswoOh2Dg@mail.gmail.com

Signature · 2 lines
Thanks,
Mikhail
#18 lore raw
In reply to Peter Zijlstra

Hello Peter,

Quoted 125 lines · Peter Zijlstra
Quoted 15 lines · Peter Zijlstra
Quoted 5 lines · Chaitanya Kumar
Quoted 5 lines
kernel/locking/ww_mutex.h +0 -0
index b1834ab7e782..bb8b410779d4 100644
@@ -42,7 +42,7 @@ __ww_waiter_last(struct mutex *lock)
Quoted 8 lines

kernel/locking/ww_mutex.h __ww_waiter_last(struct mutex *lock) · line 46

Quoted 6 lines
kernel/locking/ww_mutex.h +1 -1
   	struct mutex_waiter *w = lock->first_waiter;
   	if (w)
-		w = list_prev_entry(w, list);
+		w = __ww_waiter_prev(lock, w);
   	return w;
   }

Thank you for the response, Peter. Unfortunately, the issue is still seen with this change.

Quoted 8 lines

Bah, indeed. Looking at this after the weekend I see that it's actually wrong.

But I haven't yet had a new idea. I don't suppose there is a relatively easy way to reproduce this issue outside of your CI robot?

My current working thesis is that since this is graphics, this is ww_mutex related. I'll go over this code once more...

Since you've not provided a reproducer, can I ask you to try the below?

---

kernel/locking/mutex.c +2 -4
index 186b463fe326..a93e57fc53b1 100644
@@ -229,10 +229,8 @@ __mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter)
  		__mutex_clear_flag(lock, MUTEX_FLAGS);
  		lock->first_waiter = NULL;
  	} else {
-		if (lock->first_waiter == waiter) {
-			lock->first_waiter = list_first_entry(&waiter->list,
-							      struct mutex_waiter, list);
-		}
+		if (lock->first_waiter == waiter)
+			lock->first_waiter = list_next_entry(waiter, list);
  		list_del(&waiter->list);
  	}
 
kernel/locking/ww_mutex.h +41 -12
index 016f0db892a5..875b303511b3 100644
@@ -6,6 +6,32 @@
  #define MUTEX_WAITER	mutex_waiter
  #define WAIT_LOCK	wait_lock
 
+/*
+ *                +-------+
+ *                |   3   | <+
+ *                +-------+  |
+ *                    ^      |
+ *                    |      |
+ *                    v      |
+ *  +-------+     +-------+  |
+ *  | first | --> |   1   |  |
+ *  +-------+     +-------+  |
+ *                    ^      |
+ *                    |      |
+ *                    v      |
+ *                +-------+  |
+ *                |   2   | <+
+ *                +-------+
+ */
+
+/*
+ * Specifically:
+ *
+ *   for (cur = __ww_waiter_first(); cur; cur = __ww_waiter_next())
+ *     ...
+ *
+ * should iterate like: 1 2 3
+ */
  static inline struct mutex_waiter *
  __ww_waiter_first(struct mutex *lock)
  	__must_hold(&lock->wait_lock)
@@ -18,23 +44,21 @@ __ww_waiter_next(struct mutex *lock, struct mutex_waiter *w)
  	__must_hold(&lock->wait_lock)
  {
  	w = list_next_entry(w, list);
-	if (lock->first_waiter == w)
-		return NULL;
-
-	return w;
-}
-
-static inline struct mutex_waiter *
-__ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w)
-	__must_hold(&lock->wait_lock)
-{
-	w = list_prev_entry(w, list);
-	if (lock->first_waiter == w)
+	/* We've already seen first, terminate */
+	if (w == __ww_waiter_first(lock))
  		return NULL;
 
  	return w;
  }
 
+/*
+ * Specifically:
+ *
+ *   for (cur = __ww_waiter_last(); cur; cur = __ww_waiter_prev())
+ *     ...
+ *
+ * should iterate like: 3 2 1
+ */
  static inline struct mutex_waiter *
  __ww_waiter_last(struct mutex *lock)
  	__must_hold(&lock->wait_lock)
@@ -46,6 +70,18 @@ __ww_waiter_last(struct mutex *lock)
  	return w;
  }
 
+static inline struct mutex_waiter *
+__ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w)
+	__must_hold(&lock->wait_lock)
+{
+	w = list_prev_entry(w, list);

kernel/locking/ww_mutex.h __ww_waiter_last(struct mutex *lock) · line 87

Quoted 10 lines
kernel/locking/ww_mutex.h +7 -0
+	/* We've already seen last, terminate */
+	if (w == __ww_waiter_last(lock))
+		return NULL;
+
+	return w;
+}
+
  static inline void
  __ww_waiter_add(struct mutex *lock, struct mutex_waiter *waiter, struct mutex_waiter *pos)
  	__must_hold(&lock->wait_lock)

Thank you for the patch.
This seems to fix the issue on our CI machine. The diff turned out to be slightly different, pasting it here just in case.

kernel/locking/mutex.c +2 -4
index 186b463fe326..a93e57fc53b1 100644
@@ -229,10 +229,8 @@ __mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter)
                __mutex_clear_flag(lock, MUTEX_FLAGS);
                lock->first_waiter = NULL;
        } else {
-               if (lock->first_waiter == waiter) {
-                       lock->first_waiter = list_first_entry(&waiter->list,
-                                                             struct mutex_waiter, list);
-               }
+               if (lock->first_waiter == waiter)
+                       lock->first_waiter = list_next_entry(waiter, list);
                list_del(&waiter->list);
        }
 
kernel/locking/ww_mutex.h +0 -0
index 016f0db892a5..875b303511b3 100644
@@ -6,6 +6,32 @@

#define MUTEX_WAITER mutex_waiter
#define WAIT_LOCK wait_lock

+/*

+ *                +-------+
+ *                |   3   | <+
+ *                +-------+  |
+ *                    ^      |
+ *                    |      |
+ *                    v      |
+ *  +-------+     +-------+  |
+ *  | first | --> |   1   |  |
+ *  +-------+     +-------+  |
+ *                    ^      |
+ *                    |      |
+ *                    v      |
+ *                +-------+  |

+ * | 2 | <+
+ * +-------+
+ */
+
+/*
+ * Specifically:
+ *
+ * for (cur = __ww_waiter_first(); cur; cur = __ww_waiter_next())
+ * ...
+ *
+ * should iterate like: 1 2 3
+ */
static inline struct mutex_waiter *
__ww_waiter_first(struct mutex *lock)

        __must_hold(&lock->wait_lock)
@@ -18,31 +44,41 @@ __ww_waiter_next(struct mutex *lock, struct mutex_waiter *w)
        __must_hold(&lock->wait_lock)
{
        w = list_next_entry(w, list);
-       if (lock->first_waiter == w)
+       /* We've already seen first, terminate */
+       if (w == __ww_waiter_first(lock))
                return NULL;

        return w;
}

+/*
+ * Specifically:
+ *
+ * for (cur = __ww_waiter_last(); cur; cur = __ww_waiter_prev())
+ * ...
+ *
+ * should iterate like: 3 2 1
+ */
static inline struct mutex_waiter * -__ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w) +__ww_waiter_last(struct mutex *lock)

        __must_hold(&lock->wait_lock)

{
- w = list_prev_entry(w, list);
- if (lock->first_waiter == w)
- return NULL;
+ struct mutex_waiter *w = lock->first_waiter;

+ if (w)

+               w = list_prev_entry(w, list);
        return w;
}

static inline struct mutex_waiter * -__ww_waiter_last(struct mutex *lock) +__ww_waiter_prev(struct mutex *lock, struct mutex_waiter *w)

        __must_hold(&lock->wait_lock)
{
-       struct mutex_waiter *w = lock->first_waiter;
+       w = list_prev_entry(w, list);
+       /* We've already seen last, terminate */
+       if (w == __ww_waiter_last(lock))

+ return NULL;

- if (w)

-               w = list_prev_entry(w, list);
        return w;
}

==
Chaitanya

#19 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 )

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 )
URL : https://patchwork.freedesktop.org/series/164008/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#20 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev2)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev2)
URL : https://patchwork.freedesktop.org/series/164008/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#21 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev2)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev2)
URL : https://patchwork.freedesktop.org/series/164009/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#22 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev3)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev3)
URL : https://patchwork.freedesktop.org/series/164009/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#23 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev3)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev3)
URL : https://patchwork.freedesktop.org/series/164008/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#24 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev4)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev4)
URL : https://patchwork.freedesktop.org/series/164009/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#25 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev4)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev4)
URL : https://patchwork.freedesktop.org/series/164008/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#26 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev5)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev5)
URL : https://patchwork.freedesktop.org/series/164008/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

#27 lore raw

✗ LGCI.VerificationFailed: failure for Regression on linux-next (next-20260324 ) (rev5)

In reply to Borah, Chaitanya Kumar
== Series Details ==

== Series Details ==

Series: Regression on linux-next (next-20260324 ) (rev5)
URL : https://patchwork.freedesktop.org/series/164009/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!