diff mbox series

[bpf-next,v2] bpf/docs: Update design QA to be consistent with kfunc lifecycle docs

Message ID 20230208135731.268638-1-toke@redhat.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf-next,v2] bpf/docs: Update design QA to be consistent with kfunc lifecycle docs | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 pending Logs for test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-18 pending Logs for test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-23 pending Logs for test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 pending Logs for test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 14 of 14 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 52 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR fail PR summary

Commit Message

Toke Høiland-Jørgensen Feb. 8, 2023, 1:57 p.m. UTC
Cong pointed out that there are some inconsistencies between the BPF design
QA and the lifecycle expectations documentation we added for kfuncs. Let's
update the QA file to be consistent with the kfunc docs, and add references
where it makes sense. Also document that modules may export kfuncs now.

v2:
- Fix repeated word (s/defined defined/defined/)

Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 Documentation/bpf/bpf_design_QA.rst | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

Comments

David Vernet Feb. 8, 2023, 3:15 p.m. UTC | #1
On Wed, Feb 08, 2023 at 02:57:30PM +0100, Toke Høiland-Jørgensen wrote:
> Cong pointed out that there are some inconsistencies between the BPF design
> QA and the lifecycle expectations documentation we added for kfuncs. Let's
> update the QA file to be consistent with the kfunc docs, and add references
> where it makes sense. Also document that modules may export kfuncs now.
> 
> v2:
> - Fix repeated word (s/defined defined/defined/)
> 
> Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>

Thanks for fixing this. LGTM modulo one small grammar nit.

Acked-by: David Vernet <void@manifault.com>

> ---
>  Documentation/bpf/bpf_design_QA.rst | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst
> index cec2371173d7..4d3135187e0c 100644
> --- a/Documentation/bpf/bpf_design_QA.rst
> +++ b/Documentation/bpf/bpf_design_QA.rst
> @@ -208,6 +208,10 @@ data structures and compile with kernel internal headers. Both of these
>  kernel internals are subject to change and can break with newer kernels
>  such that the program needs to be adapted accordingly.
>  
> +New BPF functionality is generally added through the use of kfuncs instead of
> +new helpers. Kfuncs are not considered part of the stable API, but has their own

s/but has/and have

> +lifecycle expectations as described in :ref:`BPF_kfunc_lifecycle_expectations`.
> +
>  Q: Are tracepoints part of the stable ABI?
>  ------------------------------------------
>  A: NO. Tracepoints are tied to internal implementation details hence they are
> @@ -236,8 +240,8 @@ A: NO. Classic BPF programs are converted into extend BPF instructions.
>  
>  Q: Can BPF call arbitrary kernel functions?
>  -------------------------------------------
> -A: NO. BPF programs can only call a set of helper functions which
> -is defined for every program type.
> +A: NO. BPF programs can only call specific functions exposed as BPF helpers or
> +kfuncs. The set of available functions is defined for every program type.
>  
>  Q: Can BPF overwrite arbitrary kernel memory?
>  ---------------------------------------------
> @@ -263,7 +267,12 @@ Q: New functionality via kernel modules?
>  Q: Can BPF functionality such as new program or map types, new
>  helpers, etc be added out of kernel module code?
>  
> -A: NO.
> +A: Yes, through kfuncs and kptrs
> +
> +The core BPF functionality such as program types, maps and helpers cannot be
> +added to by modules. However, modules can expose functionality to BPF programs
> +by exporting kfuncs (which may return pointers to module-internal data
> +structures as kptrs).
>  
>  Q: Directly calling kernel function is an ABI?
>  ----------------------------------------------
> @@ -278,7 +287,8 @@ 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.
> +programs and they have to be adjusted accordingly. See
> +:ref:`BPF_kfunc_lifecycle_expectations` for details.
>  
>  Q: Attaching to arbitrary kernel functions is an ABI?
>  -----------------------------------------------------
> @@ -340,6 +350,7 @@ compatibility for these features?
>  
>  A: NO.
>  
> -Unlike map value types, there are no stability guarantees for this case. The
> -whole API to work with allocated objects and any support for special fields
> -inside them is unstable (since it is exposed through kfuncs).
> +Unlike map value types, the API to work with allocated objects and any support
> +for special fields inside them is exposed through kfuncs, and thus has the same
> +lifecycle expectations as the kfuncs themselves. See
> +:ref:`BPF_kfunc_lifecycle_expectations` for details.
> -- 
> 2.39.1
>
Toke Høiland-Jørgensen Feb. 8, 2023, 4:39 p.m. UTC | #2
David Vernet <void@manifault.com> writes:

