Commit 7e0ffb7
sched_ext: Fix stale direct dispatch state in ddsp_dsq_id
@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: [email protected] # v6.12+
Cc: Daniel Hodges <[email protected]>
Cc: Patrick Somaru <[email protected]>
Signed-off-by: Andrea Righi <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>1 parent 0c4a59d commit 7e0ffb7
1 file changed
Lines changed: 35 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1109 | 1109 | | |
1110 | 1110 | | |
1111 | 1111 | | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | 1112 | | |
1122 | 1113 | | |
1123 | 1114 | | |
| |||
1283 | 1274 | | |
1284 | 1275 | | |
1285 | 1276 | | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
1286 | 1298 | | |
1287 | 1299 | | |
1288 | 1300 | | |
1289 | 1301 | | |
1290 | 1302 | | |
1291 | 1303 | | |
| 1304 | + | |
1292 | 1305 | | |
1293 | 1306 | | |
1294 | 1307 | | |
| |||
1329 | 1342 | | |
1330 | 1343 | | |
1331 | 1344 | | |
1332 | | - | |
1333 | | - | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
1334 | 1349 | | |
1335 | 1350 | | |
1336 | 1351 | | |
| |||
1439 | 1454 | | |
1440 | 1455 | | |
1441 | 1456 | | |
| 1457 | + | |
1442 | 1458 | | |
1443 | 1459 | | |
1444 | 1460 | | |
| |||
1610 | 1626 | | |
1611 | 1627 | | |
1612 | 1628 | | |
| 1629 | + | |
1613 | 1630 | | |
1614 | 1631 | | |
1615 | 1632 | | |
| |||
2293 | 2310 | | |
2294 | 2311 | | |
2295 | 2312 | | |
| 2313 | + | |
| 2314 | + | |
2296 | 2315 | | |
2297 | 2316 | | |
| 2317 | + | |
2298 | 2318 | | |
2299 | | - | |
| 2319 | + | |
2300 | 2320 | | |
2301 | | - | |
2302 | | - | |
| 2321 | + | |
2303 | 2322 | | |
2304 | 2323 | | |
2305 | 2324 | | |
| |||
3015 | 3034 | | |
3016 | 3035 | | |
3017 | 3036 | | |
| 3037 | + | |
| 3038 | + | |
3018 | 3039 | | |
3019 | 3040 | | |
3020 | 3041 | | |
| |||
0 commit comments