All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Chuyi Zhou <zhouchuyi@bytedance.com>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@kernel.org
Subject: Re: [PATCH bpf-next v4 3/3] selftests/bpf: Add test for using css_task iter in sleepable progs
Date: Wed, 1 Nov 2023 19:52:59 -0700	[thread overview]
Message-ID: <5102ba67-66b1-4751-a8b2-170888873746@linux.dev> (raw)
In-Reply-To: <20231031050438.93297-4-zhouchuyi@bytedance.com>


On 10/30/23 10:04 PM, Chuyi Zhou wrote:
> 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>

> ---
>   .../testing/selftests/bpf/prog_tests/iters.c  |  1 +
>   .../selftests/bpf/progs/iters_css_task.c      | 19 +++++++++++++++++++
>   2 files changed, 20 insertions(+)
>
> 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;
> +}

  reply	other threads:[~2023-11-02  2:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31  5:04 [PATCH bpf-next v4 0/3] Relax allowlist for open-coded css_task iter Chuyi Zhou
2023-10-31  5:04 ` [PATCH bpf-next v4 1/3] bpf: Relax allowlist for " Chuyi Zhou
2023-10-31  5:04 ` [PATCH bpf-next v4 2/3] selftests/bpf: Add tests for css_task iter combining with cgroup iter Chuyi Zhou
2023-10-31  5:04 ` [PATCH bpf-next v4 3/3] selftests/bpf: Add test for using css_task iter in sleepable progs Chuyi Zhou
2023-11-02  2:52   ` Yonghong Song [this message]
2023-11-02  6:10 ` [PATCH bpf-next v4 0/3] Relax allowlist for open-coded css_task iter patchwork-bot+netdevbpf

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=5102ba67-66b1-4751-a8b2-170888873746@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=martin.lau@kernel.org \
    --cc=zhouchuyi@bytedance.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.