Commit d8234d47 authored by Chuyi Zhou's avatar Chuyi Zhou Committed by Alexei Starovoitov

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: default avatarChuyi Zhou <zhouchuyi@bytedance.com>
Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20231031050438.93297-4-zhouchuyi@bytedance.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent f49843af
...@@ -294,6 +294,7 @@ void test_iters(void) ...@@ -294,6 +294,7 @@ void test_iters(void)
RUN_TESTS(iters_state_safety); RUN_TESTS(iters_state_safety);
RUN_TESTS(iters_looping); RUN_TESTS(iters_looping);
RUN_TESTS(iters); RUN_TESTS(iters);
RUN_TESTS(iters_css_task);
if (env.has_testmod) if (env.has_testmod)
RUN_TESTS(iters_testmod_seq); RUN_TESTS(iters_testmod_seq);
......
...@@ -89,3 +89,22 @@ int cgroup_id_printer(struct bpf_iter__cgroup *ctx) ...@@ -89,3 +89,22 @@ int cgroup_id_printer(struct bpf_iter__cgroup *ctx)
bpf_cgroup_release(acquired); bpf_cgroup_release(acquired);
return 0; 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment