Re: [PATCH sched_ext/for-7.1] tools/sched_ext: Add __COMPAT wrapper for scx_bpf_sub_dispatch()

Cheng-Yang Chou
2026-03-23T12:53:40Z

On Sun, Mar 22, 2026 at 10:12:29AM -1000, Tejun Heo wrote:
> Hello,
>
> Let's not use the __COMPAT prefix. I'd like to move toward making compat
> wrappers transparent so that schedulers don't need code changes for
> compatibility as much as reasonably possible.

I think this might be another good first issue for me to tackle next :-)
I'll keep the v2 patch focused only on the scx_bpf_sub_dispatch() change,
and then I can go on to take a look at refactoring the rest of these
__COMPAT wrappers.

>
> Instead, declare the kfunc with a ___compat suffix and provide a static
> inline wrapper with the original name, like scx_bpf_dsq_insert() does:
>
> 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;
> }
>
> See tools/sched_ext/include/scx/compat.bpf.h around line 326-342 for the
> full pattern.
>
> This way schedulers just call scx_bpf_sub_dispatch() directly and the
> compat layer handles everything. The no-op fallback (returning false) is
> fine here since without sub-sched support the dispatch path can't do
> anything useful anyway.

Got it.
I'll send a v2 patch implementing this approach.

--
Thanks,
Cheng-Yang