BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Donglin Peng <dolinux.peng@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	ast@kernel.org,  zhangxiaoqin@xiaomi.com,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
	Donglin Peng <pengdonglin@xiaomi.com>,
	Alan Maguire <alan.maguire@oracle.com>,
	Song Liu <song@kernel.org>
Subject: Re: [RFC PATCH v7 5/7] libbpf: Implement BTF type sorting validation for binary search optimization
Date: Mon, 24 Nov 2025 10:16:48 -0800	[thread overview]
Message-ID: <a254810a42510ad3adc00d27d1fd456710c7faa9.camel@gmail.com> (raw)
In-Reply-To: <CAErzpmv-CQy42LMFR4hzD4ANqL4ENnWyb0uKr7_FH1fj98S2QA@mail.gmail.com>

On Sat, 2025-11-22 at 23:45 +0800, Donglin Peng wrote:
> On Sat, Nov 22, 2025 at 5:05 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
> > 
> > On Sat, 2025-11-22 at 00:50 -0800, Eduard Zingerman wrote:
> > 
> > [...]
> > 
> > > > Thanks. I’ve looked into find_btf_percpu_datasec and we can’t use
> > > > btf_find_by_name_kind here because the search scope differs. For
> > > > a module BTF, find_btf_percpu_datasec only searches within the
> > > > module’s own BTF, whereas btf_find_by_name_kind prioritizes
> > > > searching the base BTF first. Thus, placing named types ahead is
> > > > more effective here. Besides, I found that the '.data..percpu' named
> > > > type will be placed at [1] for vmlinux BTF because the prefix '.' is
> > > > smaller than any letter, so the linear search only requires one loop to
> > > > locate it. However, if we put named types at the end, it will need more
> > > > than 60,000 loops..
> > > 
> > > But this can be easily fixed if a variant of btf_find_by_name_kind()
> > > is provided that looks for a match only in a specific BTF. Or accepts
> > > a start id parameter.
> > 
> > Also, I double checked, and for my vmlinux the id for '.data..percpu'
> > section is 110864, the last id of all. So, having all anonymous types
> > in front does not change status-quo compared to current implementation.
> 
> Yes. If types are sorted alphabetically, the '.data..percpu' section will
> have ID 1 in vmlinux BTF. In this case, linear search performance is
> optimal when named types are placed ahead of anonymous types.
> 
> I would like to understand the benefits of having anonymous types at the
> front of named types.

This will allow using strcmp() instead of btf_compare_type_names(),
which we have to copy both in kernel and in libbpf. Reducing the code
size and cognitive load.

  reply	other threads:[~2025-11-24 18:16 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19  3:15 [RFC PATCH v7 0/7] Improve the performance of BTF type lookups with binary search Donglin Peng
2025-11-19  3:15 ` [RFC PATCH v7 1/7] libbpf: Add BTF permutation support for type reordering Donglin Peng
2025-11-19 18:21   ` Andrii Nakryiko
2025-11-20  5:02     ` Donglin Peng
2025-11-20 23:21     ` Eduard Zingerman
2025-11-21 14:15       ` Donglin Peng
2025-11-19  3:15 ` [RFC PATCH v7 2/7] selftests/bpf: Add test cases for btf__permute functionality Donglin Peng
2025-11-19  4:51   ` Donglin Peng
2025-11-20 23:39   ` Eduard Zingerman
2025-11-21 14:17     ` Donglin Peng
2025-11-21  0:20   ` Eduard Zingerman
2025-11-19  3:15 ` [RFC PATCH v7 3/7] tools/resolve_btfids: Add --btf_sort option for BTF name sorting Donglin Peng
2025-11-20 21:34   ` Ihor Solodrai
2025-11-20 23:53     ` Ihor Solodrai
2025-11-21 15:36     ` Donglin Peng
2025-11-24 19:35       ` Ihor Solodrai
2025-11-25 10:54         ` Donglin Peng
2025-11-21  0:18   ` Eduard Zingerman
2025-11-24 12:14     ` Donglin Peng
2025-11-19  3:15 ` [RFC PATCH v7 4/7] libbpf: Optimize type lookup with binary search for sorted BTF Donglin Peng
2025-11-19  4:11   ` bot+bpf-ci
2025-11-19  4:43     ` Donglin Peng
2025-11-19 19:47   ` Andrii Nakryiko
2025-11-20  7:41     ` Donglin Peng
2025-11-19  3:15 ` [RFC PATCH v7 5/7] libbpf: Implement BTF type sorting validation for binary search optimization Donglin Peng
2025-11-19 19:50   ` Andrii Nakryiko
2025-11-20  7:25     ` Donglin Peng
2025-11-21 19:07       ` Eduard Zingerman
2025-11-22  7:19         ` Donglin Peng
2025-11-22  8:50           ` Eduard Zingerman
2025-11-22  9:05             ` Eduard Zingerman
2025-11-22 15:45               ` Donglin Peng
2025-11-24 18:16                 ` Eduard Zingerman [this message]
2025-11-25 10:53                   ` Donglin Peng
2025-11-22 15:59             ` Donglin Peng
2025-11-21 19:42       ` Eduard Zingerman
2025-11-22  7:32         ` Donglin Peng
2025-11-22  8:38           ` Donglin Peng
2025-11-24 18:20             ` Eduard Zingerman
2025-11-25 10:52               ` Donglin Peng
2025-11-19  3:15 ` [RFC PATCH v7 6/7] btf: Optimize type lookup with binary search Donglin Peng
2025-11-19  3:15 ` [RFC PATCH v7 7/7] btf: Add sorting validation for " 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=a254810a42510ad3adc00d27d1fd456710c7faa9.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dolinux.peng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pengdonglin@xiaomi.com \
    --cc=song@kernel.org \
    --cc=zhangxiaoqin@xiaomi.com \
    /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