[PATCH 4/4] sched_ext: Use __COMPAT_is_enq_cpu_selected() in scx_qmap

From: Changwoo Min
Date: Fri Feb 07 2025 - 23:44:40 EST


Instead of directly using SCX_ENQ_CPU_SELECTED, which may not be defined
in old kernels, use the __COMPAT_is_enq_cpu_selected() helper function
so the BPF scheduler can behave correctly regardless of kernel versions.

Signed-off-by: Changwoo Min <changwoo@xxxxxxxxxx>
---
tools/sched_ext/scx_qmap.bpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/sched_ext/scx_qmap.bpf.c b/tools/sched_ext/scx_qmap.bpf.c
index 5edb79742e37..267fe15d934a 100644
--- a/tools/sched_ext/scx_qmap.bpf.c
+++ b/tools/sched_ext/scx_qmap.bpf.c
@@ -231,7 +231,7 @@ void BPF_STRUCT_OPS(qmap_enqueue, struct task_struct *p, u64 enq_flags)
}

/* if select_cpu() wasn't called, try direct dispatch */
- if (!(enq_flags & SCX_ENQ_CPU_SELECTED) &&
+ if (!__COMPAT_is_enq_cpu_selected(enq_flags) &&
(cpu = pick_direct_dispatch_cpu(p, scx_bpf_task_cpu(p))) >= 0) {
__sync_fetch_and_add(&nr_ddsp_from_enq, 1);
scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL_ON | cpu, slice_ns, enq_flags);
--
2.48.1