From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Chuyi Zhou <zhouchuyi@bytedance.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
Tejun Heo <tj@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RESEND PATCH bpf-next v6 8/8] selftests/bpf: Add tests for open-coded task and css iter
Date: Thu, 19 Oct 2023 17:03:53 -0700 [thread overview]
Message-ID: <CAADnVQKafk_junRyE=-FVAik4hjTRDtThymYGEL8hGTuYoOGpA@mail.gmail.com> (raw)
In-Reply-To: <20231018061746.111364-9-zhouchuyi@bytedance.com>
On Tue, Oct 17, 2023 at 11:18 PM Chuyi Zhou <zhouchuyi@bytedance.com> wrote:
>
> +
> +SEC("?fentry.s/" SYS_PREFIX "sys_getpgid")
> +__failure __msg("css_task_iter is only allowed in bpf_lsm and bpf iter-s")
> +int BPF_PROG(iter_css_task_for_each)
> +{
> + u64 cg_id = bpf_get_current_cgroup_id();
> + struct cgroup *cgrp = bpf_cgroup_from_id(cg_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;
> +}
I think we should relax allowlist in patch 2 further.
Any sleepable is safe.
Allowlist is needed to avoid dead locking on css_set_lock.
Any lsm and any iter (even non-sleepable) and any sleepable
seems to be safe.
Then the above test would need s/fentry.s/fentry/ to stay relevant.
I would also add:
SEC("iter/cgroup")
int cgroup_id_printer(struct bpf_iter__cgroup *ctx)
{
struct seq_file *seq = ctx->meta->seq;
struct cgroup *cgrp = ctx->cgroup;
/* epilogue */
if (cgrp == NULL) ..
bpf_for_each(css_task, task, css, CSS_TASK_ITER_PROCS) {
BPF_SEQ_PRINTF(); // something about task
}
To demonstrate how new kfunc iter can be combined with cgroup iter and
it won't deadlock, though cgroup iter is not sleepable.
I've applied the current set. Pls send a follow up. Thanks
next prev parent reply other threads:[~2023-10-20 0:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 6:17 [RESEND PATCH bpf-next v6 0/8] Add Open-coded task, css_task and css iters Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 1/8] cgroup: Prepare for using css_task_iter_*() in BPF Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 2/8] bpf: Introduce css_task open-coded iterator kfuncs Chuyi Zhou
2023-10-29 17:09 ` Guenter Roeck
2023-10-30 2:32 ` Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 3/8] bpf: Introduce task open coded " Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 4/8] bpf: Introduce css open-coded " Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 5/8] bpf: teach the verifier to enforce css_iter and task_iter in RCU CS Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 6/8] bpf: Let bpf_iter_task_new accept null task ptr Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 7/8] selftests/bpf: rename bpf_iter_task.c to bpf_iter_tasks.c Chuyi Zhou
2023-10-18 6:17 ` [RESEND PATCH bpf-next v6 8/8] selftests/bpf: Add tests for open-coded task and css iter Chuyi Zhou
2023-10-20 0:03 ` Alexei Starovoitov [this message]
2023-10-20 0:30 ` Chuyi Zhou
2023-10-20 14:46 ` Chuyi Zhou
2023-10-18 6:21 ` [RESEND PATCH bpf-next v6 0/8] Add Open-coded task, css_task and css iters Chuyi Zhou
2023-10-20 0:10 ` 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='CAADnVQKafk_junRyE=-FVAik4hjTRDtThymYGEL8hGTuYoOGpA@mail.gmail.com' \
--to=alexei.starovoitov@gmail.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 \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).