mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chuyi Zhou <zhouchuyi@bytedance.com>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@kernel.org, tj@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 0/6] Add Open-coded process and css iters
Date: Tue, 12 Sep 2023 15:11:47 +0800	[thread overview]
Message-ID: <09a0a33a-57c5-a81d-1b5b-982aa0e0441d@bytedance.com> (raw)
In-Reply-To: <20230912070149.969939-1-zhouchuyi@bytedance.com>



在 2023/9/12 15:01, Chuyi Zhou 写道:
> Hi,
> 
> This is version 2 of process and css iters support. All the changes were
> suggested by Alexei.
> 
> Thanks for your review!
> 
> --- Changelog ---
> Changes from v1:
> - Add a pre-patch to make some preparations before supporting css_task
>    iters.
> - Add an allowlist for css_task iters
> - Let bpf progs do explicit bpf_rcu_read_lock() when using process iters
> and css_descendant iters.

Sorry for missing the link to v1 
(https://lore.kernel.org/lkml/20230827072057.1591929-1-zhouchuyi@bytedance.com/).


> ---------------------
> 
> 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.
> 
> 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_{post, pre}, pos, root_css). 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 (6):
>    cgroup: Prepare for using css_task_iter_*() in BPF
>    bpf: Introduce css_task open-coded iterator kfuncs
>    bpf: Introduce process open coded iterator kfuncs
>    bpf: Introduce css_descendant open-coded iterator kfuncs
>    bpf: teach the verifier to enforce css_iter and process_iter in RCU CS
>    selftests/bpf: Add tests for open-coded task and css iter
> 
>   include/linux/cgroup.h                        |  12 +-
>   include/uapi/linux/bpf.h                      |  16 ++
>   kernel/bpf/helpers.c                          |  12 ++
>   kernel/bpf/task_iter.c                        | 130 +++++++++++++++++
>   kernel/bpf/verifier.c                         |  53 ++++++-
>   kernel/cgroup/cgroup.c                        |  18 ++-
>   tools/include/uapi/linux/bpf.h                |  16 ++
>   tools/lib/bpf/bpf_helpers.h                   |  24 +++
>   .../testing/selftests/bpf/prog_tests/iters.c  | 138 ++++++++++++++++++
>   .../testing/selftests/bpf/progs/iters_task.c  | 104 +++++++++++++
>   10 files changed, 508 insertions(+), 15 deletions(-)
>   create mode 100644 tools/testing/selftests/bpf/progs/iters_task.c
> 

      parent reply	other threads:[~2023-09-12  7:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  7:01 Chuyi Zhou
2023-09-12  7:01 ` [PATCH bpf-next v2 1/6] cgroup: Prepare for using css_task_iter_*() in BPF Chuyi Zhou
2023-09-18 20:42   ` Tejun Heo
2023-09-12  7:01 ` [PATCH bpf-next v2 2/6] bpf: Introduce css_task open-coded iterator kfuncs Chuyi Zhou
2023-09-12 17:13   ` Alexei Starovoitov
2023-09-13 14:02     ` Chuyi Zhou
2023-09-12 19:57   ` Martin KaFai Lau
2023-09-13  4:56     ` Chuyi Zhou
2023-09-14 23:26   ` Andrii Nakryiko
2023-09-12  7:01 ` [PATCH bpf-next v2 3/6] bpf: Introduce process open coded " Chuyi Zhou
2023-09-14 23:26   ` Andrii Nakryiko
2023-09-15  4:48     ` Chuyi Zhou
2023-09-15 15:03     ` Chuyi Zhou
2023-09-15 20:37       ` Andrii Nakryiko
2023-09-16 14:03         ` Chuyi Zhou
2023-09-19 23:30           ` Andrii Nakryiko
2023-09-20 12:20             ` Chuyi Zhou
2023-09-12  7:01 ` [PATCH bpf-next v2 4/6] bpf: Introduce css_descendant open-coded " Chuyi Zhou
2023-09-13  7:25   ` kernel test robot
2023-09-13  9:02   ` kernel test robot
2023-09-13  9:13   ` kernel test robot
2023-09-14 23:26   ` Andrii Nakryiko
2023-09-15 11:57     ` Chuyi Zhou
2023-09-15 20:25       ` Andrii Nakryiko
2023-09-12  7:01 ` [PATCH bpf-next v2 5/6] bpf: teach the verifier to enforce css_iter and process_iter in RCU CS Chuyi Zhou
2023-09-13 13:53   ` Chuyi Zhou
2023-09-14  8:56     ` Chuyi Zhou
2023-09-14 23:26       ` Andrii Nakryiko
2023-09-15  5:46         ` [External] " Chuyi Zhou
2023-09-15 20:23           ` Andrii Nakryiko
2023-09-14 23:26   ` Andrii Nakryiko
2023-09-12  7:01 ` [PATCH bpf-next v2 6/6] selftests/bpf: Add tests for open-coded task and css iter Chuyi Zhou
2023-09-12  7:11 ` Chuyi Zhou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09a0a33a-57c5-a81d-1b5b-982aa0e0441d@bytedance.com \
    --to=zhouchuyi@bytedance.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®