From: Waiman Long <longman@redhat.com>
To: "Shaojie Sun" <sunshaojie@kylinos.cn>,
"Ridong Chen" <ridong.chen@linux.dev>,
"Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Shuah Khan" <shuah@kernel.org>
Cc: cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests: cgroup: simplify cpuset subtree permissions test
Date: Wed, 19 Aug 2026 10:34:16 -0400 [thread overview]
Message-ID: <e5433074-5d95-4991-96be-eb03e7173900@redhat.com> (raw)
In-Reply-To: <20260819103152.767771-1-sunshaojie@kylinos.cn>
On 8/19/26 6:31 AM, Shaojie Sun wrote:
> Simplify test_cpuset_perms_subtree by removing unnecessary chown of
> cgroup.procs files. The test verifies implicit migration triggered by
> enabling/disabling the cpuset controller via cgroup.subtree_control.
>
> Implicit migration is handled internally by the kernel through
> cgroup_update_dfl_csses() when subtree_control is modified, and does
> not require cgroup.procs write permission. Only cgroup.subtree_control
> permission is needed to trigger the controller state change.
>
> Remove the allocation and cleanup of parent_procs and child_procs
> variables that are no longer needed.
>
> Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
> ---
> tools/testing/selftests/cgroup/test_cpuset.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/tools/testing/selftests/cgroup/test_cpuset.c b/tools/testing/selftests/cgroup/test_cpuset.c
> index c5cf8b56ceb8..b323addcc519 100644
> --- a/tools/testing/selftests/cgroup/test_cpuset.c
> +++ b/tools/testing/selftests/cgroup/test_cpuset.c
> @@ -167,7 +167,7 @@ static int test_cpuset_perms_object_deny(const char *root)
> static int test_cpuset_perms_subtree(const char *root)
> {
> char *parent = NULL, *child = NULL;
> - char *parent_procs = NULL, *parent_subctl = NULL, *child_procs = NULL;
> + char *parent_subctl = NULL;
> const uid_t test_euid = TEST_UID;
> int object_pid = 0;
> int ret = KSFT_FAIL;
> @@ -175,9 +175,6 @@ static int test_cpuset_perms_subtree(const char *root)
> parent = cg_name(root, "cpuset_test_0");
> if (!parent)
> goto cleanup;
> - parent_procs = cg_name(parent, "cgroup.procs");
> - if (!parent_procs)
> - goto cleanup;
> parent_subctl = cg_name(parent, "cgroup.subtree_control");
> if (!parent_subctl)
> goto cleanup;
> @@ -187,16 +184,11 @@ static int test_cpuset_perms_subtree(const char *root)
> child = cg_name(parent, "cpuset_test_1");
> if (!child)
> goto cleanup;
> - child_procs = cg_name(child, "cgroup.procs");
> - if (!child_procs)
> - goto cleanup;
> if (cg_create(child))
> goto cleanup;
>
> - /* Enable permissions as in a delegated subtree */
> - if (chown(parent_procs, test_euid, -1) ||
> - chown(parent_subctl, test_euid, -1) ||
> - chown(child_procs, test_euid, -1))
> + /* Grant minimal subtree_control permission to trigger implicit migration */
> + if (chown(parent_subctl, test_euid, -1))
> goto cleanup;
>
> /* Put a privileged child in the subtree and modify controller state
> @@ -221,12 +213,10 @@ static int test_cpuset_perms_subtree(const char *root)
> }
>
> cg_destroy(child);
> - free(child_procs);
> free(child);
>
> cg_destroy(parent);
> free(parent_subctl);
> - free(parent_procs);
> free(parent);
>
> return ret;
Reviewed-by: Waiman Long <longman@redhat.com>
next prev parent reply other threads:[~2026-08-19 14:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 10:31 [PATCH] selftests: cgroup: simplify cpuset subtree permissions test Shaojie Sun
2026-08-19 14:34 ` Waiman Long [this message]
2026-08-19 20:10 ` Tejun Heo
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=e5433074-5d95-4991-96be-eb03e7173900@redhat.com \
--to=longman@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=ridong.chen@linux.dev \
--cc=shuah@kernel.org \
--cc=sunshaojie@kylinos.cn \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox