bpf: Introduce css_task open-coded iterator kfuncs
authorChuyi Zhou <zhouchuyi@bytedance.com>
Wed, 18 Oct 2023 06:17:40 +0000 (14:17 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 20 Oct 2023 00:02:46 +0000 (17:02 -0700)
commit9c66dc94b62aef23300f05f63404afb8990920b4
tree9df3e5be227342647a1815c62ac0567d9bebbf61
parent6da88306811b40a207c94c9da9faf07bdb20776e
bpf: Introduce css_task open-coded iterator kfuncs

This patch adds kfuncs bpf_iter_css_task_{new,next,destroy} which allow
creation and manipulation of struct bpf_iter_css_task in open-coded
iterator style. These kfuncs actually wrapps css_task_iter_{start,next,
end}. BPF programs can use these kfuncs through bpf_for_each macro for
iteration of all tasks under a css.

css_task_iter_*() would try to get the global spin-lock *css_set_lock*, so
the bpf side has to be careful in where it allows to use this iter.
Currently we only allow it in bpf_lsm and bpf iter-s.

Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20231018061746.111364-3-zhouchuyi@bytedance.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/helpers.c
kernel/bpf/task_iter.c
kernel/bpf/verifier.c
tools/testing/selftests/bpf/bpf_experimental.h