mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] tools/sched_ext: Add SCX_OPS_OPEN_OPTS for schedulers using open opts
@ 2026-09-28  3:09 Fuyu Zhao
  2026-09-28  6:26 ` Andrea Righi
  2026-09-28 17:26 ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Fuyu Zhao @ 2026-09-28  3:09 UTC (permalink / raw)
  To: tj; +Cc: void, arighi, changwoo, sched-ext, linux-kernel, Fuyu Zhao

Add SCX_OPS_OPEN_OPTS() and SCX_OPS_CID_OPEN_OPTS() to allow sched_ext
schedulers to pass bpf_object_open_opts when opening BPF skeletons.

This allows sched_ext schedulers using open opts to retain the existing
compatibility handling instead of bypassing it.

Signed-off-by: Fuyu Zhao <zhaofuyu@vivo.com>
---
v3:
- Add SCX_OPS_CID_OPEN_OPTS() to support open opts for
  SCX_OPS_CID_OPEN() (Tejun).

v2:
- Link: https://lore.kernel.org/sched-ext/20260923035613.20099-1-zhaofuyu@vivo.com/
- 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 | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h
index d2e4384df..3ae6e0ef1 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,18 @@ 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_OPTS(__ops_name, __scx_name, __opts)			\
+	__SCX_OPS_OPEN(__ops_name, __scx_name, "sched_ext_ops_cid", __opts)
+
 #define SCX_OPS_CID_OPEN(__ops_name, __scx_name)				\
-	__SCX_OPS_OPEN(__ops_name, __scx_name, "sched_ext_ops_cid")
+	SCX_OPS_CID_OPEN_OPTS(__ops_name, __scx_name, 0)
 
 /*
  * Associate non-struct_ops BPF programs with the scheduler's struct_ops map so
-- 
2.34.1


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

end of thread, other threads:[~2026-09-28 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28  3:09 [PATCH v3] tools/sched_ext: Add SCX_OPS_OPEN_OPTS for schedulers using open opts Fuyu Zhao
2026-09-28  6:26 ` Andrea Righi
2026-09-28 17:26 ` Tejun Heo

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

all inboxes | Powered by JetHome®