Skip to content

Switch BTF loading and encoding to libbpf APIs

Andrii Nakryiko bpf dwarves 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11libbpf: update to latest libbpf versionlib/bpf+1 -10 replies
2/11btf_encoder: detect BTF encoding errors and exitpahole.c+5 -20 replies
3/11dwarves: expose and maintain active debug info loader operationsdwarves.c+8 -00 replies
4/11btf_loader: use libbpf to load BTFbtf_loader.c libbtf.c libbtf.h+113 -2582 replies
5/11btf_encoder: use libbpf APIs to encode BTF type infobtf_encoder.c libbtf.c libbtf.h+295 -3510 replies
6/11btf_encoder: fix emitting __ARRAY_SIZE_TYPE__ as index range typebtf_encoder.c+21 -90 replies
7/11btf_encoder: discard CUs after BTF encodingpahole.c+1 -10 replies
8/11btf_encoder: revamp how per-CPU variables are encodedbtf_encoder.c libbtf.c libbtf.h+142 -1040 replies
9/11dwarf_loader: increase the size of lookup hash mapdwarf_loader.c+1 -10 replies
10/11strings: use BTF's string APIs for strings managementctf_encoder.c libctf.c libctf.h +2 more+49 -940 replies
11/11btf_encoder: support cross-compiled ELF binaries with different endiannesslibbtf.c+22 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH dwarves 00/11] Switch BTF loading and encoding to libbpf APIs

This patch set switches pahole to use libbpf-provided BTF loading and encoding APIs. This reduces pahole's own BTF encoding code, speeds up the process, reduces amount of RAM needed for DWARF-to-BTF conversion. Also, pahole finally gets support to generating BTF for cross-compiled ELF binaries with different endianness (patch #11).

Additionally, patch #6 fixes previously missed problem with invalid array index type generation.

Patches #7-10 are speeding up DWARF-to-BTF convertion/dedup pretty significantly, saving overall about 9 seconds out of current 27 or so.

Patch #8 revamps how per-CPU BTF variables are emitted, eliminating repeated and expensive looping over ELF symbols table.

Patch #10 admittedly has some hacky parts to satisfy CTF use case, but its speed ups are greatest. So I'll understand if it gets dropped, but it would be a pity.

More details could be found in respective patches.

Andrii Nakryiko (11):
libbpf: update to latest libbpf version
btf_encoder: detect BTF encoding errors and exit
dwarves: expose and maintain active debug info loader operations
btf_loader: use libbpf to load BTF
btf_encoder: use libbpf APIs to encode BTF type info
btf_encoder: fix emitting __ARRAY_SIZE_TYPE__ as index range type
btf_encoder: discard CUs after BTF encoding
btf_encoder: revamp how per-CPU variables are encoded
dwarf_loader: increase the size of lookup hash map
strings: use BTF's string APIs for strings management
btf_encoder: support cross-compiled ELF binaries with different
endianness

 btf_encoder.c  | 361 +++++++++++++++------------
 btf_loader.c   | 244 +++++++-----------
 ctf_encoder.c  |   2 +-
 dwarf_loader.c |   2 +-
 dwarves.c      |   8 +
 lib/bpf        |   2 +-
 libbtf.c       | 661 +++++++++++++++++++++----------------------------
 libbtf.h       |  41 ++-
 libctf.c       |  14 +-
 libctf.h       |   4 +-
 pahole.c       |   9 +-
 strings.c      |  91 +++----
 strings.h      |  32 +--
 13 files changed, 653 insertions(+), 818 deletions(-)
Signature · 1 line
2.24.1