Commit 5e7b2cc
sched_ext: Fix stale direct dispatch state in ddsp_dsq_id
[ Upstream commit 7e0ffb7 ]
@p->scx.ddsp_dsq_id can be left set (non-SCX_DSQ_INVALID) triggering a
spurious warning in mark_direct_dispatch() when the next wakeup's
ops.select_cpu() calls scx_bpf_dsq_insert(), such as:
WARNING: kernel/sched/ext.c:1273 at scx_dsq_insert_commit+0xcd/0x140
The root cause is that ddsp_dsq_id was only cleared in dispatch_enqueue(),
which is not reached in all paths that consume or cancel a direct dispatch
verdict.
Fix it by clearing it at the right places:
- direct_dispatch(): cache the direct dispatch state in local variables
and clear it before dispatch_enqueue() on the synchronous path. For
the deferred path, the direct dispatch state must remain set until
process_ddsp_deferred_locals() consumes them.
- process_ddsp_deferred_locals(): cache the dispatch state in local
variables and clear it before calling dispatch_to_local_dsq(), which
may migrate the task to another rq.
- do_enqueue_task(): clear the dispatch state on the enqueue path
(local/global/bypass fallbacks), where the direct dispatch verdict is
ignored.
- dequeue_task_scx(): clear the dispatch state after dispatch_dequeue()
to handle both the deferred dispatch cancellation and the holding_cpu
race, covering all cases where a pending direct dispatch is
cancelled.
- scx_disable_task(): clear the direct dispatch state when
transitioning a task out of the current scheduler. Waking tasks may
have had the direct dispatch state set by the outgoing scheduler's
ops.select_cpu() and then been queued on a wake_list via
ttwu_queue_wakelist(), when SCX_OPS_ALLOW_QUEUED_WAKEUP is set. Such
tasks are not on the runqueue and are not iterated by scx_bypass(),
so their direct dispatch state won't be cleared. Without this clear,
any subsequent SCX scheduler that tries to direct dispatch the task
will trigger the WARN_ON_ONCE() in mark_direct_dispatch().
Fixes: 5b26f7b ("sched_ext: Allow SCX_DSQ_LOCAL_ON for direct dispatches")
Cc: stable@vger.kernel.org # v6.12+
Cc: Daniel Hodges <hodgesd@meta.com>
Cc: Patrick Somaru <patsomaru@meta.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent d5776a3 commit 5e7b2cc
1 file changed
Lines changed: 35 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1025 | 1025 | | |
1026 | 1026 | | |
1027 | 1027 | | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
1037 | 1028 | | |
1038 | 1029 | | |
1039 | 1030 | | |
| |||
1176 | 1167 | | |
1177 | 1168 | | |
1178 | 1169 | | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
1179 | 1191 | | |
1180 | 1192 | | |
1181 | 1193 | | |
1182 | 1194 | | |
1183 | 1195 | | |
1184 | 1196 | | |
| 1197 | + | |
1185 | 1198 | | |
1186 | 1199 | | |
1187 | 1200 | | |
| |||
1222 | 1235 | | |
1223 | 1236 | | |
1224 | 1237 | | |
1225 | | - | |
1226 | | - | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
1227 | 1242 | | |
1228 | 1243 | | |
1229 | 1244 | | |
| |||
1329 | 1344 | | |
1330 | 1345 | | |
1331 | 1346 | | |
| 1347 | + | |
1332 | 1348 | | |
1333 | 1349 | | |
1334 | 1350 | | |
| |||
1496 | 1512 | | |
1497 | 1513 | | |
1498 | 1514 | | |
| 1515 | + | |
1499 | 1516 | | |
1500 | 1517 | | |
1501 | 1518 | | |
| |||
2236 | 2253 | | |
2237 | 2254 | | |
2238 | 2255 | | |
| 2256 | + | |
| 2257 | + | |
2239 | 2258 | | |
2240 | 2259 | | |
| 2260 | + | |
2241 | 2261 | | |
2242 | | - | |
| 2262 | + | |
2243 | 2263 | | |
2244 | | - | |
2245 | | - | |
| 2264 | + | |
2246 | 2265 | | |
2247 | 2266 | | |
2248 | 2267 | | |
| |||
2881 | 2900 | | |
2882 | 2901 | | |
2883 | 2902 | | |
| 2903 | + | |
| 2904 | + | |
2884 | 2905 | | |
2885 | 2906 | | |
2886 | 2907 | | |
| |||
0 commit comments