Skip to content

Add diagnostics for kfunc registration failures and jit subtest skips

Wang Yibo bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3bpf: report kfunc sets that fail BTF sanity checkkernel/bpf/btf.c+5 -10 replies
2/3selftests/bpf: name the failing registration in bpf_testmod_inittools/testing/selftests/bpf/test_kmods/bpf_testmod.c+25 -161 reply
3/3selftests/bpf: say how to fix the missing LLVM skip for jited checkstools/testing/selftests/bpf/jit_disasm_helpers.c tools/testing/selftests/bpf/test_loader.c+2 -20 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH bpf-next 0/3] Add diagnostics for kfunc registration failures and jit subtest skips

While testing the unwind_goto series on arm64 I ran into two places where a failure is reported without any information about what went wrong, and each took a while to track down. These three patches add the diagnostics that would have saved that time.

Patch 1: when a kfunc in a registered set has no proper FUNC entry in the BTF of the registering object, register_btf_kfunc_id_set() returns -EINVAL and nothing is printed. With bpf_testmod built by pahole 1.30 the module fails to load with -22 and dmesg stays empty; the only hint is a resolve_btfids warning buried in the build log. Log the offending id, the owner of the BTF and the error code.

Patch 2: bpf_testmod_init() chains twelve registrations with "ret = ret ?:", so when one of them fails there is no way to tell which call it was without instrumenting the module. Print the failing expression.

Patch 3: when test_progs is built without LLVM development libraries, every subtest that checks jited output skips with a message that is only visible under -v and does not say what to do about it. Point at the fix, and add a missing newline in the verbose-only fallback message.

One observation from building both architectures: with CONFIG_WERROR=y (the x86_64 defconfig default) resolve_btfids runs with --fatal_warnings, so the stale-pahole case fails the module build outright instead of producing a module that fails at load time. Patches 1 and 2 only help the WERROR=n path, which is what we run in our arm64 CI.

Verified on arm64 (KVM guest) and x86_64 (TCG guest) against bpf-next master b71326388a: with the patched kernel a pahole-1.30-built bpf_testmod still fails to load, but dmesg now says which kfunc and which registration failed; with pahole 1.32 it loads cleanly, and the unwind selftests still pass 42/42.

Wang Yibo (3):
bpf: report kfunc sets that fail BTF sanity check selftests/bpf: name the failing registration in bpf_testmod_init selftests/bpf: say how to fix the missing LLVM skip for jited checks

 kernel/bpf/btf.c                              |  6 ++-
 .../selftests/bpf/jit_disasm_helpers.c        |  2 +-
 .../selftests/bpf/test_kmods/bpf_testmod.c    | 41 +++++++++++--------
 tools/testing/selftests/bpf/test_loader.c     |  2 +-
 4 files changed, 32 insertions(+), 19 deletions(-)
Signature · 1 line
2.51.0