Skip to content

Commit b214b04

Browse files
arighihtejun
authored andcommitted
tools/sched_ext: Provide a compatible helper for scx_bpf_events()
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: 9865f31 ("sched_ext: Add scx_bpf_events() and scx_read_event() for BPF schedulers") Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 5ae5161 commit b214b04

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

tools/sched_ext/include/scx/compat.bpf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,15 @@ static inline bool __COMPAT_is_enq_cpu_selected(u64 enq_flags)
183183
bpf_ktime_get_ns())
184184

185185
/*
186+
* v6.15: Introduce event counters.
186187
*
188+
* Preserve the following macro until v6.17.
189+
*/
190+
#define __COMPAT_scx_bpf_events(events, size) \
191+
(bpf_ksym_exists(scx_bpf_events) ? \
192+
scx_bpf_events(events, size) : ({}))
193+
194+
/*
187195
* v6.15: Introduce NUMA-aware kfuncs to operate with per-node idle
188196
* cpumasks.
189197
*

tools/sched_ext/scx_qmap.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ static int monitor_timerfn(void *map, int *key, struct bpf_timer *timer)
774774
if (print_shared_dsq)
775775
dump_shared_dsq();
776776

777-
scx_bpf_events(&events, sizeof(events));
777+
__COMPAT_scx_bpf_events(&events, sizeof(events));
778778

779779
bpf_printk("%35s: %llu", "SCX_EV_SELECT_CPU_FALLBACK",
780780
scx_read_event(&events, SCX_EV_SELECT_CPU_FALLBACK));

0 commit comments

Comments
 (0)