Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: Change log level of BTF loading error message

Reduce log level of BTF loading error to INFO if BTF is not required.

Andrii says:

Nowadays the expectation is that the BPF program will have a valid
.BTF section, so even though .BTF is "optional", I think it's fine
to emit a warning for that case (any reasonably recent Clang will
produce valid BTF).

Ihor's patch is fixing the situation with an outdated host kernel
that doesn't understand BTF. libbpf will try to "upload" the
program's BTF, but if that fails and the BPF object doesn't use
any features that require having BTF uploaded, then it's just an
information message to the user, but otherwise can be ignored.

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Ihor Solodrai and committed by
Alexei Starovoitov
8b334d91 a1ec23b9

+5 -4
+5 -4
tools/lib/bpf/libbpf.c
··· 3581 3581 report: 3582 3582 if (err) { 3583 3583 btf_mandatory = kernel_needs_btf(obj); 3584 - pr_warn("Error loading .BTF into kernel: %d. %s\n", err, 3585 - btf_mandatory ? "BTF is mandatory, can't proceed." 3586 - : "BTF is optional, ignoring."); 3587 - if (!btf_mandatory) 3584 + if (btf_mandatory) { 3585 + pr_warn("Error loading .BTF into kernel: %d. BTF is mandatory, can't proceed.\n", err); 3586 + } else { 3587 + pr_info("Error loading .BTF into kernel: %d. BTF is optional, ignoring.\n", err); 3588 3588 err = 0; 3589 + } 3589 3590 } 3590 3591 return err; 3591 3592 }