lkml.org 
[lkml]   [2023]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH bpf-next 0/4] Add Open-coded process and css iters
From
Friendly ping...

在 2023/8/27 15:20, Chuyi Zhou 写道:
> In some BPF usage scenarios, it will be useful to iterate the process and
> css directly in the BPF program. One of the expected scenarios is
> customizable OOM victim selection via BPF[1].
>
> Inspired by Dave's task_vma iter[2], this patchset adds three types of
> open-coded iterator kfuncs:
>
> 1. bpf_for_each(process, p). Just like for_each_process(p) in kernel to
> itearing all tasks in the system with rcu_read_lock().
>
> 2. bpf_for_each(css_task, task, css). It works like
> css_task_iter_{start, next, end} and would be used to iterating
> tasks/threads under a css.
>
> 3. bpf_for_each(css, pos, root_css, {PRE, POST}). It works like
> css_next_descendant_{pre, post} to iterating all descendant css.
>
> BPF programs can use these kfuncs directly or through bpf_for_each macro.
>
> link[1]: https://lore.kernel.org/lkml/20230810081319.65668-1-zhouchuyi@bytedance.com/
> link[2]: https://lore.kernel.org/all/20230810183513.684836-1-davemarchevsky@fb.com/
>
> Chuyi Zhou (4):
> bpf: Introduce css_task open-coded iterator kfuncs
> bpf: Introduce process open coded iterator kfuncs
> bpf: Introduce css_descendant open-coded iterator kfuncs
> selftests/bpf: Add tests for open-coded task and css iter
>
> include/uapi/linux/bpf.h | 13 ++
> kernel/bpf/helpers.c | 9 ++
> kernel/bpf/task_iter.c | 109 ++++++++++++++++
> tools/include/uapi/linux/bpf.h | 13 ++
> tools/lib/bpf/bpf_helpers.h | 18 +++
> .../testing/selftests/bpf/prog_tests/iters.c | 123 ++++++++++++++++++
> .../testing/selftests/bpf/progs/iters_task.c | 83 ++++++++++++
> 7 files changed, 368 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/progs/iters_task.c
>

\
 
 \ /
  Last update: 2023-09-04 04:07    [W:0.314 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site