> On Wed, Feb 08, 2023 at 02:57:30PM +0100, Toke Høiland-Jørgensen wrote:
>> Cong pointed out that there are some inconsistencies between the BPF design
>> QA and the lifecycle expectations documentation we added for kfuncs. Let's
>> update the QA file to be consistent with the kfunc docs, and add references
>> where it makes sense. Also document that modules may export kfuncs now.
>> 
>> v2:
>> - Fix repeated word (s/defined defined/defined/)
>> 
>> Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>
> Thanks for fixing this. LGTM modulo one small grammar nit.
>
> Acked-by: David Vernet <void@manifault.com>

Thanks! Will fix and respin :)

-Toke
diff mbox series

Patch

diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst
index cec2371173d7..4d3135187e0c 100644
--- a/Documentation/bpf/bpf_design_QA.rst
+++ b/Documentation/bpf/bpf_design_QA.rst
@@ -208,6 +208,10 @@  data structures and compile with kernel internal headers. Both of these
 kernel internals are subject to change and can break with newer kernels
 such that the program needs to be adapted accordingly.
 
+New BPF functionality is generally added through the use of kfuncs instead of
+new helpers. Kfuncs are not considered part of the stable API, but has their own
+lifecycle expectations as described in :ref:`BPF_kfunc_lifecycle_expectations`.
+
 Q: Are tracepoints part of the stable ABI?
 ------------------------------------------
 A: NO. Tracepoints are tied to internal implementation details hence they are
@@ -236,8 +240,8 @@  A: NO. Classic BPF programs are converted into extend BPF instructions.
 
 Q: Can BPF call arbitrary kernel functions?
 -------------------------------------------
-A: NO. BPF programs can only call a set of helper functions which
-is defined for every program type.
+A: NO. BPF programs can only call specific functions exposed as BPF helpers or
+kfuncs. The set of available functions is defined for every program type.
 
 Q: Can BPF overwrite arbitrary kernel memory?
 ---------------------------------------------
@@ -263,7 +267,12 @@  Q: New functionality via kernel modules?
 Q: Can BPF functionality such as new program or map types, new
 helpers, etc be added out of kernel module code?
 
-A: NO.
+A: Yes, through kfuncs and kptrs
+
+The core BPF functionality such as program types, maps and helpers cannot be
+added to by modules. However, modules can expose functionality to BPF programs
+by exporting kfuncs (which may return pointers to module-internal data
+structures as kptrs).
 
 Q: Directly calling kernel function is an ABI?
 ----------------------------------------------
@@ -278,7 +287,8 @@  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.
+programs and they have to be adjusted accordingly. See
+:ref:`BPF_kfunc_lifecycle_expectations` for details.
 
 Q: Attaching to arbitrary kernel functions is an ABI?
 -----------------------------------------------------
@@ -340,6 +350,7 @@  compatibility for these features?
 
 A: NO.
 
-Unlike map value types, there are no stability guarantees for this case. The
-whole API to work with allocated objects and any support for special fields
-inside them is unstable (since it is exposed through kfuncs).
+Unlike map value types, the API to work with allocated objects and any support
+for special fields inside them is exposed through kfuncs, and thus has the same
+lifecycle expectations as the kfuncs themselves. See
+:ref:`BPF_kfunc_lifecycle_expectations` for details.