From: Andrea Righi <arighi@nvidia.com>
To: Cheng-Yang Chou <yphbchou0911@gmail.com>
Cc: sched-ext@lists.linux.dev, Tejun Heo <tj@kernel.org>,
David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>,
Ching-Chun Huang <jserv@ccns.ncku.edu.tw>,
Chia-Ping Tsai <chia7712@gmail.com>
Subject: Re: [PATCH sched_ext/for-7.1] tools/sched_ext: Add __COMPAT wrapper for scx_bpf_sub_dispatch()
Date: Mon, 23 Mar 2026 08:51:28 +0100 [thread overview]
Message-ID: <acDxAON9TXIZDems@gpd4> (raw)
In-Reply-To: <20260322144433.1649092-1-yphbchou0911@gmail.com>
Hi Cheng-Yang,
On Sun, Mar 22, 2026 at 10:44:23PM +0800, Cheng-Yang Chou wrote:
> 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
Isn't bpf_ksym_exists() enough? The CONFIG_EXT_SUB_SCHED guard takes effect
only when we build an scx scheduler using __COMPAT_scx_bpf_sub_dispatch(),
instead we want to build the scheduler anywhere and then the BPF verifier
should evaluate the availability of scx_bpf_sub_dispatch().
Then the symbol will be resolved by this (from include/scx/common.bpf.h):
bool scx_bpf_sub_dispatch(u64 cgroup_id) __ksym __weak;
So, IIUC the #ifdef CONFIG_EXT_SUB_SCHED guard is not really needed here.
Thanks,
-Andrea
> + 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
>
next prev parent reply other threads:[~2026-03-23 7:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-03-23 12:46 ` Cheng-Yang Chou
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=acDxAON9TXIZDems@gpd4 \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=chia7712@gmail.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=void@manifault.com \
--cc=yphbchou0911@gmail.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 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.