From: Donglin Peng <dolinux.peng@gmail.com>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: ast@kernel.org, Andrii Nakryiko <andrii.nakryiko@gmail.com>,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
Alan Maguire <alan.maguire@oracle.com>,
Song Liu <song@kernel.org>, pengdonglin <pengdonglin@xiaomi.com>
Subject: Re: [RFC PATCH v3 1/3] btf: implement BTF type sorting for accelerated lookups
Date: Tue, 28 Oct 2025 10:18:48 +0800 [thread overview]
Message-ID: <CAErzpmu19JkTffsqXxmcppbUON4_03ZjpcxcCQntNo9HG_-uvA@mail.gmail.com> (raw)
In-Reply-To: <6e7ef94cb4e2d7fbc82676b2af1a165cac620aae.camel@gmail.com>
On Tue, Oct 28, 2025 at 3:06 AM Eduard Zingerman <eddyz87@gmail.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;
> > +}
>
> [...]
next prev parent reply other threads:[~2025-10-28 2:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 13:54 [RFC PATCH v3 0/3] Significantly Improve BTF Type Lookup Performance Donglin Peng
2025-10-27 13:54 ` [RFC PATCH v3 1/3] btf: implement BTF type sorting for accelerated lookups Donglin Peng
2025-10-27 14:20 ` bot+bpf-ci
2025-10-27 18:40 ` Eduard Zingerman
2025-10-28 2:15 ` Donglin Peng
2025-10-27 19:06 ` Eduard Zingerman
2025-10-28 2:18 ` Donglin Peng [this message]
2025-10-28 18:15 ` Andrii Nakryiko
2025-10-28 18:38 ` Andrii Nakryiko
2025-10-29 5:04 ` Donglin Peng
2025-10-27 13:54 ` [RFC PATCH v3 2/3] selftests/bpf: add tests for BTF type permutation Donglin Peng
2025-10-27 18:53 ` Eduard Zingerman
2025-10-28 2:23 ` Donglin Peng
2025-10-27 13:54 ` [RFC PATCH v3 3/3] btf: Reuse libbpf code for BTF type sorting verification and binary search Donglin Peng
2025-10-27 19:55 ` Alexei Starovoitov
2025-10-29 1:57 ` Donglin Peng
2025-10-28 18:40 ` Andrii Nakryiko
2025-10-29 2:03 ` Donglin Peng
2025-10-31 16:50 ` Andrii Nakryiko
2025-11-03 1:20 ` Donglin Peng
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=CAErzpmu19JkTffsqXxmcppbUON4_03ZjpcxcCQntNo9HG_-uvA@mail.gmail.com \
--to=dolinux.peng@gmail.com \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pengdonglin@xiaomi.com \
--cc=song@kernel.org \
/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).