[PATCH 1/2] sched_ext: scx_qmap: Drop the compat code

From: Tejun Heo

Date: Mon Oct 19 2026 - 17:32:57 EST


scx_qmap demonstrates and tests the sched_ext features of the kernel it
ships with. It already requires that kernel, as it implements
ops.sub_cid_sched_updated() and ops.sub_child_ecaps_updated(), so its compat
checks only keep untested fallbacks around. Drop them, use the kernel
interfaces directly, and note the coupling in the top comment. No functional
change on a current kernel.

Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
---
tools/sched_ext/scx_qmap.bpf.c | 31 ++++++++++++++++---------------
tools/sched_ext/scx_qmap.c | 14 +++++---------
2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/tools/sched_ext/scx_qmap.bpf.c b/tools/sched_ext/scx_qmap.bpf.c
index 63e3c9080e77..77f02fb70a86 100644
--- a/tools/sched_ext/scx_qmap.bpf.c
+++ b/tools/sched_ext/scx_qmap.bpf.c
@@ -10,6 +10,10 @@
* - Core-sched support.
* - Hierarchical sub-scheduling: delegating cpus to child cgroup schedulers.
*
+ * scx_qmap is often used to exercise sched_ext features as they land. It is
+ * coupled with the kernel it ships with and uses its sched_ext interfaces
+ * directly. It isn't expected to load on other kernels.
+ *
* Base design: Five FIFOs (arena-backed doubly-linked lists through per-task
* context). A task is assigned to a FIFO by its compound weight. Each cpu
* round-robins the FIFOs, dispatching more from higher ones.
@@ -583,14 +587,13 @@ void BPF_STRUCT_OPS(qmap_enqueue, struct task_struct *p, u64 enq_flags)
}

/* see lowpri_timerfn() */
- if (__COMPAT_has_generic_reenq() &&
- p->scx.weight < 2 && !(p->flags & PF_KTHREAD) && !(enq_flags & SCX_ENQ_REENQ)) {
+ if (p->scx.weight < 2 && !(p->flags & PF_KTHREAD) && !(enq_flags & SCX_ENQ_REENQ)) {
scx_bpf_dsq_insert(p, LOWPRI_DSQ, slice_ns, enq_flags);
return;
}

/* if select_cid() wasn't called, try direct dispatch */
- if (!__COMPAT_is_enq_cpu_selected(enq_flags) &&
+ if (!(enq_flags & SCX_ENQ_CPU_SELECTED) &&
(cid = pick_direct_dispatch_cid(p, scx_bpf_task_cid(p), taskc)) >= 0) {
__sync_fetch_and_add(&qa.nr_ddsp_from_enq, 1);
scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL_ON | cid, slice_ns,
@@ -1316,7 +1319,7 @@ static int monitor_timerfn(void *map, int *key, struct bpf_timer *timer)

dump_shared_dsq();

- __COMPAT_scx_bpf_events(&events, sizeof(events));
+ scx_bpf_events(&events, sizeof(events));

bpf_printk("%35s: %lld", "SCX_EV_SELECT_CPU_FALLBACK",
scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK));
@@ -2097,17 +2100,15 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(qmap_init)
if (ret)
return ret;

- if (__COMPAT_has_generic_reenq()) {
- /* see lowpri_timerfn() */
- timer = bpf_map_lookup_elem(&lowpri_timer, &key);
- if (!timer)
- return -ESRCH;
- bpf_timer_init(timer, &lowpri_timer, CLOCK_MONOTONIC);
- bpf_timer_set_callback(timer, lowpri_timerfn);
- ret = bpf_timer_start(timer, LOWPRI_INTV_NS, 0);
- if (ret)
- return ret;
- }
+ /* see lowpri_timerfn() */
+ timer = bpf_map_lookup_elem(&lowpri_timer, &key);
+ if (!timer)
+ return -ESRCH;
+ bpf_timer_init(timer, &lowpri_timer, CLOCK_MONOTONIC);
+ bpf_timer_set_callback(timer, lowpri_timerfn);
+ ret = bpf_timer_start(timer, LOWPRI_INTV_NS, 0);
+ if (ret)
+ return ret;

/* sub-sched: drive the boundary-cid round-robin from a bpf timer */
timer = bpf_map_lookup_elem(&round_robin_timer, &key);
diff --git a/tools/sched_ext/scx_qmap.c b/tools/sched_ext/scx_qmap.c
index 17cf584a2a3d..9b1cbe187ebd 100644
--- a/tools/sched_ext/scx_qmap.c
+++ b/tools/sched_ext/scx_qmap.c
@@ -294,7 +294,7 @@ int main(int argc, char **argv)
optind = 1;
skel = SCX_OPS_CID_OPEN(qmap_ops, scx_qmap);

- skel->rodata->slice_ns = __COMPAT_ENUM_OR_ZERO("scx_public_consts", "SCX_SLICE_DFL");
+ skel->rodata->slice_ns = skel->rodata->__SCX_SLICE_DFL;
skel->rodata->max_tasks = 16384;

while ((opt = getopt(argc, argv,
@@ -512,14 +512,10 @@ int main(int argc, char **argv)
(unsigned long long)qa->nr_expedited_remote,
(unsigned long long)qa->nr_expedited_from_timer,
(unsigned long long)qa->nr_expedited_lost);
- if (__COMPAT_has_ksym("scx_bpf_cidperf_cur"))
- printf("cpuperf: cur min/avg/max=%u/%u/%u target min/avg/max=%u/%u/%u\n",
- qa->cpuperf_min,
- qa->cpuperf_avg,
- qa->cpuperf_max,
- qa->cpuperf_target_min,
- qa->cpuperf_target_avg,
- qa->cpuperf_target_max);
+ printf("cpuperf: cur min/avg/max=%u/%u/%u target min/avg/max=%u/%u/%u\n",
+ qa->cpuperf_min, qa->cpuperf_avg, qa->cpuperf_max,
+ qa->cpuperf_target_min, qa->cpuperf_target_avg,
+ qa->cpuperf_target_max);

invoke_flush_alloc(skel);
print_hier(qa, &hprev, own_cgid);
--
2.56.0