summaryrefslogtreecommitdiff
path: root/tools/sched_ext/include
diff options
context:
space:
mode:
authorAndrea Righi <arighi@nvidia.com>2026-03-22 07:35:46 +0100
committerTejun Heo <tj@kernel.org>2026-03-22 10:03:05 -1000
commitf03ffe53ab6ffc798ed8291090cebf19c6e5fa3b (patch)
tree29871de973a6456d1dfabf4e16e57da223f3279f /tools/sched_ext/include
parent63f500c32a37d490ec623a3130e488cdb9bd6cf7 (diff)
downloadlwn-f03ffe53ab6ffc798ed8291090cebf19c6e5fa3b.tar.gz
lwn-f03ffe53ab6ffc798ed8291090cebf19c6e5fa3b.zip
tools/sched_ext: Add compat handling for sub-scheduler ops
Extend SCX_OPS_OPEN() with compatibility handling for ops.sub_attach() and ops.sub_detach(), allowing scx C schedulers with sub-scheduler support to run on kernels both with and without its support. Cc: Cheng-Yang Chou <yphbchou0911@gmail.com> Fixes: ebeca1f930ea ("sched_ext: Introduce cgroup sub-sched support") Signed-off-by: Andrea Righi <arighi@nvidia.com> Reviewed-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'tools/sched_ext/include')
-rw-r--r--tools/sched_ext/include/scx/compat.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h
index 9e0c8f3161e8..039854c490d5 100644
--- a/tools/sched_ext/include/scx/compat.h
+++ b/tools/sched_ext/include/scx/compat.h
@@ -160,6 +160,7 @@ static inline long scx_hotplug_seq(void)
* COMPAT:
* - v6.17: ops.cgroup_set_bandwidth()
* - v6.19: ops.cgroup_set_idle()
+ * - v7.1: ops.sub_attach(), ops.sub_detach(), ops.sub_cgroup_id
*/
#define SCX_OPS_OPEN(__ops_name, __scx_name) ({ \
struct __scx_name *__skel; \
@@ -181,6 +182,21 @@ static inline long scx_hotplug_seq(void)
fprintf(stderr, "WARNING: kernel doesn't support ops.cgroup_set_idle()\n"); \
__skel->struct_ops.__ops_name->cgroup_set_idle = NULL; \
} \
+ if (__skel->struct_ops.__ops_name->sub_attach && \
+ !__COMPAT_struct_has_field("sched_ext_ops", "sub_attach")) { \
+ fprintf(stderr, "WARNING: kernel doesn't support ops.sub_attach()\n"); \
+ __skel->struct_ops.__ops_name->sub_attach = NULL; \
+ } \
+ if (__skel->struct_ops.__ops_name->sub_detach && \
+ !__COMPAT_struct_has_field("sched_ext_ops", "sub_detach")) { \
+ fprintf(stderr, "WARNING: kernel doesn't support ops.sub_detach()\n"); \
+ __skel->struct_ops.__ops_name->sub_detach = NULL; \
+ } \
+ if (__skel->struct_ops.__ops_name->sub_cgroup_id > 0 && \
+ !__COMPAT_struct_has_field("sched_ext_ops", "sub_cgroup_id")) { \
+ fprintf(stderr, "WARNING: kernel doesn't support ops.sub_cgroup_id\n"); \
+ __skel->struct_ops.__ops_name->sub_cgroup_id = 0; \
+ } \
__skel; \
})