Skip to content

RFC Remove __COMPAT prefix from BPF compat wrappers

Cheng-Yang Chou sched-ext 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3tools/sched_ext: Remove __COMPAT prefix from compat.bpf.h wrapperstools/sched_ext/include/scx/common.bpf.h tools/sched_ext/include/scx/compat.bpf.h+83 -650 replies
2/3tools/sched_ext: Update scx_qmap to drop __COMPAT prefixtools/sched_ext/scx_qmap.bpf.c+4 -40 replies
3/3selftests/sched_ext: Update selftests to drop __COMPAT prefixtools/testing/selftests/sched_ext/dsq_reenq.bpf.c tools/testing/selftests/sched_ext/numa.bpf.c tools/testing/selftests/sched_ext/numa.c +1 more+16 -180 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCHSET sched_ext/for-7.1 0/3] Remove __COMPAT prefix from BPF compat wrappers

As suggested [1], move away from the __COMPAT prefix and make compat wrappers transparent so schedulers don't need code changes for compatibility.

Patch 1:
- converts the __COMPAT prefixed macros and helpers in compat.bpf.h to transparent static inline functions using the ___compat suffix pattern (so libbpf resolves them to the original kernel symbols), and removes the now-redundant __ksym __weak declarations from common.bpf.h.

Patch 2:
- updates scx_qmap to call the renamed helpers directly.

Patch 3:
- updates the selftests (dsq_reenq, peek_dsq, numa) likewise. One exception: peek_dsq has a debug path that explicitly checks bpf_ksym_exists() to record which code path is taken at runtime; since scx_bpf_dsq_peek is now a static inline, the check is updated to use bpf_ksym_exists(scx_bpf_dsq_peek___compat) directly.

scx_qmap and the selftest changes have been built and tested on both v7.0 (via vng) and a v6.14 kernel. On v6.14, dsq_reenq is skipped since scx_bpf_dsq_reenq() is not available; everything else looks fine.

One thing I'm not sure about: the "Preserve until vX.XX" comments attached to each compat block. With the old __COMPAT macros, the intent was clearly to drop the macro at that version. Now that the wrappers are transparent static inlines, I assume the plan is still to drop the wrapper and move the plain __ksym declaration back into common.bpf.h at that point (similar to how scx_bpf_dsq_insert was handled).

Please let me know if I should update them.

[1]: https://lore.kernel.org/r/[email protected]/

Thanks,
Cheng-Yang

---
Cheng-Yang Chou (3):
tools/sched_ext: Remove __COMPAT prefix from compat.bpf.h wrappers tools/sched_ext: Update scx_qmap to drop __COMPAT prefix selftests/sched_ext: Update selftests to drop __COMPAT prefix

 tools/sched_ext/include/scx/common.bpf.h      |  10 +-
 tools/sched_ext/include/scx/compat.bpf.h      | 140 +++++++++++-------
 tools/sched_ext/scx_qmap.bpf.c                |   8 +-
 .../selftests/sched_ext/dsq_reenq.bpf.c       |   2 +-
 tools/testing/selftests/sched_ext/numa.bpf.c  |  22 ++-
 tools/testing/selftests/sched_ext/numa.c      |   2 +-
 .../selftests/sched_ext/peek_dsq.bpf.c        |   8 +-
 7 files changed, 104 insertions(+), 88 deletions(-)
Signature · 1 line
2.48.1