Sched_ext development
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: sched-ext@lists.linux.dev
Cc: David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	Changwoo Min <changwoo@igalia.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	David Dai <david.dai@linux.dev>,
	linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 1/2] sched_ext: scx_qmap: Drop the compat code
Date: Mon, 19 Oct 2026 11:32:20 -1000	[thread overview]
Message-ID: <20261019213221.2919481-2-tj@kernel.org> (raw)
In-Reply-To: <20261019213221.2919481-1-tj@kernel.org>

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@kernel.org>
---
 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


  reply	other threads:[~2026-10-19 21:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 21:32 [PATCHSET sched_ext/for-7.5] sched_ext: scx_qmap: Drop the compat code and fix a lowpri starvation Tejun Heo
2026-10-19 21:32 ` Tejun Heo [this message]
2026-10-19 21:32 ` [PATCH 2/2] sched_ext: scx_qmap: Queue re-enqueued lowpri tasks on their FIFO Tejun Heo
2026-10-19 22:00 ` [PATCHSET sched_ext/for-7.5] sched_ext: scx_qmap: Drop the compat code and fix a lowpri starvation Andrea Righi
2026-10-19 22:03   ` Andrea Righi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019213221.2919481-2-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=david.dai@linux.dev \
    --cc=emil@etsalapatis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox