tools/sched_ext/include/scx/compat.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Add SCX_OPS_OPEN_OPTS() to allow sched_ext schedulers to pass
bpf_object_open_opts when opening BPF skeletons.
Using the *_open_opts() interface generated by bpftool directly would
bypass the compatibility checks performed by SCX_OPS_OPEN(). Use
SCX_OPS_OPEN_OPTS() instead to pass open opts while retaining the
existing compatibility handling.
Signed-off-by: Fuyu Zhao <zhaofuyu@vivo.com>
---
v2:
- Make SCX_OPS_OPEN() call SCX_OPS_OPEN_OPTS() with 0 as the opts
argument (Tejun).
v1:
- Link: https://lore.kernel.org/sched-ext/20260922031618.2858-1-zhaofuyu@vivo.com/
---
tools/sched_ext/include/scx/compat.h | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h
index d2e4384df..bd471c51f 100644
--- a/tools/sched_ext/include/scx/compat.h
+++ b/tools/sched_ext/include/scx/compat.h
@@ -177,23 +177,23 @@ static inline long scx_hotplug_seq(void)
* - v7.1: ops.sub_attach(), ops.sub_detach(), ops.sub_cgroup_id
* - v7.3: ops.rescue_bandwidth_ppt, ops.rescue_quantum_us
*/
-#define __SCX_OPS_OPEN(__ops_name, __scx_name, __ops_struct) ({ \
+#define __SCX_OPS_OPEN(__ops_name, __scx_name, __ops_struct, __opts) ({ \
struct __scx_name *__oskel; \
\
SCX_BUG_ON(!__COMPAT_struct_has_field(__ops_struct, "dump"), \
__ops_struct ".dump() missing, kernel too old?"); \
\
- __oskel = __scx_name##__open(); \
+ __oskel = __scx_name##__open_opts(__opts); \
SCX_BUG_ON(!__oskel, "Could not open " #__scx_name); \
__oskel->struct_ops.__ops_name->hotplug_seq = scx_hotplug_seq(); \
SCX_ENUM_INIT(__oskel); \
__oskel; \
})
-#define SCX_OPS_OPEN(__ops_name, __scx_name) ({ \
+#define SCX_OPS_OPEN_OPTS(__ops_name, __scx_name, __opts) ({ \
struct __scx_name *__skel; \
\
- __skel = __SCX_OPS_OPEN(__ops_name, __scx_name, "sched_ext_ops"); \
+ __skel = __SCX_OPS_OPEN(__ops_name, __scx_name, "sched_ext_ops", __opts); \
if (__skel->struct_ops.__ops_name->cgroup_set_bandwidth && \
!__COMPAT_struct_has_field("sched_ext_ops", "cgroup_set_bandwidth")) { \
fprintf(stderr, "WARNING: kernel doesn't support ops.cgroup_set_bandwidth()\n"); \
@@ -232,12 +232,15 @@ static inline long scx_hotplug_seq(void)
__skel; \
})
+#define SCX_OPS_OPEN(__ops_name, __scx_name) \
+ SCX_OPS_OPEN_OPTS(__ops_name, __scx_name, 0)
+
/*
* Open a cid-form (struct sched_ext_ops_cid) skeleton. The cid form postdates
* every op the load-time fix-ups above handle, so none of them apply.
*/
#define SCX_OPS_CID_OPEN(__ops_name, __scx_name) \
- __SCX_OPS_OPEN(__ops_name, __scx_name, "sched_ext_ops_cid")
+ __SCX_OPS_OPEN(__ops_name, __scx_name, "sched_ext_ops_cid", 0)
/*
* Associate non-struct_ops BPF programs with the scheduler's struct_ops map so
--
2.34.1
© 2016 - 2026 Red Hat, Inc.