All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hui Zhu" <hui.zhu@linux.dev>
Cc: tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, bpf@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next v7 09/11] selftests/bpf: Add test for memcg_bpf_ops hierarchies
Date: Tue, 26 May 2026 02:52:32 +0000	[thread overview]
Message-ID: <20260526025233.094B21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <f2740b58570c06c275946f31f60858e875d7bdfe.1779760876.git.zhuhui@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The test reuses the identical `low_mcg_ops` map for both the parent and child overrides, failing to properly test the override mechanism and clobbering its own state during cleanup.
- [Low] The test verifies that the third attachment fails but does not check if it fails with the correct error code (-EBUSY) as claimed in the commit message.
--

commit ac1e7b9da1794e345399c9485b390263c35e79df
Author: Hui Zhu <zhuhui@kylinos.cn>
selftests/bpf: Add test for memcg_bpf_ops hierarchies

This commit adds a new selftest, test_memcg_ops_hierarchies, to validate
the behavior of attaching memcg_bpf_ops in a nested cgroup hierarchy. It
verifies the enforcement of the BPF_F_ALLOW_OVERRIDE flag across a
three-level deep cgroup subtree.

> diff --git a/tools/testing/selftests/bpf/prog_tests/memcg_ops.c b/tools/testing/selftests/bpf/prog_tests/memcg_ops.c
> index 19fd4fde22660..b4084e9327eba 100644
> --- a/tools/testing/selftests/bpf/prog_tests/memcg_ops.c
> +++ b/tools/testing/selftests/bpf/prog_tests/memcg_ops.c
> @@ -559,3 +559,76 @@ void test_memcg_ops_below_min_over_high(void)

[ ... ]

> +	skel = memcg_ops__open_and_load();
> +	if (!ASSERT_OK_PTR(skel, "memcg_ops__open_and_load"))
> +		goto cleanup;
> +
> +	map = bpf_object__find_map_by_name(skel->obj, "low_mcg_ops");
> +	if (!ASSERT_OK_PTR(map, "bpf_object__find_map_by_name low_mcg_ops"))
> +		goto cleanup;
> +
> +	opts.target_fd = first;
> +	opts.flags = BPF_F_ALLOW_OVERRIDE | BPF_F_CGROUP_FD;
> +	link1 = bpf_map__attach_struct_ops_opts(map, &opts);
> +	if (!ASSERT_OK_PTR(link1, "bpf_map__attach_struct_ops_opts"))
> +		goto cleanup;
> +
> +	opts.target_fd = second;
> +	opts.flags = BPF_F_CGROUP_FD;
> +	link2 = bpf_map__attach_struct_ops_opts(map, &opts);

[Severity: Medium]
Is it intentional to reuse the identical low_mcg_ops map for both the
parent and child overrides?

Because the overriding pointer is physically identical to the overridden one,
this might not genuinely prove that the kernel substituted the operations.

Also, could this clobber the state during cleanup since the kernel's
bpf_memcg_ops_unreg() clears descendant cgroups by checking map pointer
equality?

Would it be better to retrieve a distinct map, such as high_mcg_ops, for
the child cgroup to correctly test overriding?

> +	if (!ASSERT_OK_PTR(link2, "bpf_map__attach_struct_ops_opts"))
> +		goto cleanup;
> +
> +	opts.target_fd = third;
> +	opts.flags = BPF_F_CGROUP_FD;
> +	link3 = bpf_map__attach_struct_ops_opts(map, &opts);
> +	if (!ASSERT_ERR_PTR(link3, "bpf_map__attach_struct_ops_opts"))

[Severity: Low]
The commit message states that attaching another struct_ops to the deepest
cgroup fails with -EBUSY. Does ASSERT_ERR_PTR() only check for a generic
failure pointer?

Should this test explicitly verify that errno == EBUSY to ensure the
hierarchical restriction logic is failing for the exact reason expected?

