From: Paul Houssel <paulhoussel2@gmail.com>
To: Paul Houssel <paulhoussel2@gmail.com>,
Eduard Zingerman <eddyz87@gmail.com>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Martin Horth <martin.horth@telecom-sudparis.eu>,
Ouail Derghal <ouail.derghal@imt-atlantique.fr>,
Guilhem Jazeron <guilhem.jazeron@inria.fr>,
Ludovic Paillat <ludovic.paillat@inria.fr>,
Robin Theveniaut <robin.theveniaut@irit.fr>,
Tristan d'Audibert <tristan.daudibert@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Paul Houssel <paul.houssel@orange.com>
Subject: [PATCH v4 0/2] libbpf: fix BTF dedup to support recursive typedef
Date: Thu, 13 Nov 2025 13:39:49 +0100 [thread overview]
Message-ID: <cover.1763037045.git.paul.houssel@orange.com> (raw)
Pahole fails to encode BTF for some Go projects (e.g. Kubernetes and
Podman) due to recursive type definitions that create reference loops
not representable in C. These recursive typedefs trigger a failure in
the BTF deduplication algorithm.
This patch extends btf_dedup_struct_types() to properly handle potential
recursion for BTF_KIND_TYPEDEF, similar to how recursion is already
handled for BTF_KIND_STRUCT. This allows pahole to successfully
generate BTF for Go binaries using recursive types without impacting
existing C-based workflows.
Changes in v4: fix typo found by Claude-based CI
Changes in v3:
1. Patch 1: Adjusted the comment of btf_dedup_ref_type() to refer to
typedef as well.
2. Patch 2: Update of the "dedup: recursive typedef" test to include a
duplicated version of the types to make sure deduplication still happens
in this case.
Changes in v2:
1. Patch 1: Refactored code to prevent copying existing logic. Instead of
adding a new function we modify the existing btf_dedup_struct_type()
function to handle the BTF_KIND_TYPEDEF case. Calls to btf_hash_struct()
and btf_shallow_equal_struct() are replaced with calls to functions that
select btf_hash_struct() / btf_hash_typedef() based on the type.
2. Patch 2: Added tests
v3: https://lore.kernel.org/lkml/cover.1763024337.git.paul.houssel@orange.com/
v2: https://lore.kernel.org/lkml/cover.1762956564.git.paul.houssel@orange.com/
v1: https://lore.kernel.org/lkml/20251107153408.159342-1-paulhoussel2@gmail.com/
Paul Houssel (2):
libbpf: fix BTF dedup to support recursive typedef definitions
selftests/bpf: add BTF dedup tests for recursive typedef definitions
tools/lib/bpf/btf.c | 71 +++++++++++++++-----
tools/testing/selftests/bpf/prog_tests/btf.c | 65 ++++++++++++++++++
2 files changed, 120 insertions(+), 16 deletions(-)
--
2.51.0
next reply other threads:[~2025-11-13 12:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 12:39 Paul Houssel [this message]
2025-11-13 12:39 ` [PATCH v4 1/2] libbpf: fix BTF dedup to support recursive typedef definitions Paul Houssel
2025-11-13 19:21 ` Eduard Zingerman
2025-11-13 12:39 ` [PATCH v4 2/2] selftests/bpf: add BTF dedup tests for " Paul Houssel
2025-11-13 19:21 ` Eduard Zingerman
2025-11-15 1:30 ` [PATCH v4 0/2] libbpf: fix BTF dedup to support recursive typedef 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=cover.1763037045.git.paul.houssel@orange.com \
--to=paulhoussel2@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=guilhem.jazeron@inria.fr \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=ludovic.paillat@inria.fr \
--cc=martin.horth@telecom-sudparis.eu \
--cc=martin.lau@linux.dev \
--cc=ouail.derghal@imt-atlantique.fr \
--cc=paul.houssel@orange.com \
--cc=robin.theveniaut@irit.fr \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tristan.daudibert@gmail.com \
--cc=yonghong.song@linux.dev \
/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