Re: [PATCH v3 1/2] libbpf: fix BTF dedup to support recursive typedef definitions

From: bot+bpf-ci

Date: Thu Nov 13 2025 - 06:42:42 EST


> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 9f141395c..5c4035eb9 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c

[ ... ]

> @@ -4844,14 +4865,31 @@ static void btf_dedup_merge_hypot_map(struct btf_dedup *d)
> }
> }
>
> +static inline long btf_hash_by_kind(struct btf_type *t, __u16 kind)
> +{
> + if (kind == BTF_KIND_TYPEDEF)
> + return btf_hash_typedef(t);
> + else
> + return btf_hash_struct(t);
> +}
> +
> +static inline bool btf_equal_by_kind(struct btf_type *t1, struct btf_type *t2, __u16 kind)
> +{
> + if (kind == BTF_KIND_TYPEDEF)
> + return btf_equal_typedef(t1, t2);
> + else
> + return btf_shallow_equal_struct(t1, t2);
> +}
> +
> /*
> - * Deduplicate struct/union types.
> + * Deduplicate struct/union and typedef types.
> *
> * For each struct/union type its type signature hash is calculated, taking
> * into account type's name, size, number, order and names of fields, but
> * ignoring type ID's referenced from fields, because they might not be deduped
> - * completely until after reference types deduplication phase. This type hash
> - * is used to iterate over all potential canonical types, sharing same hash.
> + * completely until after reference types deduplication phase. For each typedef
> + * type, the hash is computed based on the type's name and size. This type hash
> + * is used to iterate over all potential canonical types, sharingsame hash.
^^^^^^^^^^

This isn't a bug, but there's a typo here - "sharingsame" should be
"sharing same" (two words).

> * For each canonical candidate we check whether type graphs that they form
> * (through referenced types in fields and so on) are equivalent using algorithm
> * implemented in `btf_dedup_is_equiv`. If such equivalence is found and

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/19329986070