Commit fbeb558
Peter Zijlstra
futex/pi: Fix recursive rt_mutex waiter state
Some new assertions pointed out that the existing code has nested rt_mutex wait
state in the futex code.
Specifically, the futex_lock_pi() cancel case uses spin_lock() while there
still is a rt_waiter enqueued for this task, resulting in a state where there
are two waiters for the same task (and task_struct::pi_blocked_on gets
scrambled).
The reason to take hb->lock at this point is to avoid the wake_futex_pi()
EAGAIN case.
This happens when futex_top_waiter() and rt_mutex_top_waiter() state becomes
inconsistent. The current rules are such that this inconsistency will not be
observed.
Notably the case that needs to be avoided is where futex_lock_pi() and
futex_unlock_pi() interleave such that unlock will fail to observe a new
waiter.
*However* the case at hand is where a waiter is leaving, in this case the race
means a waiter that is going away is not observed -- which is harmless,
provided this race is explicitly handled.
This is a somewhat dangerous proposition because the converse race is not
observing a new waiter, which must absolutely not happen. But since the race is
valid this cannot be asserted.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lkml.kernel.org/r/20230915151943.GD6743@noisy.programming.kicks-ass.net1 parent 45f67f3 commit fbeb558
2 files changed
+52
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
611 | 611 | | |
612 | 612 | | |
613 | 613 | | |
614 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
615 | 617 | | |
616 | | - | |
617 | 618 | | |
618 | 619 | | |
619 | 620 | | |
620 | 621 | | |
621 | 622 | | |
622 | 623 | | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | 624 | | |
638 | 625 | | |
639 | 626 | | |
| |||
1046 | 1033 | | |
1047 | 1034 | | |
1048 | 1035 | | |
1049 | | - | |
1050 | 1036 | | |
1051 | 1037 | | |
1052 | | - | |
1053 | | - | |
1054 | | - | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1055 | 1047 | | |
1056 | | - | |
1057 | | - | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1058 | 1053 | | |
1059 | 1054 | | |
1060 | 1055 | | |
1061 | 1056 | | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1062 | 1063 | | |
1063 | 1064 | | |
1064 | 1065 | | |
| |||
1143 | 1144 | | |
1144 | 1145 | | |
1145 | 1146 | | |
| 1147 | + | |
1146 | 1148 | | |
1147 | 1149 | | |
1148 | 1150 | | |
| |||
1155 | 1157 | | |
1156 | 1158 | | |
1157 | 1159 | | |
1158 | | - | |
1159 | 1160 | | |
1160 | 1161 | | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
1164 | 1170 | | |
1165 | 1171 | | |
1166 | 1172 | | |
1167 | | - | |
| 1173 | + | |
1168 | 1174 | | |
1169 | 1175 | | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
1170 | 1189 | | |
1171 | 1190 | | |
1172 | 1191 | | |
1173 | | - | |
| 1192 | + | |
1174 | 1193 | | |
1175 | 1194 | | |
1176 | 1195 | | |
| |||
1198 | 1217 | | |
1199 | 1218 | | |
1200 | 1219 | | |
| 1220 | + | |
1201 | 1221 | | |
1202 | 1222 | | |
1203 | 1223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
850 | 850 | | |
851 | 851 | | |
852 | 852 | | |
853 | | - | |
854 | | - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
855 | 856 | | |
856 | 857 | | |
857 | 858 | | |
| 859 | + | |
858 | 860 | | |
859 | 861 | | |
860 | 862 | | |
| |||
0 commit comments