From: Ren Tamura <ren.tamura.oss@gmail.com>
To: tj@kernel.org
Cc: hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org,
void@manifault.com, cgroups@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] selftests: cgroup: enable the cpu controller in test_cpu
Date: Wed, 30 Sep 2026 15:03:24 +0900 [thread overview]
Message-ID: <179074810117.139422.8287518907118199923@gmail.com> (raw)
test_cpu uses cg_read_strstr() to check for "cpu" in the root cgroup's
cgroup.subtree_control. The substring also matches "cpuset", so a
hierarchy with only cpuset enabled skips writing "+cpu" during setup.
The tests then run without the required controller enabled and report
failures. When cpu is unavailable in that hierarchy, the suite also
reports failures instead of skipping.
Always write "+cpu" during setup and skip if the write fails. Enabling a
controller that is already enabled is a no-op, so a separate presence
check is unnecessary. This requires write access to
cgroup.subtree_control even when cpu is already enabled.
Fixes: 820a4f88ee46 ("cgroup: Add new test_cpu.c test suite in cgroup selftests")
Assisted-by: LLM
Signed-off-by: Ren Tamura <ren.tamura.oss@gmail.com>
---
Validation (2026-09-24, mainline 62f4c998b297): ran the full, unfiltered
test_cpu binary as root on a freshly built mainline kernel in a
four-vCPU KVM guest. With only cpuset enabled, the original reports two
passes and seven failures; the modified binary passes all nine tests.
With cpu already enabled, both pass all nine tests in the comparison
with vCPUs pinned to separate physical cores. With cpu disabled at boot
and only cpuset enabled, the original reports test failures while the
modified binary skips with exit status 4.
The guest validation used a writable root cgroup.
LLM assistance: finding small cgroup fixes, drafting code and commit
messages, and preparing validation.
tools/testing/selftests/cgroup/test_cpu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c
index 735a53bb222ba98812d5c6ace221c3154362d859..3456e3e988c68aa6105a0d862fdc51fa0cb10d6a 100644
--- a/tools/testing/selftests/cgroup/test_cpu.c
+++ b/tools/testing/selftests/cgroup/test_cpu.c
@@ -835,9 +835,8 @@ int main(int argc, char *argv[])
if (cg_find_unified_root(root, sizeof(root), NULL))
ksft_exit_skip("cgroup v2 isn't mounted\n");
- if (cg_read_strstr(root, "cgroup.subtree_control", "cpu"))
- if (cg_write(root, "cgroup.subtree_control", "+cpu"))
- ksft_exit_skip("Failed to set cpu controller\n");
+ if (cg_write(root, "cgroup.subtree_control", "+cpu"))
+ ksft_exit_skip("Failed to set cpu controller\n");
ksft_set_plan(ARRAY_SIZE(tests));
for (i = 0; i < ARRAY_SIZE(tests); i++) {
base-commit: 551c722f40809618230001baccf219193e22fc5a
reply other threads:[~2026-09-30 6:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=179074810117.139422.8287518907118199923@gmail.com \
--to=ren.tamura.oss@gmail.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=shuah@kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.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
all inboxes | Powered by JetHome®