[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6ce9d118-912a-df27-c015-17dee5762e1f@bytedance.com>
Date: Mon, 4 Sep 2023 10:07:06 +0800
From: Chuyi Zhou <zhouchuyi@...edance.com>
To: bpf@...r.kernel.org
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
martin.lau@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH bpf-next 0/4] Add Open-coded process and css iters
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
>
Powered by blists - more mailing lists