From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, acme@kernel.org, ttreyer@meta.com,
yonghong.song@linux.dev, song@kernel.org,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, qmo@kernel.org,
ihor.solodrai@linux.dev, david.faust@oracle.com,
jose.marchesi@oracle.com, bpf@vger.kernel.org
Subject: Re: [RFC bpf-next 03/15] libbpf: Add option to retrieve map from old->new ids from btf__dedup()
Date: Mon, 20 Oct 2025 14:03:24 -0700 [thread overview]
Message-ID: <CAEf4Bza_nnCzn-cOqP170XbqpM2=D5afhnM2Ow_BadmfM8UNXA@mail.gmail.com> (raw)
In-Reply-To: <129305e3-adb9-450a-b777-5d42f231c1df@oracle.com>
On Fri, Oct 17, 2025 at 1:57 AM Alan Maguire <alan.maguire@oracle.com> wrote:
>
> On 16/10/2025 19:39, Andrii Nakryiko wrote:
> > On Wed, Oct 8, 2025 at 10:35 AM Alan Maguire <alan.maguire@oracle.com> wrote:
> >>
> >> When creating split BTF for the .BTF.extra section to record location
> >> information, we need to add function prototypes that refer to base BTF
> >> (vmlinux) types. However since .BTF.extra is split BTF we have a
> >> problem; since collecting those type ids for the parameters, the base
> >> vmlinux BTF has been deduplicated so the type ids are stale. As a
> >> result it is valuable to be able to access the map from old->new type
> >> ids that is constructed as part of deduplication. This allows us to
> >> update the out-of-date type ids in the FUNC_PROTOs.
> >>
> >> In order to pass the map back, we need to fill out all of the hypot
> >> map mappings; as an optimization normal dedup only computes type id
> >> mappings needed in existing BTF type id references.
> >
> > I probably should look at pahole patches to find out myself, but I'm
> > going to be lazy here. ;) Wouldn't you want to generate .BTF.extra
> > after base BTF was generated and deduped? Or is it too inconvenient?
> > Can you please elaborate a bit with more info?
> >
>
> Yep, the BTF.extra is indeed generated after base BTF+dedup, but the
> problem is we need to cache info about inline sites as we process DWARF
> CUs and collect inline info. Specifically at that time we need to cache
> info about function prototypes associated with inlines, and this is done
> - like it is done for real functions - via btf_encoder__save_func(). It
> saves a representation of the function prototype using BTF ids of
> function parameters, and these are pre-dedup BTF ids.
>
> And it's those BTF ids that are the problem. When we dedup with
> FUNC_PROTOs in the same BTF, all the id references get fixed up, but
> because we now have stale type id references in FUNC_PROTOs in the split
> BTF.extra (that were not fixed up by dedup) since we didn't dedup this
> split BTF yet, we are stuck.
>
> There are other alternatives here I suppose, but they seemed equally
> bad/worse.
>
> One is to rescan all the CUs for later inline site representation once
> vmlinux/module dedup is done. That would make pahole much slower as CU
> processing is the most time-consuming aspect of its operation. It seemed
> better to collect inline info at the same time we collect everything else.
>
> Another is to put the FUNC_PROTOs (that are only needed for inline
> sites) into the vmlinux/module BTF. That would work, but even that would
> exhibit the same problem as even those FUNC_PROTO type id references
> would also get remapped by vmlinux/module dedup.
>
> So it's not an ideal solution, but I couldn't figure out an easier one
> I'm afraid.
Ok, this makes sense at the conceptual level. This might be useful
overall. But I don't like the implementation, sorry.
The size of mapping "table" is fixed, it's btf__type_cnt(). So just
make caller allocate u32 array of that size, and pass it in. Libbpf
will then maintain/populate provided array with original type ID ->
deduped type ID with an absolutely minimal amount of overhead and
extra code.
so just
__u32 dedup_map;
size_t dedup_map_cnt;
inside btf_dedup_opts ? (and we request user to specify count just to
avoid surprises, we do know the size, but user should know it as well)
>
> Alan
next prev parent reply other threads:[~2025-10-20 21:03 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-08 17:34 [RFC bpf-next 00/15] support inline tracing with BTF Alan Maguire
2025-10-08 17:34 ` [RFC bpf-next 01/15] bpf: Extend UAPI to support location information Alan Maguire
2025-10-16 18:36 ` Andrii Nakryiko
2025-10-17 8:43 ` Alan Maguire
2025-10-20 20:57 ` Andrii Nakryiko
2025-10-23 8:17 ` Alan Maguire
2025-11-05 0:43 ` Andrii Nakryiko
2025-10-23 0:56 ` Eduard Zingerman
2025-10-23 8:35 ` Alan Maguire
2025-10-08 17:34 ` [RFC bpf-next 02/15] libbpf: Add support for BTF kinds LOC_PARAM, LOC_PROTO and LOCSEC Alan Maguire
2025-10-23 0:57 ` Eduard Zingerman
2025-10-23 19:18 ` Eduard Zingerman
2025-10-23 19:59 ` Eduard Zingerman
2025-10-08 17:34 ` [RFC bpf-next 03/15] libbpf: Add option to retrieve map from old->new ids from btf__dedup() Alan Maguire
2025-10-16 18:39 ` Andrii Nakryiko
2025-10-17 8:56 ` Alan Maguire
2025-10-20 21:03 ` Andrii Nakryiko [this message]
2025-10-23 8:25 ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 04/15] libbpf: Fix parsing of multi-split BTF Alan Maguire
2025-10-16 18:36 ` Andrii Nakryiko
2025-10-17 13:47 ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 05/15] bpftool: Add ability to dump LOC_PARAM, LOC_PROTO and LOCSEC Alan Maguire
2025-10-23 0:57 ` Eduard Zingerman
2025-10-23 8:38 ` Alan Maguire
2025-10-23 8:50 ` Eduard Zingerman
2025-10-08 17:35 ` [RFC bpf-next 06/15] bpftool: Handle multi-split BTF by supporting multiple base BTFs Alan Maguire
2025-10-16 18:36 ` Andrii Nakryiko
2025-10-17 13:47 ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 07/15] selftests/bpf: Test helper support for BTF_KIND_LOC[_PARAM|_PROTO|SEC] Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 08/15] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to field iter tests Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 09/15] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to dedup split tests Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 10/15] selftests/bpf: BTF distill tests to ensure LOC[_PARAM|_PROTO] add to split BTF Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 11/15] kbuild: Add support for extra BTF Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 12/15] kbuild, module, bpf: Support CONFIG_DEBUG_INFO_BTF_EXTRA=m Alan Maguire
2025-10-16 18:37 ` Andrii Nakryiko
2025-10-17 13:54 ` Alan Maguire
2025-10-20 21:05 ` Andrii Nakryiko
2025-10-23 0:58 ` Eduard Zingerman
2025-10-23 12:00 ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 13/15] libbpf: add API to load extra BTF Alan Maguire
2025-10-16 18:37 ` Andrii Nakryiko
2025-10-17 13:55 ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 14/15] libbpf: add support for BTF location attachment Alan Maguire
2025-10-16 18:36 ` Andrii Nakryiko
2025-10-17 14:02 ` Alan Maguire
2025-10-20 21:07 ` Andrii Nakryiko
2025-10-08 17:35 ` [RFC bpf-next 15/15] selftests/bpf: Add test tracing inline site using SEC("kloc") Alan Maguire
2025-10-12 23:45 ` [RFC bpf-next 00/15] support inline tracing with BTF Alexei Starovoitov
2025-10-13 7:38 ` Alan Maguire
2025-10-14 0:12 ` Alexei Starovoitov
2025-10-14 9:58 ` Alan Maguire
2025-10-16 18:36 ` Andrii Nakryiko
2025-10-23 14:37 ` Alan Maguire
2025-10-23 16:16 ` Andrii Nakryiko
2025-10-24 11:53 ` Alan Maguire
2025-10-14 11:52 ` Jiri Olsa
2025-10-14 14:55 ` Alan Maguire
2025-10-14 23:04 ` Masami Hiramatsu
2025-10-15 14:17 ` Jiri Olsa
2025-10-15 15:19 ` Alan Maguire
2025-10-15 18:35 ` Jiri Olsa
2025-10-23 22:32 ` Eduard Zingerman
2025-10-24 12:54 ` 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='CAEf4Bza_nnCzn-cOqP170XbqpM2=D5afhnM2Ow_BadmfM8UNXA@mail.gmail.com' \
--to=andrii.nakryiko@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=david.faust@oracle.com \
--cc=haoluo@google.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jose.marchesi@oracle.com \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=qmo@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=ttreyer@meta.com \
--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 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).