Re: [RFC PATCH bpf-next 0/4] Add Open-coded process and css iters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx/
link[2]: https://lore.kernel.org/all/20230810183513.684836-1-davemarchevsky@xxxxxx/

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





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux