All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC bpf-next 0/3] bpf: Introduce module helper functions
@ 2022-01-21 19:39 Usama Arif
  2022-01-21 19:39 ` [RFC bpf-next 1/3] bpf: btf: Introduce infrastructure for module helpers Usama Arif
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Usama Arif @ 2022-01-21 19:39 UTC (permalink / raw)
  To: bpf, ast, daniel, andrii.nakryiko; +Cc: fam.zheng, cong.wang, song, Usama Arif

This patchset is a working prototype that adds support for calling helper
functions in eBPF applications that have been defined in a kernel module.

It would require further work including code refractoring (not included in
the patchset) to rename functions, data structures and variables that are
used for kfunc as well to be appropriately renamed for module helper usage.
If the idea of module helper functions and the approach used in this patchset
is acceptable to the bpf community, I can send a follow up patchset with the
code refractoring included to make it ready for review.

Module helpers are useful as:
- They support more argument and return types when compared to module
kfunc.
- This adds a way to have helper functions that would be too specialized
for a specific usecase to merge upstream, but are functions that can have
a constant API and can be maintained in-kernel modules.
- The number of in-kernel helpers have grown to a large number
(187 at the time of writing this commit). Having module helper functions
could possibly reduce the number of helper functions needing to be
in-kernel in the future and maintained upstream.

When the kernel module registers the helper, the module owner,
BTF id set of the function and function proto is stored as part of a
btf_mod_helper entry in a btf_mod_helper_list which is part of
struct btf. This entry can be removed in the unregister function
while exiting the module, and can be used by the bpf verifier to
check the helper call and get function proto.

This patchset also includes a very simple example selftest showing the
working of module helpers.

Usama Arif (3):
  bpf: btf: Introduce infrastructure for module helpers
  bpf: add support for module helpers in verifier
  selftests/bpf: add test for module helper

 include/linux/btf.h                           | 44 ++++++++++
 kernel/bpf/btf.c                              | 88 +++++++++++++++++++
 kernel/bpf/verifier.c                         | 50 ++++++++---
 tools/testing/selftests/bpf/Makefile          |  3 +-
 .../selftests/bpf/bpf_testmod/bpf_testmod.c   | 21 +++++
 .../selftests/bpf/prog_tests/helper_module.c  | 59 +++++++++++++
 .../selftests/bpf/progs/test_helper_module.c  | 18 ++++
 7 files changed, 271 insertions(+), 12 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/helper_module.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_helper_module.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-01-24 16:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 19:39 [RFC bpf-next 0/3] bpf: Introduce module helper functions Usama Arif
2022-01-21 19:39 ` [RFC bpf-next 1/3] bpf: btf: Introduce infrastructure for module helpers Usama Arif
2022-01-21 22:47   ` kernel test robot
2022-01-21 22:47     ` kernel test robot
2022-01-21 22:47   ` kernel test robot
2022-01-21 22:47     ` kernel test robot
2022-01-22  3:23   ` Kumar Kartikeya Dwivedi
2022-01-21 19:39 ` [RFC bpf-next 2/3] bpf: add support for module helpers in verifier Usama Arif
2022-01-22  3:31   ` Kumar Kartikeya Dwivedi
2022-01-22  3:56     ` Kumar Kartikeya Dwivedi
2022-01-24 16:23       ` Usama Arif
2022-01-21 19:39 ` [RFC bpf-next 3/3] selftests/bpf: add test for module helper Usama Arif
2022-01-21 22:48 ` [RFC bpf-next 0/3] bpf: Introduce module helper functions Alexei Starovoitov
2022-01-22  4:04   ` Kumar Kartikeya Dwivedi
2022-01-24 16:33     ` [External] " Usama Arif

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.