mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: sh_def@163.com,bpf@vger.kernel.org,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com
Cc: yonghong.song@linux.dev,qmo@kernel.org,martin.lau@linux.dev,song@kernel.org,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,shuah@kernel.org,linux-kselftest@vger.kernel.org,linux-kernel@vger.kernel.org,sh_def@163.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf 2/3] selftests/bpf: Test querying BPF_F_PREORDER cgroup attachments
Date: Fri, 18 Sep 2026 18:23:29 +0000 (UTC)	[thread overview]
Message-ID: <aef608763223e20b18f1aeaa837dca130fac90207177723508254a41b756ff98@mail.kernel.org> (raw)
In-Reply-To: <20260918172407.3459188-3-sh_def@163.com>

[-- Attachment #1: Type: text/plain, Size: 3518 bytes --]

> diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_mprog_opts.c b/tools/testing/selftests/bpf/prog_tests/cgroup_mprog_opts.c
> index bb60704a3ef92..343357d9c460e 100644
> --- a/tools/testing/selftests/bpf/prog_tests/cgroup_mprog_opts.c
> +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_mprog_opts.c

[ ... ]

> @@ -357,6 +380,34 @@ static void test_preorder_prog_attach_detach(int atype)
>
>  	assert_mprog_count(cg, atype, 4);
>
> +	optq.prog_ids = prog_ids;
> +	optq.prog_attach_flags = prog_attach_flags;
> +	optq.count = 10;
> +	err = bpf_prog_query_opts(cg, atype, &optq);
> +	if (!ASSERT_OK(err, "prog_query"))
> +		goto cleanup4;
> +
> +	ASSERT_EQ(optq.count, 4, "count");
> +	/* Direct query reports attached programs in cgroup list order.
> +	 * Lookup by prog_id to verify per-program flags independently of slot index.
> +	 */
> +	err = find_prog_attach_flags(&optq, id1, &flags);
> +	if (ASSERT_OK(err, "find id1"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI, "flags id1");
> +
> +	err = find_prog_attach_flags(&optq, id2, &flags);
> +	if (ASSERT_OK(err, "find id2"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI | BPF_F_PREORDER, "flags id2");
> +
> +	err = find_prog_attach_flags(&optq, id3, &flags);
> +	if (ASSERT_OK(err, "find id3"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI | BPF_F_PREORDER, "flags id3");
> +
> +	err = find_prog_attach_flags(&optq, id4, &flags);
> +	if (ASSERT_OK(err, "find id4"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI, "flags id4");
> +
> +cleanup4:
>  	err = bpf_prog_detach_opts(fd4, cg, atype, &optd);

[ ... ]

> @@ -460,6 +520,34 @@ static void test_preorder_link_attach_detach(int atype)
>
>  	assert_mprog_count(cg, atype, 4);
>
> +	optq.prog_ids = prog_ids;
> +	optq.prog_attach_flags = prog_attach_flags;
> +	optq.count = 10;
> +	err = bpf_prog_query_opts(cg, atype, &optq);
> +	if (!ASSERT_OK(err, "prog_query"))
> +		goto cleanup4;
> +
> +	ASSERT_EQ(optq.count, 4, "count");
> +	/* Direct query reports attached programs in cgroup list order.
> +	 * Lookup by prog_id to verify per-program flags independently of slot index.
> +	 */
> +	err = find_prog_attach_flags(&optq, id1, &flags);
> +	if (ASSERT_OK(err, "find id1"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI, "flags id1");
> +
> +	err = find_prog_attach_flags(&optq, id2, &flags);
> +	if (ASSERT_OK(err, "find id2"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI | BPF_F_PREORDER, "flags id2");
> +
> +	err = find_prog_attach_flags(&optq, id3, &flags);
> +	if (ASSERT_OK(err, "find id3"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI | BPF_F_PREORDER, "flags id3");
> +
> +	err = find_prog_attach_flags(&optq, id4, &flags);
> +	if (ASSERT_OK(err, "find id4"))
> +		ASSERT_EQ(flags, BPF_F_ALLOW_MULTI, "flags id4");
> +
> +cleanup4:
>  	bpf_link__destroy(link4);

This isn't a bug, but since the patch already introduces a helper
(find_prog_attach_flags), would it be worth folding this
query-and-check block into one too, so the two preorder subtests
share it instead of carrying identical copies?

The pattern appears twice: first in test_preorder_prog_attach_detach()
and again verbatim in test_preorder_link_attach_detach() - same query
setup, same comment, same four id/flag expectations, together with
duplicated locals (prog_ids[10], prog_attach_flags[10], flags, optq).


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/35376083935

  reply	other threads:[~2026-09-18 18:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 17:24 [PATCH bpf 0/3] bpf: expose cgroup preorder attachment state to userspace Hui Su
2026-09-18 17:24 ` [PATCH bpf 1/3] bpf: Report BPF_F_PREORDER in cgroup program queries Hui Su
2026-09-18 17:51   ` Alexei Starovoitov
2026-09-18 18:23   ` bot+bpf-ci
2026-09-18 17:24 ` [PATCH bpf 2/3] selftests/bpf: Test querying BPF_F_PREORDER cgroup attachments Hui Su
2026-09-18 18:23   ` bot+bpf-ci [this message]
2026-09-18 17:24 ` [PATCH bpf 3/3] bpftool: Add support for BPF_F_PREORDER cgroup attach flag Hui Su
2026-09-18 18:23   ` bot+bpf-ci

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=aef608763223e20b18f1aeaa837dca130fac90207177723508254a41b756ff98@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=qmo@kernel.org \
    --cc=sh_def@163.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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

all inboxes | Powered by JetHome®