Skip to content

libbpf: add bulk BTF type copying API

[email protected] bpf 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (refs/heads/master):

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 0 repliesApplied 3/3
  2. v13 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- fix typo in doc comment and selftest clean up fix (Song).

Patches in v2 All 3 applied

#Subject and filesSizeRepliesApplied
1/3libbpf: add API that copies all BTF types from one BTF object to anothertools/lib/bpf/btf.c tools/lib/bpf/btf.h tools/lib/bpf/libbpf.map+135 -20 repliesApplied
2/3selftests/bpf: refactor btf_write selftest to reuse BTF generation logictools/testing/selftests/bpf/prog_tests/btf_write.c+49 -60 repliesApplied
3/3selftests/bpf: test new btf__add_btf() APItools/testing/selftests/bpf/prog_tests/btf_write.c+86 -00 repliesApplied

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchSong Liu
1/3A-b
2/3A-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 bpf-next 0/3] libbpf: add bulk BTF type copying API

From: Andrii Nakryiko <[email protected]>

Add bulk BTF type data copying API, btf__add_btf(), to libbpf. This API is useful for tools that are manipulating BPF, such as pahole. They abstract away the details of implementing a pretty mundane, but important to get right, details of handling all possible BTF kinds, as well as, importantly, adjusting BTF type IDs and copying/deduplicating strings and string offsets, referenced from copied BTF types.

Also, being a batch API, it's possible to improve the efficiency by preallocating necessary memory more efficiently.

This API is going to be used by pahole to implement efficient parallelized BTF encoding.

v1->v2:
- fix typo in doc comment and selftest clean up fix (Song).

Cc Arnaldo Carvalho de Melo <[email protected]>

Andrii Nakryiko (3):
libbpf: add API that copies all BTF types from one BTF object to
another
selftests/bpf: refactor btf_write selftest to reuse BTF generation
logic
selftests/bpf: test new btf__add_btf() API

 tools/lib/bpf/btf.c                           | 114 +++++++++++++-
 tools/lib/bpf/btf.h                           |  22 +++
 tools/lib/bpf/libbpf.map                      |   1 +
 .../selftests/bpf/prog_tests/btf_write.c      | 141 +++++++++++++++++-
 4 files changed, 270 insertions(+), 8 deletions(-)
Signature · 1 line
2.30.2