public inbox for sched-ext@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2 sched_ext/for-7.1] sched_ext: Add scx_bpf_sub_dispatch() compat wrapper
@ 2026-03-23 14:37 Cheng-Yang Chou
  2026-03-23 15:17 ` [PATCH v3 sched_ext/for-7.1] tools/sched_ext: " Cheng-Yang Chou
  0 siblings, 1 reply; 3+ messages in thread
From: Cheng-Yang Chou @ 2026-03-23 14:37 UTC (permalink / raw)
  To: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, yphbchou0911

Add a transparent compatibility wrapper for the scx_bpf_sub_dispatch()
kfunc in compat.bpf.h. This allows BPF schedulers using the sub-sched
dispatch feature to build and run on older kernels that lack the kfunc.

To avoid requiring code changes in individual schedulers, the
transparent wrapper pattern is used instead of a __COMPAT prefix. The
kfunc is declared with a ___compat suffix, while the static inline
wrapper retains the original scx_bpf_sub_dispatch() name.

When the kfunc is unavailable, the wrapper safely falls back to
returning false. This is acceptable because the dispatch path cannot
do anything useful without underlying sub-sched support anyway.

Tested scx_qmap on v6.14 successfully.

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
Changes in v2:
- Adopt the transparent wrapper pattern with a ___compat suffix instead
  of the __COMPAT_ prefix. (Tejun Heo)
- Keep the original scx_bpf_sub_dispatch() name for the wrapper,
  removing the need to modify tools/sched_ext/scx_qmap.bpf.c.
- Remove the #ifdef CONFIG_EXT_SUB_SCHED guard since bpf_ksym_exists()
  cleanly handles the fallback. (Andrea Righi)
- Link to v1:
  https://lore.kernel.org/r/20260322144433.1649092-1-yphbchou0911@gmail.com/

 tools/sched_ext/include/scx/common.bpf.h |  1 -
 tools/sched_ext/include/scx/compat.bpf.h | 13 +++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
index a63a98a96b86..19459dedde41 100644
--- a/tools/sched_ext/include/scx/common.bpf.h
+++ b/tools/sched_ext/include/scx/common.bpf.h
@@ -101,7 +101,6 @@ struct rq *scx_bpf_locked_rq(void) __ksym;
 struct task_struct *scx_bpf_cpu_curr(s32 cpu) __ksym __weak;
 u64 scx_bpf_now(void) __ksym __weak;
 void scx_bpf_events(struct scx_event_stats *events, size_t events__sz) __ksym __weak;
-bool scx_bpf_sub_dispatch(u64 cgroup_id) __ksym __weak;
 
 /*
  * Use the following as @it__iter when calling scx_bpf_dsq_move[_vtime]() from
diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
index 83b3425e63b2..654b566bd94a 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.
+ */
+bool scx_bpf_sub_dispatch___compat(u64 cgroup_id) __ksym __weak;
+
+static inline bool scx_bpf_sub_dispatch(u64 cgroup_id)
+{
+	if (bpf_ksym_exists(scx_bpf_sub_dispatch___compat))
+		return scx_bpf_sub_dispatch___compat(cgroup_id);
+	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.
-- 
2.48.1


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

* [PATCH v3 sched_ext/for-7.1] tools/sched_ext: Add scx_bpf_sub_dispatch() compat wrapper
  2026-03-23 14:37 [PATCH v2 sched_ext/for-7.1] sched_ext: Add scx_bpf_sub_dispatch() compat wrapper Cheng-Yang Chou
@ 2026-03-23 15:17 ` Cheng-Yang Chou
  2026-03-23 17:49   ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Cheng-Yang Chou @ 2026-03-23 15:17 UTC (permalink / raw)
  To: yphbchou0911; +Cc: arighi, changwoo, chia7712, jserv, sched-ext, tj, void

Add a transparent compatibility wrapper for the scx_bpf_sub_dispatch()
kfunc in compat.bpf.h. This allows BPF schedulers using the sub-sched
dispatch feature to build and run on older kernels that lack the kfunc.

To avoid requiring code changes in individual schedulers, the
transparent wrapper pattern is used instead of a __COMPAT prefix. The
kfunc is declared with a ___compat suffix, while the static inline
wrapper retains the original scx_bpf_sub_dispatch() name.

When the kfunc is unavailable, the wrapper safely falls back to
returning false. This is acceptable because the dispatch path cannot
do anything useful without underlying sub-sched support anyway.

Tested scx_qmap on v6.14 successfully.

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
Changes in v3:
- Rename subject prefix from sched_ext to tools/sched_ext
- Link to v2:
  https://lore.kernel.org/r/20260323143757.4149146-1-yphbchou0911@gmail.com/

Changes in v2:
- Adopt the transparent wrapper pattern with a ___compat suffix instead
  of the __COMPAT_ prefix. (Tejun Heo)
- Keep the original scx_bpf_sub_dispatch() name for the wrapper,
  removing the need to modify tools/sched_ext/scx_qmap.bpf.c.
- Remove the #ifdef CONFIG_EXT_SUB_SCHED guard since bpf_ksym_exists()
  cleanly handles the fallback. (Andrea Righi)
- Link to v1:
  https://lore.kernel.org/r/20260322144433.1649092-1-yphbchou0911@gmail.com/

 tools/sched_ext/include/scx/common.bpf.h |  1 -
 tools/sched_ext/include/scx/compat.bpf.h | 13 +++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
index a63a98a96b86..19459dedde41 100644
--- a/tools/sched_ext/include/scx/common.bpf.h
+++ b/tools/sched_ext/include/scx/common.bpf.h
@@ -101,7 +101,6 @@ struct rq *scx_bpf_locked_rq(void) __ksym;
 struct task_struct *scx_bpf_cpu_curr(s32 cpu) __ksym __weak;
 u64 scx_bpf_now(void) __ksym __weak;
 void scx_bpf_events(struct scx_event_stats *events, size_t events__sz) __ksym __weak;
-bool scx_bpf_sub_dispatch(u64 cgroup_id) __ksym __weak;
 
 /*
  * Use the following as @it__iter when calling scx_bpf_dsq_move[_vtime]() from
diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
index 83b3425e63b2..654b566bd94a 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.
+ */
+bool scx_bpf_sub_dispatch___compat(u64 cgroup_id) __ksym __weak;
+
+static inline bool scx_bpf_sub_dispatch(u64 cgroup_id)
+{
+	if (bpf_ksym_exists(scx_bpf_sub_dispatch___compat))
+		return scx_bpf_sub_dispatch___compat(cgroup_id);
+	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.
-- 
2.48.1


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

* Re: [PATCH v3 sched_ext/for-7.1] tools/sched_ext: Add scx_bpf_sub_dispatch() compat wrapper
  2026-03-23 15:17 ` [PATCH v3 sched_ext/for-7.1] tools/sched_ext: " Cheng-Yang Chou
@ 2026-03-23 17:49   ` Tejun Heo
  0 siblings, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2026-03-23 17:49 UTC (permalink / raw)
  To: Cheng-Yang Chou
  Cc: sched-ext, David Vernet, Andrea Righi, Changwoo Min,
	Ching-Chun Huang, Chia-Ping Tsai

Applied to sched_ext/for-7.1.

Thanks.

--
tejun

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 14:37 [PATCH v2 sched_ext/for-7.1] sched_ext: Add scx_bpf_sub_dispatch() compat wrapper Cheng-Yang Chou
2026-03-23 15:17 ` [PATCH v3 sched_ext/for-7.1] tools/sched_ext: " Cheng-Yang Chou
2026-03-23 17:49   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox