diff options
author | Chuyi Zhou <zhouchuyi@bytedance.com> | 2023-10-31 13:04:38 +0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-11-01 22:49:20 -0700 |
commit | d8234d47c4aa494d789b85562fa90e837b4575f9 (patch) | |
tree | b34584327520a6b746403e0b2583fd875f29d177 /tools | |
parent | f49843afde6771ef6ed5d021eacafacfc98a58bf (diff) | |
download | linux-d8234d47c4aa494d789b85562fa90e837b4575f9.tar.gz linux-d8234d47c4aa494d789b85562fa90e837b4575f9.tar.bz2 linux-d8234d47c4aa494d789b85562fa90e837b4575f9.zip |
selftests/bpf: Add test for using css_task iter in sleepable progs
This Patch add a test to prove css_task iter can be used in normal
sleepable progs.
Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20231031050438.93297-4-zhouchuyi@bytedance.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/iters.c | 1 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/progs/iters_css_task.c | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/iters.c b/tools/testing/selftests/bpf/prog_tests/iters.c index c2425791c923..bf84d4a1d9ae 100644 --- a/tools/testing/selftests/bpf/prog_tests/iters.c +++ b/tools/testing/selftests/bpf/prog_tests/iters.c @@ -294,6 +294,7 @@ void test_iters(void) RUN_TESTS(iters_state_safety); RUN_TESTS(iters_looping); RUN_TESTS(iters); + RUN_TESTS(iters_css_task); if (env.has_testmod) RUN_TESTS(iters_testmod_seq); diff --git a/tools/testing/selftests/bpf/progs/iters_css_task.c b/tools/testing/selftests/bpf/progs/iters_css_task.c index 384ff806990f..e180aa1b1d52 100644 --- a/tools/testing/selftests/bpf/progs/iters_css_task.c +++ b/tools/testing/selftests/bpf/progs/iters_css_task.c @@ -89,3 +89,22 @@ int cgroup_id_printer(struct bpf_iter__cgroup *ctx) bpf_cgroup_release(acquired); return 0; } + +SEC("?fentry.s/" SYS_PREFIX "sys_getpgid") +int BPF_PROG(iter_css_task_for_each_sleep) +{ + u64 cgrp_id = bpf_get_current_cgroup_id(); + struct cgroup *cgrp = bpf_cgroup_from_id(cgrp_id); + struct cgroup_subsys_state *css; + struct task_struct *task; + + if (cgrp == NULL) + return 0; + css = &cgrp->self; + + bpf_for_each(css_task, task, css, CSS_TASK_ITER_PROCS) { + + } + bpf_cgroup_release(cgrp); + return 0; +} |