Skip to content

bpf: Add __bpf_kfunc tag for kfunc definitions

David Vernet bpf lkml 2 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 0 repliesApplied 4/4
  2. v13 patches 8 repliesSuperseded

Changes in v3 from the cover letter

- Go back to the __bpf_kfunc approach from v1. The BPF_KFUNC macro received pushback as it didn't match the more typical EXPORT_SYMBOL* APIs used elsewhere in the kernel. It's the longer term plan, but for now we're proposing something less controversial to fix kfuncs and BTF encoding.
- Add __bpf_kfunc macro to newly added cpumask kfuncs.
- Add __bpf_kfunc macro to newly added XDP metadata kfuncs, which were failing to be BTF encoded in the thread in [2].
- Update patch description(s) to reference the discussions in [2].
- Add a selftest that validates that a static kfunc with unused args is properly BTF encoded and can be invoked.

Patches in v3 All 4 applied

#Subject and filesSizeRepliesApplied
1/4bpf: Add __bpf_kfunc tag for marking kernel functions as kfuncsinclude/linux/btf.h+8 -00 repliesApplied
2/4bpf: Document usage of the new __bpf_kfunc macroDocumentation/bpf/kfuncs.rst Documentation/conf.py+20 -30 repliesApplied
3/4bpf: Add __bpf_kfunc tag to all kfuncskernel/bpf/cpumask.c kernel/bpf/helpers.c kernel/cgroup/rstat.c +12 more+130 -1280 repliesApplied
4/4selftests/bpf: Add testcase for static kfunc with unused argnet/bpf/test_run.c tools/testing/selftests/bpf/prog_tests/kfunc_call.c tools/testing/selftests/bpf/progs/kfunc_call_test.c+18 -00 repliesApplied

Reviews trailers per patch

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

PatchStanislav Fomichev
1/4A-b
2/4A-b
3/4A-b
4/4

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/4] bpf: Add __bpf_kfunc tag for kfunc definitions

This is v3 of the patchset [0]. v2 can be found at [1].

[0]: https://lore.kernel.org/bpf/Y7kCsjBZ%2FFrsWW%[email protected]/T/
[1]: https://lore.kernel.org/lkml/[email protected]/

Changelog:
----------
v2 -> v3:
- Go back to the __bpf_kfunc approach from v1. The BPF_KFUNC macro received pushback as it didn't match the more typical EXPORT_SYMBOL* APIs used elsewhere in the kernel. It's the longer term plan, but for now we're proposing something less controversial to fix kfuncs and BTF encoding.
- Add __bpf_kfunc macro to newly added cpumask kfuncs.
- Add __bpf_kfunc macro to newly added XDP metadata kfuncs, which were failing to be BTF encoded in the thread in [2].
- Update patch description(s) to reference the discussions in [2].
- Add a selftest that validates that a static kfunc with unused args is properly BTF encoded and can be invoked.

[2]: https://lore.kernel.org/all/[email protected]/

v1 -> v2:
- Wrap entire function signature in BPF_KFUNC macro instead of using __bpf_kfunc tag (Kumar)
- Update all kfunc definitions to use this macro.
- Update kfuncs.rst documentation to describe and illustrate the macro.
- Also clean up a few small parts of kfuncs.rst, e.g. some grammar, and in general making it a bit tighter.

David Vernet (4):
bpf: Add __bpf_kfunc tag for marking kernel functions as kfuncs
bpf: Document usage of the new __bpf_kfunc macro
bpf: Add __bpf_kfunc tag to all kfuncs
selftests/bpf: Add testcase for static kfunc

 Documentation/bpf/kfuncs.rst                  | 20 +++++-
 Documentation/conf.py                         |  3 +
 include/linux/btf.h                           |  8 +++
 kernel/bpf/cpumask.c                          | 60 +++++++++---------
 kernel/bpf/helpers.c                          | 38 ++++++------
 kernel/cgroup/rstat.c                         |  4 +-
 kernel/kexec_core.c                           |  3 +-
 kernel/trace/bpf_trace.c                      |  8 +--
 net/bpf/test_run.c                            | 61 +++++++++++--------
 net/core/xdp.c                                |  5 +-
 net/ipv4/tcp_bbr.c                            | 16 ++---
 net/ipv4/tcp_cong.c                           | 10 +--
 net/ipv4/tcp_cubic.c                          | 12 ++--
 net/ipv4/tcp_dctcp.c                          | 12 ++--
 net/netfilter/nf_conntrack_bpf.c              | 20 +++---
 net/netfilter/nf_nat_bpf.c                    |  6 +-
 net/xfrm/xfrm_interface_bpf.c                 |  7 +--
 .../selftests/bpf/bpf_testmod/bpf_testmod.c   |  2 +-
 .../selftests/bpf/prog_tests/kfunc_call.c     |  1 +
 .../selftests/bpf/progs/kfunc_call_test.c     | 11 ++++
 20 files changed, 176 insertions(+), 131 deletions(-)
Signature · 1 line
2.39.0