> +		goto cleanup;
> +
> +cleanup:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1779760876.git.zhuhui@kylinos.cn?part=9

  reply	other threads:[~2026-05-26  2:52 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26  2:20 [RFC PATCH bpf-next v7 00/11] mm: BPF struct_ops for dynamic memory protection and async reclaim Hui Zhu
2026-05-26  2:20 ` [RFC PATCH bpf-next v7 01/11] bpf: move bpf_struct_ops_link into bpf.h Hui Zhu
2026-05-26  2:20 ` [RFC PATCH bpf-next v7 02/11] bpf: allow attaching struct_ops to cgroups Hui Zhu
2026-05-26  3:00   ` sashiko-bot
2026-05-26  3:19   ` bot+bpf-ci
2026-05-26  3:19     ` bot+bpf-ci
2026-05-26  2:20 ` [RFC PATCH bpf-next v7 03/11] libbpf: fix return value on memory allocation failure Hui Zhu
2026-05-26  2:41   ` sashiko-bot
2026-05-26  3:06   ` bot+bpf-ci
2026-05-26  3:06     ` bot+bpf-ci
2026-05-26  2:20 ` [RFC PATCH bpf-next v7 04/11] libbpf: introduce bpf_map__attach_struct_ops_opts() Hui Zhu
2026-05-26  2:58   ` sashiko-bot
2026-05-26  3:06   ` bot+bpf-ci
2026-05-26  3:06     ` bot+bpf-ci
2026-05-27 15:43   ` Yonghong Song
2026-05-28  5:53     ` Leon Hwang
2026-05-26  2:20 ` [RFC PATCH bpf-next v7 05/11] bpf: Pass flags in bpf_link_create for struct_ops Hui Zhu
2026-05-26  3:04   ` sashiko-bot
2026-05-26  2:24 ` [RFC PATCH bpf-next v7 06/11] mm: memcontrol: Add BPF struct_ops for memory controller Hui Zhu
2026-05-26  3:04   ` sashiko-bot
2026-05-26  3:19   ` bot+bpf-ci
2026-05-26  3:19     ` bot+bpf-ci
2026-05-26  2:24 ` [RFC PATCH bpf-next v7 07/11] mm/bpf: Add bpf_try_to_free_mem_cgroup_pages kfunc Hui Zhu
2026-05-26  2:52   ` sashiko-bot
2026-05-26  3:06   ` bot+bpf-ci
2026-05-26  3:06     ` bot+bpf-ci
2026-05-26  2:24 ` [RFC PATCH bpf-next v7 08/11] selftests/bpf: Add tests for memcg_bpf_ops Hui Zhu
2026-05-26  2:50   ` sashiko-bot
2026-05-26  2:27 ` [RFC PATCH bpf-next v7 09/11] selftests/bpf: Add test for memcg_bpf_ops hierarchies Hui Zhu
2026-05-26  2:52   ` sashiko-bot [this message]
2026-05-26  2:27 ` [RFC PATCH bpf-next v7 10/11] selftests/bpf: Add selftest for memcg async reclaim via BPF Hui Zhu
2026-05-26  3:06   ` sashiko-bot
2026-05-26  3:06   ` bot+bpf-ci
2026-05-26  3:06     ` bot+bpf-ci
2026-05-26  2:27 ` [RFC PATCH bpf-next v7 11/11] samples/bpf: Add memcg priority control and async reclaim example Hui Zhu
2026-05-26  3:10   ` sashiko-bot
2026-05-26 13:41 ` [RFC PATCH bpf-next v7 00/11] mm: BPF struct_ops for dynamic memory protection and async reclaim Usama Arif
2026-05-27  9:31   ` teawater
2026-05-27  8:47 ` Michal Hocko
2026-05-28  8:27   ` teawater

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=20260526025233.094B21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=hui.zhu@linux.dev \
    --cc=mkoutny@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tj@kernel.org \
    /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.