[PATCH 23/31] pahole: Skip inline expansions during BTF encoding

Arnaldo Carvalho de Melo <[email protected]> Wed, 29 Jul 2026 16:07:23 -0300
Newsgroups org.kernel.vger.dwarves,org.kernel.vger.bpf
Message-ID <[email protected]>
From: Arnaldo Carvalho de Melo <[email protected]>

Enable ignore_inline_expansions for BTF encoding (-J).  Inline
expansions (DW_TAG_inlined_subroutine) describe code-flow inlining
decisions — the BTF encoder never uses them (it encodes types, not
code structure).

Skipping them avoids allocating and recursively processing one of
the most numerous DWARF tag types in a vmlinux, reducing memory
usage and DWARF processing time for BTF generation.

This mirrors the existing ignore_labels optimization that was
already enabled for BTF encoding.

In a vmlinux with 548,620 DW_TAG_inlined_subroutine DIEs (the 6th
most common tag type):

  Before (processing inline expansions):
    $ time pahole -J --btf_encode_detached /tmp/t.btf vmlinux
    7.41s, 1057 MB max RSS

  After (skipping inline expansions):
    $ time pahole -J --btf_encode_detached /tmp/t.btf vmlinux
    7.06s, 1042 MB max RSS

  ~5% faster BTF encoding, 15 MB less peak memory.  The savings
  scale with the inline expansion count — heavily-inlined codebases
  like the kernel benefit the most.

Assisted-by: Claude:claude-sonnet-4-5
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
 pahole.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/pahole.c b/pahole.c
index a6012e6a157293e9..65becc938cb0fc01 100644
--- a/pahole.c
+++ b/pahole.c
@@ -1891,9 +1891,7 @@ static error_t pahole__options_parser(int key, char *arg,
 	case 'J': btf_encode = 1;
 		  conf_load.get_addr_info = true;
 		  conf_load.ignore_alignment_attr = true;
-		  // XXX for now, test this more thoroughly
-		  // We may have some references from formal parameters, etc, (abstract_origin)
-		  // conf_load.ignore_inline_expansions = true;
+		  conf_load.ignore_inline_expansions = true;
 		  conf_load.ignore_labels	     = true;
 		  conf_load.use_obstack		     = true;
 		  no_bitfield_type_recode = true;	break;
-- 
2.55.0