public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 dwarves 0/5] Improve BTF concrete function accuracy
@ 2026-01-23 17:26 Alan Maguire
  2026-01-23 17:26 ` [PATCH v2 dwarves 1/5] dwarf_loader/btf_encoder: Detect reordered parameters Alan Maguire
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Alan Maguire @ 2026-01-23 17:26 UTC (permalink / raw)
  To: yonghong.song, mattbobrowski
  Cc: ihor.solodrai, eddyz87, jolsa, andrii, ast, david.faust, dwarves,
	bpf, Alan Maguire

This series brings together a few solutions to issues we have
with accuracy of BTF function representation at the binary level.

The first patch detects mismatches between concrete (binary)
and abstract (source-level) function signatures as a means
of either excluding them or providing a "true" function signature.

Patch 2 adds GCC true function signature support for optimized
functions; with that support, we use binary-level signatures
for .isra.0, .constprop.0 functions and represent them with
their "." suffixes as BTF_KIND_FUNC names.

This allows for fentry attach to such functions, and
the "." suffix is an indicator of signature modification.
The feature is guarded by a default-off BTF feature because
older kernels did not support a "." in a function name.

Patch 3 uses Yonghong's example program as a test; compiling
with -O2 we expect a parameter to "foo" to be optimized
out and the true function signature should reflect that.

Patch 4 documents the non-default "true_signature" feature.

Patch 5 is Matt's patch to favour the strong function
over the associated weak declaration.  The other patches
are important prerequisites for this as the patch selects
the binary-level function (with a lowpc value), and in
the case of optimized functions we were often selecting
the .isra function with optimized-out parameters.  Because
pahole did not previously detect this correctly we ended
up with functions with signatures having reordered parameters.

Patches 1-2 help avoid this by better detecting optimized-out
function parameters.

With these patches in place, ~20 functions are omitted from
vmlinux BTF; all these are "."-suffixed functions which
we were not noticing had optimized-out parameters.

Experimenting with adding true_signature to BTF features
we end up adding approximately 500 .isra and .constprop
functions to vmlinux BTF.

The true function signature support here will also hopefully
help pave the way for Yonghong's work on the LLVM side.

Changes since v1 [1]

- dropped Yonghong's patch (Ihor)
- fixed up issues Yonghong found in true signature encoding
  where we did not adjust the number of parameters and
  were not handling true function signature case correctly
  when adding saved functions (Yonghong, patch 2)
- added test using Yonghong's example (patch 3)

[1] https://lore.kernel.org/dwarves/20260113131352.2395024-1-alan.maguire@oracle.com/

Alan Maguire (4):
  dwarf_loader/btf_encoder: Detect reordered parameters
  btf_encoder: Add true_signature feature support for "."-suffixed
    functions
  test: add gcc true signature test
  man-pages: document true_signature btf_feature

Matt Bobrowski (1):
  btf_encoder: Prefer strong function definitions for BTF generation

 btf_encoder.c                | 139 +++++++++++++++++++++++++++++++----
 dwarf_loader.c               |   5 +-
 dwarves.h                    |   3 +
 man-pages/pahole.1           |   5 ++
 pahole.c                     |   1 +
 tests/gcc_true_signatures.sh |  92 +++++++++++++++++++++++
 6 files changed, 227 insertions(+), 18 deletions(-)
 create mode 100755 tests/gcc_true_signatures.sh

-- 
2.43.5


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

end of thread, other threads:[~2026-01-27 12:19 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 17:26 [PATCH v2 dwarves 0/5] Improve BTF concrete function accuracy Alan Maguire
2026-01-23 17:26 ` [PATCH v2 dwarves 1/5] dwarf_loader/btf_encoder: Detect reordered parameters Alan Maguire
2026-01-26  9:30   ` Matt Bobrowski
2026-01-23 17:26 ` [PATCH v2 dwarves 2/5] btf_encoder: Add true_signature feature support for "."-suffixed functions Alan Maguire
2026-01-23 19:05   ` Yonghong Song
2026-01-26  9:52   ` Matt Bobrowski
2026-01-26 10:49     ` Alan Maguire
2026-01-26 11:18       ` Matt Bobrowski
2026-01-27 12:18         ` Alan Maguire
2026-01-23 17:26 ` [PATCH v2 dwarves 3/5] test: add gcc true signature test Alan Maguire
2026-01-23 19:06   ` Yonghong Song
2026-01-23 17:26 ` [PATCH v2 dwarves 4/5] man-pages: document true_signature btf_feature Alan Maguire
2026-01-23 19:07   ` Yonghong Song
2026-01-26 10:02   ` Matt Bobrowski
2026-01-26 10:51     ` Alan Maguire
2026-01-26 11:21       ` Matt Bobrowski
2026-01-26 17:10         ` Alan Maguire
2026-01-26 18:13           ` Yonghong Song
2026-01-23 17:26 ` [PATCH v2 dwarves 5/5] btf_encoder: Prefer strong function definitions for BTF generation Alan Maguire
2026-01-23 19:09   ` Yonghong Song

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