BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Ihor Solodrai <ihor.solodrai@pm.me>,
	bpf@vger.kernel.org, andrii@kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, mykolal@fb.com
Subject: Re: [PATCH bpf-next] libbpf: change log level of BTF loading error message
Date: Wed, 18 Sep 2024 14:03:55 -0700	[thread overview]
Message-ID: <a63ec24f6a54173d29a7b88ef679b2aa942d606a.camel@gmail.com> (raw)
In-Reply-To: <20240918193319.1165526-1-ihor.solodrai@pm.me>

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@kernel.org>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
> ---

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.


  reply	other threads:[~2024-09-18 21:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18 19:33 [PATCH bpf-next] libbpf: change log level of BTF loading error message Ihor Solodrai
2024-09-18 21:03 ` Eduard Zingerman [this message]
2024-09-18 21:45   ` Ihor Solodrai
2024-09-19  4:25   ` Andrii Nakryiko
2024-09-19  4:32     ` Eduard Zingerman
2024-09-25 10:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a63ec24f6a54173d29a7b88ef679b2aa942d606a.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=ihor.solodrai@pm.me \
    --cc=mykolal@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox