All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH sched_ext/for-7.1] tools/sched_ext: Add __COMPAT wrapper for scx_bpf_sub_dispatch()
@ 2026-03-22 14:44 Cheng-Yang Chou
  2026-03-22 20:12 ` Tejun Heo
  2026-03-23  7:51 ` Andrea Righi
  0 siblings, 2 replies; 5+ messages in thread
From: Cheng-Yang Chou @ 2026-03-22 14:44 UTC (permalink / raw)
  To: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, yphbchou0911

Add __COMPAT_scx_bpf_sub_dispatch() to compat.bpf.h so that schedulers
using sub-sched dispatch can build and run on older kernels that lack the
kfunc. Guard the call with CONFIG_EXT_SUB_SCHED and bpf_ksym_exists(),
falling back to false when unavailable.

Update scx_qmap to use the new wrapper instead of calling
scx_bpf_sub_dispatch() directly.

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
 tools/sched_ext/include/scx/compat.bpf.h | 13 +++++++++++++
 tools/sched_ext/scx_qmap.bpf.c           |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
index 83b3425e63b2..f24b9a1c75ad 100644
--- a/tools/sched_ext/include/scx/compat.bpf.h
+++ b/tools/sched_ext/include/scx/compat.bpf.h
@@ -108,6 +108,19 @@ static inline struct task_struct *__COMPAT_scx_bpf_dsq_peek(u64 dsq_id)
 	return p;
 }
 
+/*
+ * v7.1: scx_bpf_sub_dispatch() for sub-sched dispatch. Preserve until we drop
+ * the compat layer for older kernels that lack the kfunc.
+ */
+static inline bool __COMPAT_scx_bpf_sub_dispatch(u64 cgroup_id)
+{
+#ifdef CONFIG_EXT_SUB_SCHED
+	if (bpf_ksym_exists(scx_bpf_sub_dispatch))
+		return scx_bpf_sub_dispatch(cgroup_id);
+#endif
+	return false;
+}
+
 /**
  * __COMPAT_is_enq_cpu_selected - Test if SCX_ENQ_CPU_SELECTED is on
  * in a compatible way. We will preserve this __COMPAT helper until v6.16.
diff --git a/tools/sched_ext/scx_qmap.bpf.c b/tools/sched_ext/scx_qmap.bpf.c
index f3587fb709c9..dd44d8db0341 100644
--- a/tools/sched_ext/scx_qmap.bpf.c
+++ b/tools/sched_ext/scx_qmap.bpf.c
@@ -490,7 +490,7 @@ void BPF_STRUCT_OPS(qmap_dispatch, s32 cpu, struct task_struct *prev)
 
 	for (i = 0; i < MAX_SUB_SCHEDS; i++) {
 		if (sub_sched_cgroup_ids[i] &&
-		    scx_bpf_sub_dispatch(sub_sched_cgroup_ids[i]))
+		    __COMPAT_scx_bpf_sub_dispatch(sub_sched_cgroup_ids[i]))
 			return;
 	}
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-23 12:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-22 14:44 [PATCH sched_ext/for-7.1] tools/sched_ext: Add __COMPAT wrapper for scx_bpf_sub_dispatch() Cheng-Yang Chou
2026-03-22 20:12 ` Tejun Heo
2026-03-23 12:53   ` Cheng-Yang Chou
2026-03-23  7:51 ` Andrea Righi
2026-03-23 12:46   ` Cheng-Yang Chou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.