Skip to content

libbpf: rename btf__get_from_id() and btf__load() APIs, support split BTF

Quentin Monnet bpf netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 5 repliesIn review
  2. v25 patches 19 repliesSuperseded
  3. v16 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- Use libbpf_err_ptr() in btf__load_from_kernel_by_id(), ERR_PTR() in bpftool's get_map_kv_btf().
- Move the definition of btf__load_from_kernel_by_id() closer to the btf__parse() group in btf.h (move the legacy function with it).
- Fix a bug on the return value in libbpf_find_prog_btf_id(), as a new patch.
- Move the btf__free() fixes to their own patch.
- Add "Fixes:" tags to relevant patches.
- Re-introduce deprecation (removed in v2) for the legacy functions, as a new macro LIBBPF_DEPRECATED_SINCE(major, minor, message).

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8libbpf: return non-null error on failures in libbpf_find_prog_btf_id()tools/lib/bpf/libbpf.c+3 -10 replies
2/8libbpf: rename btf__load() as btf__load_into_kernel()tools/lib/bpf/btf.c tools/lib/bpf/btf.h tools/lib/bpf/libbpf.c +1 more+5 -20 replies
3/8libbpf: rename btf__get_from_id() as btf__load_from_kernel_by_id()tools/lib/bpf/btf.c tools/lib/bpf/btf.h tools/lib/bpf/libbpf.c +1 more+23 -110 replies
4/8tools: free BTF objects at various locationstools/bpf/bpftool/prog.c tools/perf/util/bpf-event.c tools/perf/util/bpf_counter.c +1 more+9 -40 replies
5/8tools: replace btf__get_from_id() with btf__load_from_kernel_by_id()tools/bpf/bpftool/btf.c tools/bpf/bpftool/btf_dumper.c tools/bpf/bpftool/map.c +4 more+42 -290 replies
6/8libbpf: prepare deprecation of btf__get_from_id(), btf__load()tools/lib/bpf/Makefile tools/lib/bpf/btf.h tools/lib/bpf/libbpf_common.h+24 -00 replies
7/8libbpf: add split BTF support for btf__load_from_kernel_by_id()tools/lib/bpf/btf.c tools/lib/bpf/btf.h tools/lib/bpf/libbpf.map+9 -20 replies
8/8tools: bpftool: support dumping split BTF by idtools/bpf/bpftool/btf.c+1 -10 replies

Reviews trailers per patch

5 of 8 patches have a Reviewed-by or Acked-by.

PatchJohn Fastabend
1/8
2/8A-b
3/8A-b
4/8
5/8A-b
6/8
7/8A-b
8/8A-b

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

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/8] libbpf: rename btf__get_from_id() and btf__load() APIs, support split BTF

As part of the effort to move towards a v1.0 for libbpf [0], this set improves some confusing function names related to BTF loading from and to the kernel:

- btf__load() becomes btf__load_into_kernel().
- btf__get_from_id becomes btf__load_from_kernel_by_id().
- A new version btf__load_from_kernel_by_id_split() extends the former to add support for split BTF.

The old functions are marked for deprecation for the next minor version (0.6) of libbpf.

The last patch is a trivial change to bpftool to add support for dumping split BTF objects by referencing them by their id (and not only by their BTF path).

[0] https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#btfh-apis

v3:
- Use libbpf_err_ptr() in btf__load_from_kernel_by_id(), ERR_PTR() in bpftool's get_map_kv_btf().
- Move the definition of btf__load_from_kernel_by_id() closer to the btf__parse() group in btf.h (move the legacy function with it).
- Fix a bug on the return value in libbpf_find_prog_btf_id(), as a new patch.
- Move the btf__free() fixes to their own patch.
- Add "Fixes:" tags to relevant patches.
- Re-introduce deprecation (removed in v2) for the legacy functions, as a new macro LIBBPF_DEPRECATED_SINCE(major, minor, message).

v2:
- Remove deprecation marking of legacy functions (patch 4/6 from v1).
- Make btf__load_from_kernel_by_id{,_split}() return the btf struct, adjust surrounding code and call btf__free() when missing.
- Add new functions to v0.5.0 API (and not v0.6.0).

Quentin Monnet (8):
libbpf: return non-null error on failures in libbpf_find_prog_btf_id()
libbpf: rename btf__load() as btf__load_into_kernel()
libbpf: rename btf__get_from_id() as btf__load_from_kernel_by_id()
tools: free BTF objects at various locations
tools: replace btf__get_from_id() with btf__load_from_kernel_by_id()
libbpf: prepare deprecation of btf__get_from_id(), btf__load()
libbpf: add split BTF support for btf__load_from_kernel_by_id()
tools: bpftool: support dumping split BTF by id

 tools/bpf/bpftool/btf.c                      |  8 ++---
 tools/bpf/bpftool/btf_dumper.c               |  6 ++--
 tools/bpf/bpftool/map.c                      | 14 ++++-----
 tools/bpf/bpftool/prog.c                     | 29 +++++++++++------
 tools/lib/bpf/Makefile                       |  3 ++
 tools/lib/bpf/btf.c                          | 33 ++++++++++++++------
 tools/lib/bpf/btf.h                          |  7 ++++-
 tools/lib/bpf/libbpf.c                       | 11 ++++---
 tools/lib/bpf/libbpf.map                     |  3 ++
 tools/lib/bpf/libbpf_common.h                | 19 +++++++++++
 tools/perf/util/bpf-event.c                  | 11 ++++---
 tools/perf/util/bpf_counter.c                | 12 +++++--
 tools/testing/selftests/bpf/prog_tests/btf.c |  4 ++-
 13 files changed, 113 insertions(+), 47 deletions(-)
Signature · 1 line
2.30.2