bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Larysa Zaremba <larysa.zaremba@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Quentin Monnet <quentin@isovalent.com>,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Alexander Lobakin <alexandr.lobakin@intel.com>
Subject: Re: [PATCH bpf-next v2] bpftool: Use sysfs vmlinux when dumping BTF by ID
Date: Mon, 9 May 2022 17:24:33 -0700	[thread overview]
Message-ID: <CAEf4BzZ=_C6pOjoLKpbZaWB0=28YhbPvU3f9sS5P1W3Lc_NQHQ@mail.gmail.com> (raw)
In-Reply-To: <20220505130507.130670-1-larysa.zaremba@intel.com>

On Thu, May 5, 2022 at 6:17 AM Larysa Zaremba <larysa.zaremba@intel.com> wrote:
>
> Currently, dumping almost all BTFs specified by id requires
> using the -B option to pass the base BTF. For kernel module
> BTFs the vmlinux BTF sysfs path should work.
>
> This patch simplifies dumping by ID usage by attempting to
> use vmlinux BTF from sysfs, if the first try of loading BTF by ID
> fails with certain conditions and the ID corresponds to a kernel
> module BTF.

It feels sloppy to first try without base BTF and then fallback to
base BTF. When specified ID of BTF object, let's just get its struct
bpf_btf_info with bpf_obj_get_info_by_fd() and then check that
kernel_btf is set and name isn't "vmlinux". This will mean it's kernel
module, so load base BTF from /sys/kernel/btf/vmlinux. If that fails,
there is no way that kernel module BTF will be successfully loaded, so
there is no point in trying.

>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com>
> ---
>  tools/bpf/bpftool/btf.c | 67 +++++++++++++++++++++++++++++++++++------
>  1 file changed, 58 insertions(+), 9 deletions(-)
>

[...]

      reply	other threads:[~2022-05-10  0:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05 13:05 [PATCH bpf-next v2] bpftool: Use sysfs vmlinux when dumping BTF by ID Larysa Zaremba
2022-05-10  0:24 ` Andrii Nakryiko [this message]

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='CAEf4BzZ=_C6pOjoLKpbZaWB0=28YhbPvU3f9sS5P1W3Lc_NQHQ@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=alexandr.lobakin@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@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;
as well as URLs for NNTP newsgroup(s).