[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAErzpmu19JkTffsqXxmcppbUON4_03ZjpcxcCQntNo9HG_-uvA@mail.gmail.com>
Date: Tue, 28 Oct 2025 10:18:48 +0800
From: Donglin Peng <dolinux.peng@...il.com>
To: Eduard Zingerman <eddyz87@...il.com>
Cc: ast@...nel.org, Andrii Nakryiko <andrii.nakryiko@...il.com>, 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 v3 1/3] btf: implement BTF type sorting for
accelerated lookups
On Tue, Oct 28, 2025 at 3:06 AM Eduard Zingerman <eddyz87@...il.com> wrote:
>
> On Mon, 2025-10-27 at 21:54 +0800, Donglin Peng wrote:
>
> [...]
>
> Question to Andrii, I think.
> It looks a bit asymmetrical, that there is btf_check_sorted() in
> libbpf, but library does not provide comparison or sorting function.
> Wdyt?
>
> > +static void btf_check_sorted(struct btf *btf, int start_id)
> > +{
> > + const struct btf_type *t;
> > + int i, n, nr_sorted_types;
> > +
> > + n = btf__type_cnt(btf);
> > + if (btf->nr_types < BTF_CHECK_SORT_THRESHOLD)
> > + return;
> > +
> > + n--;
> > + nr_sorted_types = 0;
> > + for (i = start_id; i < n; i++) {
> > + int k = i + 1;
> > +
> > + if (btf_compare_type_kinds_names(&i, &k, btf) > 0)
> > + return;
> > +
> > + t = btf_type_by_id(btf, k);
> > + if (!str_is_empty(btf__str_by_offset(btf, t->name_off)))
> > + nr_sorted_types++;
> > + }
> > +
> > + t = btf_type_by_id(btf, start_id);
> > + if (!str_is_empty(btf__str_by_offset(btf, t->name_off)))
> > + nr_sorted_types++;
> > +
> > + if (nr_sorted_types < BTF_CHECK_SORT_THRESHOLD)
> > + return;
>
> Nit: Still think that this is not needed. It trades a couple of CPU
> cycles for this check and a big comment on the top, about why
> it's needed.
Thanks, I will remove it in the next version.
>
> > +
> > + btf->nr_sorted_types = nr_sorted_types;
> > +}
>
> [...]
Powered by blists - more mailing lists