* [PATCH sched_ext/for-6.15] tools/sched_ext: Provide a compatible helper for scx_bpf_events()
@ 2025-02-27 9:11 Andrea Righi
2025-02-27 10:27 ` Changwoo Min
2025-02-27 16:27 ` Tejun Heo
0 siblings, 2 replies; 3+ messages in thread
From: Andrea Righi @ 2025-02-27 9:11 UTC (permalink / raw)
To: Tejun Heo, David Vernet, Changwoo Min; +Cc: linux-kernel
Introduce __COMPAT_scx_bpf_events() to use scx_bpf_events() in a
compatible way also with kernels that don't provide this kfunc.
This also fixes the following error with scx_qmap when running on a
kernel that does not provide scx_bpf_events():
; scx_bpf_events(&events, sizeof(events)); @ scx_qmap.bpf.c:777
318: (b7) r2 = 72 ; R2_w=72 async_cb
319: <invalid kfunc call>
kfunc 'scx_bpf_events' is referenced but wasn't resolved
Fixes: 9865f31d852a4 ("sched_ext: Add scx_bpf_events() and scx_read_event() for BPF schedulers")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
tools/sched_ext/include/scx/compat.bpf.h | 8 ++++++++
tools/sched_ext/scx_qmap.bpf.c | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
index 266f94fe479b7..9252e1a00556f 100644
--- a/tools/sched_ext/include/scx/compat.bpf.h
+++ b/tools/sched_ext/include/scx/compat.bpf.h
@@ -183,7 +183,15 @@ static inline bool __COMPAT_is_enq_cpu_selected(u64 enq_flags)
bpf_ktime_get_ns())
/*
+ * v6.15: Introduce event counters.
*
+ * Preserve the following macro until v6.17.
+ */
+#define __COMPAT_scx_bpf_events(events, size) \
+ (bpf_ksym_exists(scx_bpf_events) ? \
+ scx_bpf_events(events, size) : ({}))
+
+/*
* v6.15: Introduce NUMA-aware kfuncs to operate with per-node idle
* cpumasks.
*
diff --git a/tools/sched_ext/scx_qmap.bpf.c b/tools/sched_ext/scx_qmap.bpf.c
index a6c6be308315a..45fd643d2ca0d 100644
--- a/tools/sched_ext/scx_qmap.bpf.c
+++ b/tools/sched_ext/scx_qmap.bpf.c
@@ -774,7 +774,7 @@ static int monitor_timerfn(void *map, int *key, struct bpf_timer *timer)
if (print_shared_dsq)
dump_shared_dsq();
- scx_bpf_events(&events, sizeof(events));
+ __COMPAT_scx_bpf_events(&events, sizeof(events));
bpf_printk("%35s: %llu", "SCX_EV_SELECT_CPU_FALLBACK",
scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK));
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH sched_ext/for-6.15] tools/sched_ext: Provide a compatible helper for scx_bpf_events()
2025-02-27 9:11 [PATCH sched_ext/for-6.15] tools/sched_ext: Provide a compatible helper for scx_bpf_events() Andrea Righi
@ 2025-02-27 10:27 ` Changwoo Min
2025-02-27 16:27 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Changwoo Min @ 2025-02-27 10:27 UTC (permalink / raw)
To: Andrea Righi, Tejun Heo, David Vernet; +Cc: linux-kernel
Hi Andrea,
On 25. 2. 27. 18:11, Andrea Righi wrote:
> Introduce __COMPAT_scx_bpf_events() to use scx_bpf_events() in a
> compatible way also with kernels that don't provide this kfunc.
>
> This also fixes the following error with scx_qmap when running on a
> kernel that does not provide scx_bpf_events():
>
> ; scx_bpf_events(&events, sizeof(events)); @ scx_qmap.bpf.c:777
> 318: (b7) r2 = 72 ; R2_w=72 async_cb
> 319: <invalid kfunc call>
> kfunc 'scx_bpf_events' is referenced but wasn't resolved
>
> Fixes: 9865f31d852a4 ("sched_ext: Add scx_bpf_events() and scx_read_event() for BPF schedulers")
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
> ---
> tools/sched_ext/include/scx/compat.bpf.h | 8 ++++++++
> tools/sched_ext/scx_qmap.bpf.c | 2 +-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
> index 266f94fe479b7..9252e1a00556f 100644
> --- a/tools/sched_ext/include/scx/compat.bpf.h
> +++ b/tools/sched_ext/include/scx/compat.bpf.h
> @@ -183,7 +183,15 @@ static inline bool __COMPAT_is_enq_cpu_selected(u64 enq_flags)
> bpf_ktime_get_ns())
>
> /*
> + * v6.15: Introduce event counters.
> *
> + * Preserve the following macro until v6.17.
> + */
> +#define __COMPAT_scx_bpf_events(events, size) \
> + (bpf_ksym_exists(scx_bpf_events) ? \
> + scx_bpf_events(events, size) : ({}))
> +
> +/*
> * v6.15: Introduce NUMA-aware kfuncs to operate with per-node idle
> * cpumasks.
> *
> diff --git a/tools/sched_ext/scx_qmap.bpf.c b/tools/sched_ext/scx_qmap.bpf.c
> index a6c6be308315a..45fd643d2ca0d 100644
> --- a/tools/sched_ext/scx_qmap.bpf.c
> +++ b/tools/sched_ext/scx_qmap.bpf.c
> @@ -774,7 +774,7 @@ static int monitor_timerfn(void *map, int *key, struct bpf_timer *timer)
> if (print_shared_dsq)
> dump_shared_dsq();
>
> - scx_bpf_events(&events, sizeof(events));
> + __COMPAT_scx_bpf_events(&events, sizeof(events));
>
> bpf_printk("%35s: %llu", "SCX_EV_SELECT_CPU_FALLBACK",
> scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK));
This is a nice catch. Looks good to me.
Thanks!
Changwoo Min
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH sched_ext/for-6.15] tools/sched_ext: Provide a compatible helper for scx_bpf_events()
2025-02-27 9:11 [PATCH sched_ext/for-6.15] tools/sched_ext: Provide a compatible helper for scx_bpf_events() Andrea Righi
2025-02-27 10:27 ` Changwoo Min
@ 2025-02-27 16:27 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2025-02-27 16:27 UTC (permalink / raw)
To: Andrea Righi; +Cc: David Vernet, Changwoo Min, linux-kernel
On Thu, Feb 27, 2025 at 10:11:38AM +0100, Andrea Righi wrote:
> Introduce __COMPAT_scx_bpf_events() to use scx_bpf_events() in a
> compatible way also with kernels that don't provide this kfunc.
>
> This also fixes the following error with scx_qmap when running on a
> kernel that does not provide scx_bpf_events():
>
> ; scx_bpf_events(&events, sizeof(events)); @ scx_qmap.bpf.c:777
> 318: (b7) r2 = 72 ; R2_w=72 async_cb
> 319: <invalid kfunc call>
> kfunc 'scx_bpf_events' is referenced but wasn't resolved
>
> Fixes: 9865f31d852a4 ("sched_ext: Add scx_bpf_events() and scx_read_event() for BPF schedulers")
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
Applied to sched_ext/for-6.15.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-27 16:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 9:11 [PATCH sched_ext/for-6.15] tools/sched_ext: Provide a compatible helper for scx_bpf_events() Andrea Righi
2025-02-27 10:27 ` Changwoo Min
2025-02-27 16:27 ` Tejun Heo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.