BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Donglin Peng <dolinux.peng@gmail.com>
Cc: ast@kernel.org, andrii.nakryiko@gmail.com,
	zhangxiaoqin@xiaomi.com,  ihor.solodrai@linux.dev,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
	pengdonglin <pengdonglin@xiaomi.com>,
	Alan Maguire <alan.maguire@oracle.com>
Subject: Re: [PATCH bpf-next v9 08/10] bpf: Skip anonymous types in type lookup for performance
Date: Wed, 17 Dec 2025 09:29:10 -0800	[thread overview]
Message-ID: <239e3861b030a8d68f24a5be72346ffedffb8843.camel@gmail.com> (raw)
In-Reply-To: <CAErzpmt9HKPfyrc_iW5QjT1=E5mUwFcKJihga0s-WBhqE6uiwg@mail.gmail.com>

On Wed, 2025-12-17 at 17:21 +0800, Donglin Peng wrote:
> On Wed, Dec 17, 2025 at 2:55 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
> > 
> > On Mon, 2025-12-08 at 14:23 +0800, Donglin Peng wrote:
> > 
> > [...]
> > 
> > > @@ -550,6 +550,11 @@ u32 btf_nr_types(const struct btf *btf)
> > >       return total;
> > >  }
> > > 
> > > +u32 btf_sorted_start_id(const struct btf *btf)
> > > +{
> > > +     return btf->sorted_start_id ?: (btf->start_id ?: 1);
> > > +}
> > > +
> > 
> > I think that changes in this patch are correct.  However, it seems
> 
> Thanks, I think the changes to btf_find_decl_tag_value and
> btf_prepare_func_args will cause issues if the input btf is a
> split BTF. We should search from its base BTF. Like this:
> 
> const struct btf *base_btf = btf;
> while (btf_base_btf(base_btf))
>         base_btf = btf_base_btf(base_btf);
> id = base_btf->sorted_start_id > 0 ? base_btf->sorted_start_id - 1 : 0;

Missed that, makes sense.

> > error prone to remember that sorted_start_id is always set for
> > vmlinux/module BTF and might not be set for program BTF.
> > Wdyt about using the above function everywhere instead of directly
> > reading the field?
> 
> Agreed. If so, I think we need to add another helper function to check
> whether the input BTF is sorted to improve code clarity.
> 
> bool btf_is_sorted(const struct btf *btf)
> {
>         return btf->sorted_start_id > 0;
> }

Sure, as you see fit.

> Besides, do you think we should reject loading a  kernel module that is
> not sorted?

Not my strong side. As far as I understand, when external modules are
built for production use-cases DKMS is used. DKMS will use same
resolve_btfids as the kernel module is built for. Hence reject the
modules with not sorted BTFs should be fine. Are there other use-cases
when mismatch between resolve_btfids versions is allowed?

  reply	other threads:[~2025-12-17 17:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08  6:23 [PATCH bpf-next v9 00/10] Improve the performance of BTF type lookups with binary search Donglin Peng
2025-12-08  6:23 ` [PATCH bpf-next v9 01/10] libbpf: Add BTF permutation support for type reordering Donglin Peng
2025-12-16 22:00   ` Eduard Zingerman
2025-12-16 22:47     ` Andrii Nakryiko
2025-12-17  3:30     ` Donglin Peng
2025-12-08  6:23 ` [PATCH bpf-next v9 02/10] selftests/bpf: Add test cases for btf__permute functionality Donglin Peng
2025-12-16 22:00   ` Eduard Zingerman
2025-12-08  6:23 ` [PATCH bpf-next v9 03/10] tools/resolve_btfids: Support BTF sorting feature Donglin Peng
2025-12-16 22:13   ` Eduard Zingerman
2025-12-08  6:23 ` [PATCH bpf-next v9 04/10] libbpf: Optimize type lookup with binary search for sorted BTF Donglin Peng
2025-12-16 23:38   ` Eduard Zingerman
2025-12-16 23:43     ` Eduard Zingerman
2025-12-17  2:46       ` Donglin Peng
2025-12-17  2:32     ` Donglin Peng
2025-12-17  2:34       ` Donglin Peng
2025-12-17  2:57       ` Eduard Zingerman
2025-12-08  6:23 ` [PATCH bpf-next v9 05/10] libbpf: Verify BTF Sorting Donglin Peng
2025-12-17  0:32   ` Eduard Zingerman
2025-12-17  3:19     ` Donglin Peng
2025-12-08  6:23 ` [PATCH bpf-next v9 06/10] btf: Optimize type lookup with binary search Donglin Peng
2025-12-08  6:23 ` [PATCH bpf-next v9 07/10] btf: Verify BTF Sorting Donglin Peng
2025-12-09  3:21   ` Donglin Peng
2025-12-17  0:41     ` Eduard Zingerman
2025-12-17  0:48   ` Eduard Zingerman
2025-12-17  3:26     ` Donglin Peng
2025-12-08  6:23 ` [PATCH bpf-next v9 08/10] bpf: Skip anonymous types in type lookup for performance Donglin Peng
2025-12-08  6:36   ` Donglin Peng
2025-12-17  6:55   ` Eduard Zingerman
2025-12-17  9:21     ` Donglin Peng
2025-12-17 17:29       ` Eduard Zingerman [this message]
2025-12-18  9:16         ` Donglin Peng
2025-12-08  6:23 ` [PATCH bpf-next v9 09/10] bpf: Optimize the performance of find_bpffs_btf_enums Donglin Peng
2025-12-17  6:58   ` Eduard Zingerman
2025-12-08  6:23 ` [PATCH bpf-next v9 10/10] libbpf: Optimize the performance of determine_ptr_size Donglin Peng
2025-12-17  7:06   ` Eduard Zingerman
2025-12-17  8:38     ` 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=239e3861b030a8d68f24a5be72346ffedffb8843.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=ihor.solodrai@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pengdonglin@xiaomi.com \
    --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