public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: polo <paulhoussel2@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, 	song@kernel.org, yonghong.song@linux.dev,
	john.fastabend@gmail.com, 	kpsingh@kernel.org, sdf@fomichev.me,
	haoluo@google.com, jolsa@kernel.org, 	bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Paul Houssel	 <paul.houssel@orange.com>,
	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>
Subject: Re: [PATCH] libbpf: fix BTF dedup to support recursive typedef definitions
Date: Mon, 10 Nov 2025 11:06:54 -0800	[thread overview]
Message-ID: <a27413bc0fb9a4d8925366b239aa08f195164810.camel@gmail.com> (raw)
In-Reply-To: <CA+aJb_27fAdAXNwkYCxTKaWCCOdiWmJc7a_qhpmykXqxMjJYMA@mail.gmail.com>

On Fri, 2025-11-07 at 21:49 +0100, polo wrote:
> Hello Eduard,
> 
> On Fri, 7 Nov 2025 at 20:45, Eduard Zingerman <eddyz87@gmail.com> wrote:
> > 
> > On Fri, 2025-11-07 at 16:34 +0100, paulhoussel2@gmail.com wrote:
> > > From: Paul Houssel <paul.houssel@orange.com>
> > > 
> > > 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>
> > > 
> > > ---
> > > The issue was originally observed when attempting to encode BTF for
> > > Kubernetes binaries (kubectl, kubeadm):
> > > 
> > > $ git clone --depth 1 https://github.com/kubernetes/kubernetes
> > > $ cd ./kubernetes
> > > $ make kubeadm DBG=1
> > > $ pahole --btf_encode_detached=kubeadm.btf _output/bin/kubeadm
> > > btf_encoder__encode: btf__dedup failed!
> > > Failed to encode BTF
> > 
> > Hi Paul,
> > 
> > Could you please provide some details on why would you like to use BTF
> > for golang programs?
> 
> We would like to use BTF for Golang programs in order to trace
> compiled Go user-space applications using eBPF uprobe programs.
> Tetragon [1] implements the use of the BTF file to resolve paths to
> attributes in hook parameters, and therefore if we can obtain the BTF
> for Go programs, we will be able to start reading any attributes.
> Recently, this feature has been extended to support uprobes [2].
> 
> [1] https://tetragon.io/docs/concepts/tracing-policy/hooks/#attribute-resolution
> [2] https://github.com/cilium/tetragon/pull/4286#pullrequestreview-3427725698
> 
> > Also, is this the only scenario when golang
> > generated DWARF has loops not possible in C code?
> 
> This is the only scenario we’ve identified where Golang DWARF contains
> loops, which are not possible in C. We’re not aware of any other
> Go-specific characteristics that could cause additional DWARF loops.
> We tested BTF generation on a set of Go projects that are quite large
> and representative of the diversity of Go programs, and we only
> observed loops for this specific typedef usage.
> 
> Paul Houssel

Hi Paul,

Thank you for explaining, this sounds like a reasonable use-case.
I'll comment on the patch itself in the separate email.

Thanks,
Eduard

  reply	other threads:[~2025-11-10 19:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07 15:34 [PATCH] libbpf: fix BTF dedup to support recursive typedef definitions paulhoussel2
2025-11-07 19:45 ` Eduard Zingerman
2025-11-07 20:49   ` polo
2025-11-10 19:06     ` Eduard Zingerman [this message]
2025-11-10 19:14 ` 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=a27413bc0fb9a4d8925366b239aa08f195164810.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=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=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