Re: [PATCH bpf-next] libbpf: change log level of BTF loading error message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 18, 2024 at 11:04 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> On Wed, 2024-09-18 at 19:33 +0000, Ihor Solodrai wrote:
> > Reduce log level of BTF loading error to INFO if BTF is not required.
> >
> > Suggested-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> > Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx>
> > ---
>
> fwiw, I took verifier_bswap.bpf.o and replaced .BTF section with empty
> one inside it:
>
>     for s in .BTF .rel.BTF .BTF.ext .rel.BTF.ext; do objcopy --remove-section $s verifier_bswap.bpf.o; done
>     touch empty
>     objcopy --add-section .BTF=empty verifier_bswap.bpf.o
>
> And modified veristat to show log level for libbpf messages:
>
> --- a/tools/testing/selftests/bpf/veristat.c
> +++ b/tools/testing/selftests/bpf/veristat.c
> @@ -187,6 +187,7 @@ static int libbpf_print_fn(enum libbpf_print_level level, const char *format, va
>                 return 0;
>         if (level == LIBBPF_DEBUG  && !env.debug)
>                 return 0;
> +       fprintf(stderr, "%d: ", level);
>         return vfprintf(stderr, format, args);
>  }
>
> And here is the output for veristat loading modified verifier_bswap.bpf.o:
>
>     ./veristat -d /home/eddy/work/tmp/verifier_bswap.bpf.o  -f bswap_16
>     PROCESSING /home/eddy/work/tmp/verifier_bswap.bpf.o/bswap_16, DURATION US: 26, VERDICT: success, VERIFIER LOG:
>     verification time 26 usec
>     stack depth 0
>     processed 3 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
>     2: libbpf: loading object from /home/eddy/work/tmp/verifier_bswap.bpf.o
>     2: libbpf: elf: section(2) socket, size 80, link 0, flags 6, type=1
>     2: libbpf: sec 'socket': found program 'bswap_16' at insn offset 0 (0 bytes), code size 3 insns (24 bytes)
>     2: libbpf: sec 'socket': found program 'bswap_32' at insn offset 3 (24 bytes), code size 3 insns (24 bytes)
>     2: libbpf: sec 'socket': found program 'bswap_64' at insn offset 6 (48 bytes), code size 4 insns (32 bytes)
>     2: libbpf: elf: section(3) license, size 4, link 0, flags 3, type=1
>     2: libbpf: license of /home/eddy/work/tmp/verifier_bswap.bpf.o is GPL
>     2: libbpf: elf: section(18) .BTF, size 0, link 0, flags 0, type=1
>     2: libbpf: elf: section(19) .symtab, size 336, link 20, flags 0, type=2
>     2: libbpf: BTF header not found
>     0: libbpf: Error loading ELF section .BTF: -22.
>     ...
>
> Note the log level is 0 which corresponds to LIBBPF_WARN.
> So, if the goal is to move all optional invalid BTF messages to info
> level there are probably a few more places to modify.
>

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.

tl;dr, I think Ihor's patch is fine and sufficient. bpf-next is
closed, will apply when it reopens.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux