Skip to content

bpf: compute btf_ids at build time for btf_iter

Yonghong Song bpf netdev 2 versions – Applied

Status from this message: Applied, Thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 3 repliesApplied
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- v1 ([1]) is only for bpf_skc_to_*() helpers. This version expanded it to cover ctx btf_id_or_null arguments
- abandoned the change of "extern u32 name[]" to "static u32 name[]" for BPF_ID_LIST local "name" definition. gcc 9 incurred a compilation error.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/5bpf: compute bpf_skc_to_*() helper socket btf ids at build timeinclude/linux/bpf.h kernel/bpf/btf.c net/core/filter.c+18 -360 replies
2/5tools/bpf: sync btf_ids.h to toolstools/include/linux/btf_ids.h tools/testing/selftests/bpf/prog_tests/resolve_btfids.c+11 -11 reply
3/5bpf: add BTF_ID_LIST_GLOBAL in btf_ids.hinclude/linux/btf_ids.h tools/include/linux/btf_ids.h tools/testing/selftests/bpf/prog_tests/resolve_btfids.c+39 -141 reply
4/5bpf: make btf_sock_ids globalinclude/linux/btf_ids.h net/core/filter.c tools/include/linux/btf_ids.h+62 -280 replies
5/5bpf: net: use precomputed btf_id for bpf iteratorsinclude/linux/bpf.h kernel/bpf/btf.c kernel/bpf/map_iter.c +5 more+38 -90 replies

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by.

PatchJiri Olsa
1/5
2/5
3/5A-b
4/5
5/5

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 bpf-next v2 0/5] bpf: compute btf_ids at build time for btf_iter

Commit 5a2798ab32ba
("bpf: Add BTF_ID_LIST/BTF_ID/BTF_ID_UNUSED macros") implemented a mechanism to compute btf_ids at kernel build time which can simplify kernel implementation and reduce runtime overhead by removing in-kernel btf_id calculation.

This patch set tried to use this mechanism to compute btf_ids for bpf_skc_to_*() helpers and for btf_id_or_null ctx arguments specified during bpf iterator registration. Please see individual patch for details.

Changelogs:
v1 -> v2:
- v1 ([1]) is only for bpf_skc_to_*() helpers. This version expanded it to cover ctx btf_id_or_null arguments
- abandoned the change of "extern u32 name[]" to "static u32 name[]" for BPF_ID_LIST local "name" definition. gcc 9 incurred a compilation error.

[1]: https://lore.kernel.org/bpf/[email protected]/T

Yonghong Song (5):
bpf: compute bpf_skc_to_*() helper socket btf ids at build time tools/bpf: sync btf_ids.h to tools
bpf: add BTF_ID_LIST_GLOBAL in btf_ids.h
bpf: make btf_sock_ids global
bpf: net: use precomputed btf_id for bpf iterators

 include/linux/bpf.h                           |  5 +-
 include/linux/btf_ids.h                       | 40 +++++++++++++--
 kernel/bpf/btf.c                              |  6 +--
 kernel/bpf/map_iter.c                         |  7 ++-
 kernel/bpf/task_iter.c                        | 12 ++++-
 net/core/filter.c                             | 49 ++----------------
 net/ipv4/tcp_ipv4.c                           |  4 +-
 net/ipv4/udp.c                                |  4 +-
 net/ipv6/route.c                              |  7 ++-
 net/netlink/af_netlink.c                      |  7 ++-
 tools/include/linux/btf_ids.h                 | 51 +++++++++++++++++--
 .../selftests/bpf/prog_tests/resolve_btfids.c | 34 ++++++++++---
 12 files changed, 153 insertions(+), 73 deletions(-)
Signature · 1 line
2.24.1