All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Eduard Zingerman <eddyz87@gmail.com>
Cc: andrii@kernel.org, jolsa@kernel.org, acme@redhat.com,
	quentin@isovalent.com, 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: Wed, 22 May 2024 17:16:28 +0100	[thread overview]
Message-ID: <f97dcbd9-5bd0-4ff8-aeae-ee36bf3e12ac@oracle.com> (raw)
In-Reply-To: <CAEf4BzbghAqpTSfWH_v10uK4ynXqG5Nm2e-_xTWFOF=bmLqd_Q@mail.gmail.com>

On 21/05/2024 23:01, Andrii Nakryiko wrote:
> On Tue, May 21, 2024 at 12:08 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
>>
>> On Tue, 2024-05-21 at 11:54 -0700, Andrii Nakryiko wrote:
>>
>> [...]
>>
>>> I'm probably leaning towards not doing automatic relocations in
>>> btf__parse(), tbh. Distilled BTF is a rather special kernel-specific
>>> feature, if we need to teach resolve_btfids and bpftool to do
>>> something extra for that case (i.e., call another API for relocation,
>>> if necessary), then it's fine, doesn't seems like a problem.
>>
>> My point is that with current implementation it does not even make
>> sense to call btf__parse() for an ELF with distilled base,
>> because it would fail.
> 
> True (unless application loaded .BTF.base as stand-alone BTF first,
> but it's pretty advanced scenario)
> 
>>
>> And selecting BTF encoding based on a few retries seems like a kludge
>> if there is a simple way to check if distilled base has to be used
>> (presence of the .BTF.base section).
> 
> agreed
> 
>>
>>> Much worse is having to do some workarounds to prevent an API from
>>> doing some undesired extra steps (like in resolve_btfids not wanting a
>>> relocation). Orthogonality FTW, IMO.
>>
>> For resolve_btfids it is a bit different, imo.
>> It does want some base: for in-tree modules it wants vmlinux,
>> for out-of-tree it wants distilled base.
>> So it has to be adjusted either way.
> 
> Ok, so I read some more code and re-read your discussion w/ Alan. I
> agree with your proposal, I think it's logical (even if relocation
> does feel a bit "extra" for "parse"-like API, but ok, whatever).
> 
> I see what you are saying about resolve_btfids needing the changes
> either way, and that's true. But instead of adding (unnecessary, IMO)
> -R argument, resolve_btfids should be able to detect .BTF.base section
> presence and infer that this is distilled BTF case, and thus proceed
> with ignoring `-B <vmlinux>` argument (we can even complain that `-B
> vmlinux` is specified if distilled BTF is used, not sure.

That's a good idea; we already have ELF parsing in resolve_btfids, so as
we can detect the .BTF.base presence there easily, no need for a
parameter. I put together a quick proof-of-concept and it works well.

This simplifies things considerably; we can eliminate the bpftool
patches completely since ELF parsing does the right thing already, and
the resolve_btfids change is small, with no user interface-visible
changes there.

Thanks!

Alan

      parent reply	other threads:[~2024-05-22 16:17 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
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 [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=f97dcbd9-5bd0-4ff8-aeae-ee36bf3e12ac@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=acme@redhat.com \
    --cc=andrii.nakryiko@gmail.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.