From: Eduard Zingerman <eddyz87@gmail.com>
To: Paul Houssel <paulhoussel2@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: Re: [PATCH v2 1/2] libbpf: fix BTF dedup to support recursive typedef definitions
Date: Wed, 12 Nov 2025 12:16:45 -0800 [thread overview]
Message-ID: <31a5fcc60535d93b8b8ab7e9ca38487038fc38f7.camel@gmail.com> (raw)
In-Reply-To: <c1b79b23c2a20964792961f23348970ebaee14b8.1762956565.git.paul.houssel@orange.com>
On Wed, 2025-11-12 at 15:11 +0100, Paul Houssel wrote:
> Handle recursive typedefs in BTF deduplication
>
> 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_ref_type() 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.
>
> Co-developed-by: Martin Horth <martin.horth@telecom-sudparis.eu>
> Signed-off-by: Martin Horth <martin.horth@telecom-sudparis.eu>
> Co-developed-by: Ouail Derghal <ouail.derghal@imt-atlantique.fr>
> Signed-off-by: Ouail Derghal <ouail.derghal@imt-atlantique.fr>
> Co-developed-by: Guilhem Jazeron <guilhem.jazeron@inria.fr>
> Signed-off-by: Guilhem Jazeron <guilhem.jazeron@inria.fr>
> Co-developed-by: Ludovic Paillat <ludovic.paillat@inria.fr>
> Signed-off-by: Ludovic Paillat <ludovic.paillat@inria.fr>
> Co-developed-by: Robin Theveniaut <robin.theveniaut@irit.fr>
> Signed-off-by: Robin Theveniaut <robin.theveniaut@irit.fr>
> Suggested-by: Tristan d'Audibert <tristan.daudibert@gmail.com>
> Signed-off-by: Paul Houssel <paul.houssel@orange.com>
>
> ---
No differences in BTF generated for kernel when using pahole built
against libbpf with and without this patch.
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> @@ -4939,7 +4979,7 @@ static int btf_dedup_struct_types(struct btf_dedup *d)
> /*
> * Deduplicate reference type.
> *
> - * Once all primitive and struct/union types got deduplicated, we can easily
> + * Once all primitive, struct/union and typedef types got deduplicated, we can easily
> * deduplicate all other (reference) BTF types. This is done in two steps:
> *
> * 1. Resolve all referenced type IDs into their canonical type IDs. This
Nit: this passage continues as:
* There is no danger of encountering cycles because in C type
* system the only way to form type cycle is through struct/union, so any chain
* of reference types, even those taking part in a type cycle, will inevitably
* reach struct/union at some point.
I think it needs adjustment to refer to typedef as well.
[...]
next prev parent reply other threads:[~2025-11-12 20:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 14:11 [PATCH v2 0/2] libbpf: fix BTF dedup to support recursive typedef Paul Houssel
2025-11-12 14:11 ` [PATCH v2 1/2] libbpf: fix BTF dedup to support recursive typedef definitions Paul Houssel
2025-11-12 20:16 ` Eduard Zingerman [this message]
2025-11-12 14:11 ` [PATCH v2 2/2] selftests/bpf: add BTF dedup tests for " Paul Houssel
2025-11-12 20:28 ` Eduard Zingerman
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=31a5fcc60535d93b8b8ab7e9ca38487038fc38f7.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--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=paulhoussel2@gmail.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