Re: [PATCH bpf-next v9 08/10] bpf: Skip anonymous types in type lookup for performance

From: Eduard Zingerman
Date: Wed Dec 17 2025 - 01:57:08 EST


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
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?

> /*
> * Assuming that types are sorted by name in ascending order.
> */

[...]