[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <61f94d36d6777b9b84e9bf865edd17476a278e73.camel@gmail.com>
Date: Tue, 04 Nov 2025 17:23:13 -0800
From: Eduard Zingerman <eddyz87@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Donglin Peng <dolinux.peng@...il.com>, ast@...nel.org,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org, Alan Maguire
<alan.maguire@...cle.com>, Song Liu <song@...nel.org>, pengdonglin
<pengdonglin@...omi.com>
Subject: Re: [RFC PATCH v4 1/7] libbpf: Extract BTF type remapping logic
into helper function
On Tue, 2025-11-04 at 16:57 -0800, Andrii Nakryiko wrote:
> On Tue, Nov 4, 2025 at 4:36 PM Eduard Zingerman <eddyz87@...il.com> wrote:
> >
> > On Tue, 2025-11-04 at 16:11 -0800, Andrii Nakryiko wrote:
> >
> > [...]
> >
> > > > @@ -3400,6 +3400,37 @@ int btf_ext__set_endianness(struct btf_ext *btf_ext, enum btf_endianness endian)
> > > > return 0;
> > > > }
> > > >
> > > > +static int btf_remap_types(struct btf *btf, struct btf_ext *btf_ext,
> > > > + btf_remap_type_fn visit, void *ctx)
> > >
> > > tbh, my goal is to reduce the amount of callback usage within libbpf,
> > > not add more of it...
> > >
> > > I don't like this refactoring. We should convert
> > > btf_ext_visit_type_ids() into iterators, have btf_field_iter_init +
> > > btf_field_iter_next usable in for_each() form, and not try to reuse 5
> > > lines of code. See my comments in the next patch.
> >
> > Remapping types is a concept.
> > I hate duplicating code for concepts.
> > Similarly, having patch #3 == patch #5 and patch #4 == patch #6 is
> > plain ugly. Just waiting for a bug because we changed the one but
> > forgot to change another in a year or two.
>
> Tricky and evolving part (iterating all type ID fields) is abstracted
> behind the iterator (and we should do the same for btf_ext). Iterating
> types is not something tricky or requiring constant maintenance.
>
> Same for binary search, I don't see why we'd need to adjust it. So no,
> I don't want to share code between kernel and libbpf just to reuse
> binary search implementation, sorry.
<rant>
Sure binary search is trivial, but did you count how many times you
asked people to re-implement binary search as in [1]?
[1] https://elixir.bootlin.com/linux/v6.18-rc4/source/kernel/bpf/verifier.c#L2952
</rant>
Powered by blists - more mailing lists