From: Alan Maguire <alan.maguire@oracle.com>
To: Eduard Zingerman <eddyz87@gmail.com>,
andrii@kernel.org, jolsa@kernel.org, acme@redhat.com,
quentin@isovalent.com
Cc: mykolal@fb.com, ast@kernel.org, daniel@iogearbox.net,
martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
haoluo@google.com, houtao1@huawei.com, bpf@vger.kernel.org,
masahiroy@kernel.org, mcgrof@kernel.org, nathan@kernel.org
Subject: Re: [PATCH v4 bpf-next 00/11] bpf: support resilient split BTF
Date: Tue, 21 May 2024 10:15:48 +0100 [thread overview]
Message-ID: <3ae296b2-402a-4e17-b874-e067c57fc091@oracle.com> (raw)
In-Reply-To: <b647e0d1d225f9d21e78c6ffedb722507f42eff0.camel@gmail.com>
On 18/05/2024 03:38, Eduard Zingerman wrote:
> On Fri, 2024-05-17 at 11:22 +0100, Alan Maguire wrote:
>
> (Also, please note that CI fails for this series).
>
> [...]
>
>> Also explored Eduard's suggestion of doing an implicit fallback
>> to checking for .BTF.base section in btf__parse() when it is
>> called to get base BTF. However while it is doable, it turned
>> out to be difficult operationally. Since fallback is implicit
>> we do not know the source of the BTF - was it from .BTF or
>> .BTF.base? In bpftool, we want to try first standalone BTF,
>> then split, then split with distilled base. Having a way
>> to explicitly request .BTF.base via btf__parse_opts() fits
>> that model better.
>
> I don't think this is the case. Here is what I mean:
> https://github.com/eddyz87/bpf/tree/distilled-base-alternative-parse-elf
>
> The branch above is a modification for btf_parse_elf() and a few
> reverts on top of this patch-set.
>
> I modified btf_parse_elf() to follow the logic below:
>
> | base_btf | .BTF.base | Effect |
> | specified? | present? | |
> |------------+-----------+---------------------------------------------|
> | no | no | load btf from .BTF |
> |------------+-----------+---------------------------------------------|
> | yes | no | load btf from .BTF using base_btf as base |
> | | | |
> |------------+-----------+---------------------------------------------|
> | no | yes | load btf from .BTF using .BTF.base as base |
> | | | |
> |------------+-----------+---------------------------------------------|
> | yes | yes | load btf from .BTF using .BTF.base as base, |
> | | | relocate btf against base_btf |
>
> When organized like that, there is no need to modify libbpf clients to
> work with split BTF.
>
> The `bpftool btf dump file ./btf_testmod.ko` would print non-relocated BTF.
> The `bpftool btf -B ../../../vmlinux dump file ./btf_testmod.ko` would
> print relocated BTF, no need for separate -R flag.
> Imo, loading split BTF w/o relocation when .BTF.base is present
> is interesting only for debug purposes and could be handled separately
> as all building blocks are present in the library.
>
This is a neat approach, and as you say it eliminates the need to modify
bpftool to handle distilled base BTF and relocation. The only wrinkle
is resolve_btfids; we call resolve_btfids for modules with a "-B
vmlinux" argument, so in that case we'd be calling btf_parse_elf() with
both a split and base BTF. According to the approach outlined above,
we'd relocate split BTF - originally relative to .BTF.base - to be
relative to vmlinux BTF, but in the case of resolve_btfids we don't want
that relocation. We want the BTF ids to reflect the distilled base BTF
ids since they will be relocated later on module load along with the
split BTF references themselves.
We can handle this by having a -R flag to skip relocation; it would
simply ensure we first try calling btf__parse(), falling back to
btf__parse_split(); we need the fallback logic as it is possible the
pahole version didn't add .BTF.base sections. This logic would only be
activated for out-of-tree module builds so seems acceptable to me. If
that makes sense, with your permission I can rework the series to
include your BTF parsing patch.
Thanks!
Alan
> [...]
>
next prev parent reply other threads:[~2024-05-21 9:16 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-17 10:22 [PATCH v4 bpf-next 00/11] bpf: support resilient split BTF Alan Maguire
2024-05-17 10:22 ` [PATCH v4 bpf-next 01/11] libbpf: add btf__distill_base() creating split BTF with distilled base BTF Alan Maguire
2024-05-21 21:48 ` Andrii Nakryiko
2024-05-22 16:42 ` Alan Maguire
2024-05-22 16:57 ` Andrii Nakryiko
2024-05-22 18:00 ` Kui-Feng Lee
2024-05-17 10:22 ` [PATCH v4 bpf-next 02/11] selftests/bpf: test distilled base, split BTF generation Alan Maguire
2024-05-17 10:22 ` [PATCH v4 bpf-next 03/11] libbpf: add btf__parse_opts() API for flexible BTF parsing Alan Maguire
2024-05-21 22:01 ` Andrii Nakryiko
2024-05-17 10:22 ` [PATCH v4 bpf-next 04/11] bpftool: support displaying raw split BTF using base BTF section as base Alan Maguire
2024-05-17 10:22 ` [PATCH v4 bpf-next 05/11] resolve_btfids: use .BTF.base ELF section as base BTF if -B option is used Alan Maguire
2024-05-17 10:22 ` [PATCH v4 bpf-next 06/11] kbuild, bpf: add module-specific pahole/resolve_btfids flags for distilled base BTF Alan Maguire
2024-05-17 10:22 ` [PATCH v4 bpf-next 07/11] libbpf: split BTF relocation Alan Maguire
2024-05-21 22:34 ` Andrii Nakryiko
2024-05-23 1:06 ` Kui-Feng Lee
2024-05-17 10:22 ` [PATCH v4 bpf-next 08/11] selftests/bpf: extend distilled BTF tests to cover " Alan Maguire
2024-05-17 10:22 ` [PATCH v4 bpf-next 09/11] module, bpf: store BTF base pointer in struct module Alan Maguire
2024-05-17 10:22 ` [PATCH v4 bpf-next 10/11] libbpf,bpf: share BTF relocate-related code with kernel Alan Maguire
2024-05-21 22:59 ` Andrii Nakryiko
2024-05-17 10:22 ` [PATCH v4 bpf-next 11/11] bpftool: support displaying relocated-with-base split BTF Alan Maguire
2024-05-22 9:04 ` Quentin Monnet
[not found] ` <CA+JHD93=ZcVN4GxepbRF6SLorWJjw0gCgJZUYxQG5hxFehdHUw@mail.gmail.com>
2024-05-17 11:56 ` [PATCH v4 bpf-next 00/11] bpf: support resilient " Alan Maguire
2024-05-17 21:09 ` Eduard Zingerman
2024-05-20 9:36 ` Alan Maguire
2024-05-18 2:38 ` Eduard Zingerman
2024-05-21 9:15 ` Alan Maguire [this message]
2024-05-21 16:19 ` Eduard Zingerman
2024-05-21 18:54 ` Andrii Nakryiko
2024-05-21 19:08 ` Eduard Zingerman
2024-05-21 22:01 ` Andrii Nakryiko
2024-05-21 22:15 ` Eduard Zingerman
2024-05-21 22:36 ` Andrii Nakryiko
2024-05-22 16:16 ` Alan Maguire
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=3ae296b2-402a-4e17-b874-e067c57fc091@oracle.com \
--to=alan.maguire@oracle.com \
--cc=acme@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=houtao1@huawei.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=masahiroy@kernel.org \
--cc=mcgrof@kernel.org \
--cc=mykolal@fb.com \
--cc=nathan@kernel.org \
--cc=quentin@isovalent.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.