mbox series

[bpf-next,v3,0/2] Document some recent core kfunc additions

Message ID 20221207204911.873646-1-void@manifault.com (mailing list archive)
Headers show
Series Document some recent core kfunc additions | expand

Message

David Vernet Dec. 7, 2022, 8:49 p.m. UTC
A series of recent patch sets introduced kfuncs that allowed struct
task_struct and struct cgroup objects to be used as kptrs. These were
introduced in [0], [1], and [2].

[0]: https://lore.kernel.org/lkml/20221120051004.3605026-1-void@manifault.com/
[1]: https://lore.kernel.org/lkml/20221122145300.251210-2-void@manifault.com/T/
[2]: https://lore.kernel.org/lkml/20221122055458.173143-1-void@manifault.com/

These are "core" kfuncs, in that they may be used by a wide variety of
possible BPF tracepoint or struct_ops programs, and are defined in
kernel/bpf/helpers.c. Even though as kfuncs they have no ABI stability
guarantees, they should still be properly documented. This patch set
adds that documentation.

Some other kfuncs were added recently as well, such as
bpf_rcu_read_lock() and bpf_rcu_read_unlock(). Those could and should be
added to this "Core kfuncs" section as well in subsequent patch sets.

Note that this patch set does not contain documentation for
bpf_task_acquire_not_zero(), or bpf_task_kptr_get(). As discussed in
[3], those kfuncs currently always return NULL pending resolution on how
to properly protect their arguments using RCU.


[3]: https://lore.kernel.org/all/20221206210538.597606-1-void@manifault.com/

--
Changelog:
v2 -> v3:
- Don't document bpf_task_kptr_get(), and instead provide a more
  substantive example for bpf_cgroup_kptr_get().
- Further clarify expected behavior of bpf_task_from_pid() in comments
  (Alexei)

v1 -> v2:
- Expand comment to specify that a map holds a reference to a task kptr
  if we don't end up releasing it (Alexei)
- Just read task->pid instead of using a probed read (Alexei)

David Vernet (2):
  bpf/docs: Document struct task_struct * kfuncs
  bpf/docs: Document struct cgroup * kfuncs

 Documentation/bpf/kfuncs.rst | 198 +++++++++++++++++++++++++++++++++++
 kernel/bpf/helpers.c         |   4 +-
 2 files changed, 200 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 8, 2022, 1:20 a.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Wed,  7 Dec 2022 14:49:09 -0600 you wrote:
> A series of recent patch sets introduced kfuncs that allowed struct
> task_struct and struct cgroup objects to be used as kptrs. These were
> introduced in [0], [1], and [2].
> 
> [0]: https://lore.kernel.org/lkml/20221120051004.3605026-1-void@manifault.com/
> [1]: https://lore.kernel.org/lkml/20221122145300.251210-2-void@manifault.com/T/
> [2]: https://lore.kernel.org/lkml/20221122055458.173143-1-void@manifault.com/
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,1/2] bpf/docs: Document struct task_struct * kfuncs
    https://git.kernel.org/bpf/bpf-next/c/25c5e92d197b
  - [bpf-next,v3,2/2] bpf/docs: Document struct cgroup * kfuncs
    https://git.kernel.org/bpf/bpf-next/c/36aa10ffd648

You are awesome, thank you!