Skip to content

bpf: Fix a couple of test failures with LTO kernel

Yonghong Song bpf 3 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 0 repliesApplied 8/8
  2. v25 patches 24 repliesSuperseded
  3. v14 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- no need to check config file, directly so strstr with '.llvm.'.
- for kprobe_multi_bench with syms, instead of skipping the syms, consult /proc/kallyms to find corresponding names.
- add a test with populating addrs to the kernel for kprobe multi attach.

Patches in v3 All 8 applied

#Subject and filesSizeRepliesApplied
1/8selftests/bpf: Replace CHECK with ASSERT macros for ksyms testtools/testing/selftests/bpf/prog_tests/ksyms.c+11 -190 repliesApplied
2/8libbpf: Mark libbpf_kallsyms_parse static functiontools/lib/bpf/libbpf.c tools/lib/bpf/libbpf_internal.h+4 -60 repliesApplied
3/8libbpf: Handle <orig_name>.llvm.<hash> symbol properlytools/lib/bpf/libbpf.c+20 -10 repliesApplied
4/8selftests/bpf: Refactor some functions for kprobe_multi_testtools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c+57 -370 repliesApplied
5/8selftests/bpf: Refactor trace helper func load_kallsyms_local()tools/testing/selftests/bpf/trace_helpers.c tools/testing/selftests/bpf/trace_helpers.h+14 -70 repliesApplied
6/8selftests/bpf: Add {load,search}_kallsyms_custom_local()tools/testing/selftests/bpf/trace_helpers.c tools/testing/selftests/bpf/trace_helpers.h+32 -00 repliesApplied
7/8selftests/bpf: Fix kprobe_multi_bench_attach test failure with LTO kerneltools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c+48 -140 repliesApplied
8/8selftests/bpf: Add a kprobe_multi subtest to use addrs instead of symstools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c+98 -00 repliesApplied

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/8] bpf: Fix a couple of test failures with LTO kernel

With a LTO kernel built with clang, with one of earlier version of kernel, I encountered two test failures, ksyms and kprobe_multi_bench_attach/kernel. Now with latest bpf-next, only kprobe_multi_bench_attach/kernel failed. But it is possible in the future ksyms selftest may fail again.

Both test failures are due to static variable/function renaming due to cross-file inlining. For Ksyms failure, the solution is to strip .llvm.<hash> suffixes for symbols in /proc/kallsyms before comparing against the ksym in bpf program.
For kprobe_multi_bench_attach/kernel failure, the solution is to either provide names in /proc/kallsyms to the kernel or ignore those names who have .llvm.<hash> suffix since the kernel sym name comparison is against /proc/kallsyms.

Please see each individual patches for details.

Changelogs:
v2 -> v3:
- no need to check config file, directly so strstr with '.llvm.'.
- for kprobe_multi_bench with syms, instead of skipping the syms, consult /proc/kallyms to find corresponding names.
- add a test with populating addrs to the kernel for kprobe multi attach.
v1 -> v2:
- Let libbpf handle .llvm.<hash suffixes since it may impact bpf program ksym.

Yonghong Song (8):
selftests/bpf: Replace CHECK with ASSERT macros for ksyms test
libbpf: Mark libbpf_kallsyms_parse static function
libbpf: Handle <orig_name>.llvm.<hash> symbol properly selftests/bpf: Refactor some functions for kprobe_multi_test selftests/bpf: Refactor trace helper func load_kallsyms_local() selftests/bpf: Add {load,search}_kallsyms_custom_local() selftests/bpf: Fix kprobe_multi_bench_attach test failure with LTO
kernel
selftests/bpf: Add a kprobe_multi subtest to use addrs instead of syms

 tools/lib/bpf/libbpf.c                        |  26 +-
 tools/lib/bpf/libbpf_internal.h               |   5 -
 .../bpf/prog_tests/kprobe_multi_test.c        | 248 ++++++++++++++----
 .../testing/selftests/bpf/prog_tests/ksyms.c  |  30 +--
 tools/testing/selftests/bpf/trace_helpers.c   |  46 +++-
 tools/testing/selftests/bpf/trace_helpers.h   |   7 +
 6 files changed, 281 insertions(+), 81 deletions(-)
Signature · 1 line
2.43.0