diff options
| author | Changwoo Min <changwoo@igalia.com> | 2026-01-30 11:18:43 +0900 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-01-30 12:20:25 -0800 |
| commit | cd77618c418254b827f2a807b4c27b97088fdb52 (patch) | |
| tree | 92cf649933dd1040c55d66bf5b264359661d4597 /include | |
| parent | b18a761ca0f6ef7c07b0ae5cee28315a0c5478a8 (diff) | |
selftests/bpf: Make bpf get_preempt_count() work for v6.14+ kernels
Recent x86 kernels export __preempt_count as a ksym, while some old kernels
between v6.1 and v6.14 expose the preemption counter via
pcpu_hot.preempt_count. The existing selftest helper unconditionally
dereferenced __preempt_count, which breaks BPF program loading on such old
kernels.
Make the x86 preemption count lookup version-agnostic by:
- Marking __preempt_count and pcpu_hot as weak ksyms.
- Introducing a BTF-described pcpu_hot___local layout with
preserve_access_index.
- Selecting the appropriate access path at runtime using ksym availability
and bpf_ksym_exists() and bpf_core_field_exists().
This allows a single BPF binary to run correctly across kernel versions
(e.g., v6.18 vs. v6.13) without relying on compile-time version checks.
Signed-off-by: Changwoo Min <changwoo@igalia.com>
Link: https://lore.kernel.org/r/20260130021843.154885-1-changwoo@igalia.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions
