From: Antoine Tenart <atenart@kernel.org>
To: andrii@kernel.org, eddyz87@gmail.com
Cc: Antoine Tenart <atenart@kernel.org>,
bpf@vger.kernel.org, Paul Houssel <paulhoussel2@gmail.com>,
Alan Maguire <alan.maguire@oracle.com>
Subject: [PATCH bpf v2 1/2] libbpf: fix deduplication of typedef with base definitions
Date: Fri, 17 Apr 2026 10:33:17 +0200 [thread overview]
Message-ID: <20260417083319.32716-1-atenart@kernel.org> (raw)
When deduplicating definitions for a module, typedef defined in the base
are not removed. This is because the hash used for base types differs
from the one used in the deduplication logic in btf_dedup_struct_type.
This was introduced by the referenced commit when moving the typedef
deduplication logic handling from btf_dedup_ref_type to
btf_dedup_struct_type, as this also changed the hash logic
(btf_hash_common to btf_hash_typedef).
This also impacts other types referencing those typedef (e.g. const). In
my test, the BTF section size of the openvswitch module went from 31KB
to 45KB.
Cc: Paul Houssel <paulhoussel2@gmail.com>
Fixes: 3781413465df ("libbpf: Fix BTF dedup to support recursive typedef definitions").
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Antoine Tenart <atenart@kernel.org>
---
tools/lib/bpf/btf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index ceb57b46a878..771aeaa0262b 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -4578,12 +4578,14 @@ static int btf_dedup_prep(struct btf_dedup *d)
case BTF_KIND_RESTRICT:
case BTF_KIND_PTR:
case BTF_KIND_FWD:
- case BTF_KIND_TYPEDEF:
case BTF_KIND_FUNC:
case BTF_KIND_FLOAT:
case BTF_KIND_TYPE_TAG:
h = btf_hash_common(t);
break;
+ case BTF_KIND_TYPEDEF:
+ h = btf_hash_typedef(t);
+ break;
case BTF_KIND_INT:
case BTF_KIND_DECL_TAG:
h = btf_hash_int_decl_tag(t);
--
2.53.0
next reply other threads:[~2026-04-17 8:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 8:33 Antoine Tenart [this message]
2026-04-17 8:33 ` [PATCH bpf v2 2/2] selftests/bpf: ensure typedef are deduplicated in split BTF Antoine Tenart
2026-04-17 22:10 ` [PATCH bpf v2 1/2] libbpf: fix deduplication of typedef with base definitions Alan Maguire
2026-04-22 21:20 ` patchwork-bot+netdevbpf
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=20260417083319.32716-1-atenart@kernel.org \
--to=atenart@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=paulhoussel2@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.