netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Networking <netdev@vger.kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [PATCH bpf] tools/bpftool: Add/Fix support for modules btf dump
Date: Mon, 07 Dec 2020 22:26:50 -0800	[thread overview]
Message-ID: <76aa0d16e3d03cf12496184c848f60069bf71872.camel@kernel.org> (raw)
In-Reply-To: <CAEf4BzZe2162nMsamMKkGRpR_9hUnaATWocE=XjgZd+2cJk5Jw@mail.gmail.com>

On Mon, 2020-12-07 at 19:14 -0800, Andrii Nakryiko wrote:
> On Sun, Dec 6, 2020 at 9:21 PM <saeed@kernel.org> wrote:
> > From: Saeed Mahameed <saeedm@nvidia.com>
> > 
> > While playing with BTF for modules, i noticed that executing the
> > command:
> > $ bpftool btf dump id <module's btf id>
> > 
> > Fails due to lack of information in the BTF data.
> > 
> > Maybe I am missing a step but actually adding the support for this
> > is
> > very simple.
> 
> yes, bpftool takes -B <path> argument for specifying base BTF. So if
> you added -B /sys/kernel/btf/vmlinux, it should have worked. I've
> added auto-detection logic for the case of `btf dump file
> /sys/kernel/btf/<module>` (see [0]), and we can also add it for when
> ID corresponds to a module BTF. But I think it's simplest to re-use
> the logic and just open /sys/kernel/btf/vmlinux, instead of adding
> narrowly-focused libbpf API for that.
> 

When dumping with a file it works even without the -B since you lookup
the vmlinux file, but the issue is not dumping from a file source, we
need it by id..

> > To completely parse modules BTF data, we need the vmlinux BTF as
> > their
> > "base btf", which can be easily found by iterating through the btf
> > ids and
> > looking for btf.name == "vmlinux".
> > 
> > I am not sure why this hasn't been added by the original patchset
> 
> because I never though of dumping module BTF by id, given there is
> nicely named /sys/kernel/btf/<module> :)
> 

What if i didn't compile my kernel with SYSFS ? a user experience is a
user experience, there is no reason to not support dump a module btf by
id or to have different behavior for different BTF sources.

I can revise this patch to support -B option and lookup vmlinux file if
not provided for module btf dump by ids.

but we  still need to pass base_btf to btf__get_from_id() in order to
support that, as was done for btf__parse_split() ... :/

Are you sure you don't like the current patch/libbpf API ? it is pretty
straight forward and correct.

> > "Integrate kernel module BTF support", as adding the support for
> > this is very trivial. Unless i am missing something, CCing Andrii..
> > 
> > Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
> > CC: Andrii Nakryiko <andrii@kernel.org>
> > ---
> >  tools/lib/bpf/btf.c      | 57
> > ++++++++++++++++++++++++++++++++++++++++
> >  tools/lib/bpf/btf.h      |  2 ++
> >  tools/lib/bpf/libbpf.map |  1 +
> >  3 files changed, 60 insertions(+)
> > 
> 
> [...]


  reply	other threads:[~2020-12-08  6:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07  5:20 [PATCH bpf] tools/bpftool: Add/Fix support for modules btf dump saeed
2020-12-08  3:14 ` Andrii Nakryiko
2020-12-08  6:26   ` Saeed Mahameed [this message]
2020-12-08  6:38     ` Andrii Nakryiko
2020-12-08  6:45       ` Saeed Mahameed
2020-12-08  6:48         ` Andrii Nakryiko
2020-12-08  6:52           ` Saeed Mahameed

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=76aa0d16e3d03cf12496184c848f60069bf71872.camel@kernel.org \
    --to=saeed@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).