Skip to content

Commit 9b67179

Browse files
committed
sched_ext, scx_qmap: Add and use SCX_ENQ_CPU_SELECTED
scx_qmap and other schedulers in the SCX repo are using SCX_ENQ_WAKEUP to tell whether ops.select_cpu() was called. This is incorrect as ops.select_cpu() can be skipped in the wakeup path and leads to e.g. incorrectly skipping direct dispatch for tasks that are bound to a single CPU. sched core has been updated to specify ENQUEUE_RQ_SELECTED if ->select_task_rq() was called. Map it to SCX_ENQ_CPU_SELECTED and update scx_qmap to test it instead of SCX_ENQ_WAKEUP. Signed-off-by: Tejun Heo <[email protected]> Acked-by: David Vernet <[email protected]> Cc: Daniel Hodges <[email protected]> Cc: Changwoo Min <[email protected]> Cc: Andrea Righi <[email protected]> Cc: Dan Schatzberg <[email protected]>
1 parent f207dc2 commit 9b67179

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

kernel/sched/ext.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ enum scx_enq_flags {
696696
/* expose select ENQUEUE_* flags as enums */
697697
SCX_ENQ_WAKEUP = ENQUEUE_WAKEUP,
698698
SCX_ENQ_HEAD = ENQUEUE_HEAD,
699+
SCX_ENQ_CPU_SELECTED = ENQUEUE_RQ_SELECTED,
699700

700701
/* high 32bits are SCX specific */
701702

tools/sched_ext/scx_qmap.bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ void BPF_STRUCT_OPS(qmap_enqueue, struct task_struct *p, u64 enq_flags)
230230
return;
231231
}
232232

233-
/* if !WAKEUP, select_cpu() wasn't called, try direct dispatch */
234-
if (!(enq_flags & SCX_ENQ_WAKEUP) &&
233+
/* if select_cpu() wasn't called, try direct dispatch */
234+
if (!(enq_flags & SCX_ENQ_CPU_SELECTED) &&
235235
(cpu = pick_direct_dispatch_cpu(p, scx_bpf_task_cpu(p))) >= 0) {
236236
__sync_fetch_and_add(&nr_ddsp_from_enq, 1);
237237
scx_bpf_dispatch(p, SCX_DSQ_LOCAL_ON | cpu, slice_ns, enq_flags);

0 commit comments

Comments
 (0)