netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: add debug message for each created program
@ 2020-06-24  0:33 Andrii Nakryiko
  2020-06-24  6:47 ` Alexei Starovoitov
  0 siblings, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2020-06-24  0:33 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Similar message for map creation is extremely useful, so add similar for BPF
programs.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/libbpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 18461deb1b19..f24a90c86c58 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -5379,8 +5379,9 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
 	}
 
 	ret = bpf_load_program_xattr(&load_attr, log_buf, log_buf_size);
-
 	if (ret >= 0) {
+		pr_debug("prog '%s' ('%s'): created successfully, fd=%d\n",
+			 prog->name, prog->section_name, ret);
 		if (log_buf && load_attr.log_level)
 			pr_debug("verifier log:\n%s", log_buf);
 		*pfd = ret;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: add debug message for each created program
  2020-06-24  0:33 [PATCH bpf-next] libbpf: add debug message for each created program Andrii Nakryiko
@ 2020-06-24  6:47 ` Alexei Starovoitov
  2020-06-24  6:59   ` Andrii Nakryiko
  0 siblings, 1 reply; 7+ messages in thread
From: Alexei Starovoitov @ 2020-06-24  6:47 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: bpf, Network Development, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Kernel Team

On Tue, Jun 23, 2020 at 5:34 PM Andrii Nakryiko <andriin@fb.com> wrote:
>
> Similar message for map creation is extremely useful, so add similar for BPF
> programs.

'extremely useful' is quite subjective.
If we land this patch then everyone will be allowed to add pr_debug()
everywhere in libbpf with the same reasoning: "it's extremely useful pr_debug".

> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
>  tools/lib/bpf/libbpf.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 18461deb1b19..f24a90c86c58 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -5379,8 +5379,9 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
>         }
>
>         ret = bpf_load_program_xattr(&load_attr, log_buf, log_buf_size);
> -
>         if (ret >= 0) {
> +               pr_debug("prog '%s' ('%s'): created successfully, fd=%d\n",
> +                        prog->name, prog->section_name, ret);
>                 if (log_buf && load_attr.log_level)
>                         pr_debug("verifier log:\n%s", log_buf);
>                 *pfd = ret;
> --
> 2.24.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: add debug message for each created program
  2020-06-24  6:47 ` Alexei Starovoitov
@ 2020-06-24  6:59   ` Andrii Nakryiko
  2020-06-24 14:52     ` Alexei Starovoitov
  0 siblings, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2020-06-24  6:59 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Andrii Nakryiko, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team

On Tue, Jun 23, 2020 at 11:47 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Jun 23, 2020 at 5:34 PM Andrii Nakryiko <andriin@fb.com> wrote:
> >
> > Similar message for map creation is extremely useful, so add similar for BPF
> > programs.
>
> 'extremely useful' is quite subjective.
> If we land this patch then everyone will be allowed to add pr_debug()
> everywhere in libbpf with the same reasoning: "it's extremely useful pr_debug".

