public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] libbpf: fix BTF dedup to support recursive typedef
@ 2025-11-13 12:39 Paul Houssel
  2025-11-13 12:39 ` [PATCH v4 1/2] libbpf: fix BTF dedup to support recursive typedef definitions Paul Houssel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Paul Houssel @ 2025-11-13 12:39 UTC (permalink / raw)
  To: Paul Houssel, Eduard Zingerman, bpf, linux-kselftest,
	linux-kernel
  Cc: Martin Horth, Ouail Derghal, Guilhem Jazeron, Ludovic Paillat,
	Robin Theveniaut, Tristan d'Audibert, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Shuah Khan, Paul Houssel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-15  1:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13 12:39 [PATCH v4 0/2] libbpf: fix BTF dedup to support recursive typedef Paul Houssel
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox