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

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>
---
 tools/sched_ext/include/scx/compat.h | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h
index d2e4384df..f8c9bf657 100644
--- a/tools/sched_ext/include/scx/compat.h
+++ b/tools/sched_ext/include/scx/compat.h
@@ -177,23 +177,25 @@ 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_SKEL(__ops_name, __scx_name, __ops_struct,		\
+			    __open_expr) ({					\
 	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 = (__open_expr);						\
 	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(__ops_name, __scx_name, __open_expr) ({			\
 	struct __scx_name *__skel;						\
 										\
-	__skel = __SCX_OPS_OPEN(__ops_name, __scx_name, "sched_ext_ops");	\
+	__skel = __SCX_OPS_OPEN_SKEL(__ops_name, __scx_name,			\
+				     "sched_ext_ops", __open_expr);		\
 	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 +234,20 @@ static inline long scx_hotplug_seq(void)
 	__skel; 								\
 })
 
+#define SCX_OPS_OPEN(__ops_name, __scx_name)					\
+	__SCX_OPS_OPEN(__ops_name, __scx_name, __scx_name##__open())
+
+#define SCX_OPS_OPEN_OPTS(__ops_name, __scx_name, __opts)			\
+	__SCX_OPS_OPEN(__ops_name, __scx_name,					\
+		       __scx_name##__open_opts(__opts))
+
 /*
  * 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_SKEL(__ops_name, __scx_name,				\
+			    "sched_ext_ops_cid", __scx_name##__open())
 
 /*
  * 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

* Re: [PATCH] tools/sched_ext: Add SCX_OPS_OPEN_OPTS for schedulers using open opts
  2026-09-22  3:16 [PATCH] tools/sched_ext: Add SCX_OPS_OPEN_OPTS for schedulers using open opts Fuyu Zhao
@ 2026-09-22 15:56 ` Tejun Heo
  2026-09-23  3:35   ` Fuyu Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2026-09-22 15:56 UTC (permalink / raw)
  To: Fuyu Zhao; +Cc: void, arighi, changwoo, sched-ext, linux-kernel

Hello,

On Tue, Sep 22, 2026 at 11:16:18AM +0800, Fuyu Zhao wrote:
> +#define SCX_OPS_OPEN_OPTS(__ops_name, __scx_name, __opts)			\
> +	__SCX_OPS_OPEN(__ops_name, __scx_name,					\
> +		       __scx_name##__open_opts(__opts))

Can SCX_OPS_OPEN() just call SCX_OPS_OPEN_OPTS() with 0 as opts?

Thanks.

-- 
tejun

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

* Re: [PATCH] tools/sched_ext: Add SCX_OPS_OPEN_OPTS for schedulers using open opts
  2026-09-22 15:56 ` Tejun Heo
@ 2026-09-23  3:35   ` Fuyu Zhao
  0 siblings, 0 replies; 3+ messages in thread
From: Fuyu Zhao @ 2026-09-23  3:35 UTC (permalink / raw)
  To: Tejun Heo; +Cc: void, arighi, changwoo, sched-ext, linux-kernel



On 9/22/2026 11:56 PM, Tejun Heo wrote:
> Hello,
> 
> On Tue, Sep 22, 2026 at 11:16:18AM +0800, Fuyu Zhao wrote:
>> +#define SCX_OPS_OPEN_OPTS(__ops_name, __scx_name, __opts)			\
>> +	__SCX_OPS_OPEN(__ops_name, __scx_name,					\
>> +		       __scx_name##__open_opts(__opts))
> 
> Can SCX_OPS_OPEN() just call SCX_OPS_OPEN_OPTS() with 0 as opts?
> 
> Thanks.
> 
Yes, that makes sense. I'll update the patch accordingly.

Thanks,
Fuyu


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

end of thread, other threads:[~2026-09-23  3:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22  3:16 [PATCH] tools/sched_ext: Add SCX_OPS_OPEN_OPTS for schedulers using open opts Fuyu Zhao
2026-09-22 15:56 ` Tejun Heo
2026-09-23  3:35   ` Fuyu Zhao

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®