We print this for maps, making it clear which maps and with which FD
were created. Having this for programs is just as useful. It doesn't
overwhelm output (and it's debug one either way). "everyone will be
allowed to add pr_debug()" is a big stretch, you can't just sneak in
or force random pr_debug, we do review patches and if something
doesn't make sense we can and we do reject it, regardless of claimed
usefulness by the patch author.

So far, libbpf debug logs were extremely helpful (subjective, of
course, but what isn't?) to debug "remotely" various issues that BPF
users had. They don't feel overwhelmingly verbose and don't have a lot
of unnecessary info. Adding a few lines (how many BPF programs are
there per each BPF object?) for listing BPF programs is totally ok.

But I'm not going to fight it, up to you, of course.

>
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> > ---
> >  tools/lib/bpf/libbpf.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 18461deb1b19..f24a90c86c58 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -5379,8 +5379,9 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
> >         }
> >
> >         ret = bpf_load_program_xattr(&load_attr, log_buf, log_buf_size);
> > -
> >         if (ret >= 0) {
> > +               pr_debug("prog '%s' ('%s'): created successfully, fd=%d\n",
> > +                        prog->name, prog->section_name, ret);
> >                 if (log_buf && load_attr.log_level)
> >                         pr_debug("verifier log:\n%s", log_buf);
> >                 *pfd = ret;
> > --
> > 2.24.1
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: add debug message for each created program
  2020-06-24  6:59   ` Andrii Nakryiko
@ 2020-06-24 14:52     ` Alexei Starovoitov
  2020-06-24 15:03       ` Toke Høiland-Jørgensen
  2020-06-24 16:34       ` Andrii Nakryiko
  0 siblings, 2 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2020-06-24 14:52 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Andrii Nakryiko, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team

On Tue, Jun 23, 2020 at 11:59:40PM -0700, Andrii Nakryiko wrote:
> On Tue, Jun 23, 2020 at 11:47 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Tue, Jun 23, 2020 at 5:34 PM Andrii Nakryiko <andriin@fb.com> wrote:
> > >
> > > Similar message for map creation is extremely useful, so add similar for BPF
> > > programs.
> >
> > 'extremely useful' is quite subjective.
> > If we land this patch then everyone will be allowed to add pr_debug()
> > everywhere in libbpf with the same reasoning: "it's extremely useful pr_debug".
> 
> We print this for maps, making it clear which maps and with which FD
> were created. Having this for programs is just as useful. It doesn't
> overwhelm output (and it's debug one either way). "everyone will be
> allowed to add pr_debug()" is a big stretch, you can't just sneak in
> or force random pr_debug, we do review patches and if something
> doesn't make sense we can and we do reject it, regardless of claimed
> usefulness by the patch author.
> 
> So far, libbpf debug logs were extremely helpful (subjective, of
> course, but what isn't?) to debug "remotely" various issues that BPF
> users had. They don't feel overwhelmingly verbose and don't have a lot
> of unnecessary info. Adding a few lines (how many BPF programs are
> there per each BPF object?) for listing BPF programs is totally ok.

None of the above were mentioned in the commit log.
And no examples were given where this extra line would actually help.

I think libbpf pr_debug is extremely verbose instead of extremely useful.
Just typical output:
./test_progs -vv -t lsm
libbpf: loading object 'lsm' from buffer
libbpf: section(1) .strtab, size 306, link 0, flags 0, type=3
libbpf: skip section(1) .strtab
libbpf: section(2) .text, size 0, link 0, flags 6, type=1
libbpf: skip section(2) .text
libbpf: section(3) lsm/file_mprotect, size 192, link 0, flags 6, type=1
libbpf: found program lsm/file_mprotect
libbpf: section(4) .rellsm/file_mprotect, size 32, link 25, flags 0, type=9
libbpf: section(5) lsm/bprm_committed_creds, size 104, link 0, flags 6, type=1
libbpf: found program lsm/bprm_committed_creds
libbpf: section(6) .rellsm/bprm_committed_creds, size 32, link 25, flags 0, type=9

How's above useful for anyone?
libbpf says that there are '.strtab' and '.text' sections in the elf file.
That's wet water. Any elf file has that.
Then it says it's skipping '.text' ?
That reads surprising. Why library would skip the code?
And so on and so forth.
That output is useful to only few core libbpf developers.

I don't mind more thought through debug prints, but
saying that existing pr_debugs are 'extremely useful' is a stretch.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: add debug message for each created program
  2020-06-24 14:52     ` Alexei Starovoitov
@ 2020-06-24 15:03       ` Toke Høiland-Jørgensen
  2020-06-24 16:34       ` Andrii Nakryiko
  1 sibling, 0 replies; 7+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-06-24 15:03 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko
  Cc: Andrii Nakryiko, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team

Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:

> On Tue, Jun 23, 2020 at 11:59:40PM -0700, Andrii Nakryiko wrote:
>> On Tue, Jun 23, 2020 at 11:47 PM Alexei Starovoitov
>> <alexei.starovoitov@gmail.com> wrote:
>> >
>> > On Tue, Jun 23, 2020 at 5:34 PM Andrii Nakryiko <andriin@fb.com> wrote:
>> > >
>> > > Similar message for map creation is extremely useful, so add similar for BPF
>> > > programs.
>> >
>> > 'extremely useful' is quite subjective.
>> > If we land this patch then everyone will be allowed to add pr_debug()
>> > everywhere in libbpf with the same reasoning: "it's extremely useful pr_debug".
>> 
>> We print this for maps, making it clear which maps and with which FD
>> were created. Having this for programs is just as useful. It doesn't
>> overwhelm output (and it's debug one either way). "everyone will be
>> allowed to add pr_debug()" is a big stretch, you can't just sneak in
>> or force random pr_debug, we do review patches and if something
>> doesn't make sense we can and we do reject it, regardless of claimed
>> usefulness by the patch author.
>> 
>> So far, libbpf debug logs were extremely helpful (subjective, of
>> course, but what isn't?) to debug "remotely" various issues that BPF
>> users had. They don't feel overwhelmingly verbose and don't have a lot
>> of unnecessary info. Adding a few lines (how many BPF programs are
>> there per each BPF object?) for listing BPF programs is totally ok.
>
> None of the above were mentioned in the commit log.
> And no examples were given where this extra line would actually help.
>
> I think libbpf pr_debug is extremely verbose instead of extremely useful.
> Just typical output:
> ./test_progs -vv -t lsm
> libbpf: loading object 'lsm' from buffer
> libbpf: section(1) .strtab, size 306, link 0, flags 0, type=3
> libbpf: skip section(1) .strtab
> libbpf: section(2) .text, size 0, link 0, flags 6, type=1
> libbpf: skip section(2) .text
> libbpf: section(3) lsm/file_mprotect, size 192, link 0, flags 6, type=1
> libbpf: found program lsm/file_mprotect
> libbpf: section(4) .rellsm/file_mprotect, size 32, link 25, flags 0, type=9
> libbpf: section(5) lsm/bprm_committed_creds, size 104, link 0, flags 6, type=1
> libbpf: found program lsm/bprm_committed_creds
> libbpf: section(6) .rellsm/bprm_committed_creds, size 32, link 25, flags 0, type=9
>
> How's above useful for anyone?
> libbpf says that there are '.strtab' and '.text' sections in the elf file.
> That's wet water. Any elf file has that.
> Then it says it's skipping '.text' ?
> That reads surprising. Why library would skip the code?
> And so on and so forth.
> That output is useful to only few core libbpf developers.
>
> I don't mind more thought through debug prints, but
> saying that existing pr_debugs are 'extremely useful' is a stretch.

Agreed. I had to demote libbpf debug output to an (additional) 'verbose'
level in xdp-tools because there was just too much output.

Personally I think the additional 'program loading succeeded' message
would be useful *if* some of the more verbose stuff (like what you
posted above) was cleared out.

-Toke


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: add debug message for each created program
  2020-06-24 14:52     ` Alexei Starovoitov
  2020-06-24 15:03       ` Toke Høiland-Jørgensen
@ 2020-06-24 16:34       ` Andrii Nakryiko
  2020-06-24 17:38         ` Alexei Starovoitov
  1 sibling, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2020-06-24 16:34 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Andrii Nakryiko, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team

On Wed, Jun 24, 2020 at 7:52 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Jun 23, 2020 at 11:59:40PM -0700, Andrii Nakryiko wrote:
> > On Tue, Jun 23, 2020 at 11:47 PM Alexei Starovoitov
> > <alexei.starovoitov@gmail.com> wrote:
> > >
> > > On Tue, Jun 23, 2020 at 5:34 PM Andrii Nakryiko <andriin@fb.com> wrote:
> > > >
> > > > Similar message for map creation is extremely useful, so add similar for BPF
> > > > programs.
> > >
> > > 'extremely useful' is quite subjective.
> > > If we land this patch then everyone will be allowed to add pr_debug()
> > > everywhere in libbpf with the same reasoning: "it's extremely useful pr_debug".
> >
> > We print this for maps, making it clear which maps and with which FD
> > were created. Having this for programs is just as useful. It doesn't
> > overwhelm output (and it's debug one either way). "everyone will be
> > allowed to add pr_debug()" is a big stretch, you can't just sneak in
> > or force random pr_debug, we do review patches and if something
> > doesn't make sense we can and we do reject it, regardless of claimed
> > usefulness by the patch author.
> >
> > So far, libbpf debug logs were extremely helpful (subjective, of
> > course, but what isn't?) to debug "remotely" various issues that BPF
> > users had. They don't feel overwhelmingly verbose and don't have a lot
> > of unnecessary info. Adding a few lines (how many BPF programs are
> > there per each BPF object?) for listing BPF programs is totally ok.
>
> None of the above were mentioned in the commit log.
> And no examples were given where this extra line would actually help.

I used it just 2 days ago trying to understand why bpftool doesn't
show its own bpf_iter program, but shows maps. I discovered with
surprise that we actually don't log FDs of loaded programs.

>
> I think libbpf pr_debug is extremely verbose instead of extremely useful.
> Just typical output:
> ./test_progs -vv -t lsm
> libbpf: loading object 'lsm' from buffer
> libbpf: section(1) .strtab, size 306, link 0, flags 0, type=3
> libbpf: skip section(1) .strtab
> libbpf: section(2) .text, size 0, link 0, flags 6, type=1
> libbpf: skip section(2) .text
> libbpf: section(3) lsm/file_mprotect, size 192, link 0, flags 6, type=1
> libbpf: found program lsm/file_mprotect
> libbpf: section(4) .rellsm/file_mprotect, size 32, link 25, flags 0, type=9
> libbpf: section(5) lsm/bprm_committed_creds, size 104, link 0, flags 6, type=1
> libbpf: found program lsm/bprm_committed_creds
> libbpf: section(6) .rellsm/bprm_committed_creds, size 32, link 25, flags 0, type=9
>
> How's above useful for anyone?
> libbpf says that there are '.strtab' and '.text' sections in the elf file.
> That's wet water. Any elf file has that.
> Then it says it's skipping '.text' ?
> That reads surprising. Why library would skip the code?
> And so on and so forth.

I can pick a few more not-so-useful (usually) pr_debug-level log lines
as well, I don't think it disproves that debug logs are useful.

> That output is useful to only few core libbpf developers.

Yes, and I don't expect typical BPF developers to have them turned on
by default. They are *DEBUG*-level output, after all, users shouldn't
care about them, only INFO and WARN/ERR ones, I'd hope. But it's #1
thing that I ask users to provide when they come with any questions
about BPF or libbpf.

So yeah, as a core libbpf developer and a person helping people with
various (often non-libbpf-specific) BPF problems both online and
within my company, I stand by my claim that libbpf debug logs are
extremely useful and helped debug and understand numerous issues.

Just yesterday (or two days ago, maybe), having those CO-RE relocation
logs, which I fought to keep when I added CO-RE relocs initially,
immediately shown that a person doesn't have bpf_iter compiled in its
running kernel, despite the claims otherwise.

>
> I don't mind more thought through debug prints, but
> saying that existing pr_debugs are 'extremely useful' is a stretch.

Some lines are extremely useful, yes, some less so. But then again,
depending on the situation. Not all parts of the log are relevant 100%
of the time, but sometimes even these ELF parsing logs are important.
How many people add and debug libbpf functionality that deals with
interpreting ELF sections/relocations/etc to be able to claim about
their usefulness anyway?

Regardless, we've spent way too much time on this, I don't care about
this particular pr_debug() enough to argue further.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] libbpf: add debug message for each created program
  2020-06-24 16:34       ` Andrii Nakryiko
@ 2020-06-24 17:38         ` Alexei Starovoitov
  0 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2020-06-24 17:38 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Andrii Nakryiko, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Kernel Team

On Wed, Jun 24, 2020 at 09:34:52AM -0700, Andrii Nakryiko wrote:
> 
> Just yesterday (or two days ago, maybe), having those CO-RE relocation
> logs, which I fought to keep when I added CO-RE relocs initially,
> immediately shown that a person doesn't have bpf_iter compiled in its
> running kernel, despite the claims otherwise.
...
> of the time, but sometimes even these ELF parsing logs are important.

Prints for reloc make sense to me because that's libbpf's job.
Whereas info about elf sections could have been received by asking
that remote person to do objdump or llvm-objdump on the .o
Printing elf data from libbpf is an indication that libbpf itself
is not sure whether it has bugs in elf parsing. If that's the case
still after those years in production it just sad state of libbpf.
There could be an elf parsing bug there, of course, but keeping
all of that verbosity for likely rare bug is just not right.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-24 17:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24  0:33 [PATCH bpf-next] libbpf: add debug message for each created program Andrii Nakryiko
2020-06-24  6:47 ` Alexei Starovoitov
2020-06-24  6:59   ` Andrii Nakryiko
2020-06-24 14:52     ` Alexei Starovoitov
2020-06-24 15:03       ` Toke Høiland-Jørgensen
2020-06-24 16:34       ` Andrii Nakryiko
2020-06-24 17:38         ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).