Skip to contentSkip to conversation

bpf: Update doc about calling kernel function

PATCH Applied Martin KaFai Lau 3 participants 6 messages Mar 30, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover bpf: Update doc about calling kernel function

This set updates the document about the bpf program calling kernel function. In particular, updates are regarding to the clang requirement in selftests and kfunc-call not an ABI.

Martin KaFai Lau (2):
bpf: Update bpf_design_QA.rst to clarify the kfunc call is not ABI
bpf: selftests: Update clang requirement in README.rst for testing
kfunc call

 Documentation/bpf/bpf_design_QA.rst    | 15 +++++++++++++++
 tools/testing/selftests/bpf/README.rst | 14 ++++++++++++++
 2 files changed, 29 insertions(+)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 bpf: Update bpf_design_QA.rst to clarify the kfunc call is not ABI

This patch updates bpf_design_QA.rst to clarify that the kernel function callable by bpf program is not an ABI.

---
 Documentation/bpf/bpf_design_QA.rst | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Documentation/bpf/bpf_design_QA.rst +15 -0
index 0e15f9b05c9d..437de2a7a5de 100644
@@ -258,3 +258,18 @@ Q: Can BPF functionality such as new program or map types, new
 helpers, etc be added out of kernel module code?
 
 A: NO.
+
+Q: Directly calling kernel function is an ABI?
+----------------------------------------------
+Q: Some kernel functions (e.g. tcp_slow_start) can be called
+by BPF programs.  Do these kernel functions become an ABI?
+
+A: NO.
+
+The kernel function protos will change and the bpf programs will be
+rejected by the verifier.  Also, for example, some of the bpf-callable
+kernel functions have already been used by other kernel tcp
+cc (congestion-control) implementations.  If any of these kernel
+functions has changed, both the in-tree and out-of-tree kernel tcp cc
+implementations have to be changed.  The same goes for the bpf
+programs and they have to be adjusted accordingly.
Signature · 1 line
2.30.2
#3 lore raw

PATCH 2/2 bpf: selftests: Update clang requirement in README.rst for testing kfunc call

In reply to Martin KaFai Lau

This patch updates the README.rst to specify the clang requirement to compile the bpf selftests that call kernel function.

---
 tools/testing/selftests/bpf/README.rst | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tools/testing/selftests/bpf/README.rst +14 -0
index 3464161c8eea..65fe318d1e71 100644
@@ -179,3 +179,17 @@ types, which was introduced in `Clang 13`__. The older Clang versions will
 either crash when compiling these tests, or generate an incorrect BTF.
 
 __  https://reviews.llvm.org/D83289
+
+Kernel function call test and Clang version
+===========================================
+
+Some selftests (e.g. kfunc_call and bpf_tcp_ca) require a LLVM support
+to generate extern function in BTF.  It was introduced in `Clang 13`__.
+
+Without it, the error from compiling bpf selftests looks like:
+
+.. code-block:: console
+
+  libbpf: failed to find BTF for extern 'tcp_slow_start' [25] section: -2
+
+__ https://reviews.llvm.org/D93563
Signature · 1 line
2.30.2
#5 lore raw
In reply to Martin KaFai Lau
Quoted 4 lines · Martin KaFai Lau

This set updates the document about the bpf program calling kernel function. In particular, updates are regarding to the clang requirement in selftests and kfunc-call not an ABI.

Applied.