summaryrefslogtreecommitdiff
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorRen Tamura <ren.tamura.oss@gmail.com>2026-09-30 15:03:24 +0900
committerTejun Heo <tj@kernel.org>2026-09-30 13:37:15 -1000
commit7b56cc82e5f94ef428c58666c9edd6c7f33e5691 (patch)
treede8cfdb6db92492e1f6176b55f4b3c0a0e048c4a /tools/testing/selftests
parent5ffe20411787dd9947a35669ef8cb9484053efcf (diff)
downloadlinux-next-7b56cc82e5f94ef428c58666c9edd6c7f33e5691.tar.gz
linux-next-7b56cc82e5f94ef428c58666c9edd6c7f33e5691.zip
selftests: cgroup: Enable the cpu controller in test_cpu
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. Assisted-by: LLM Signed-off-by: Ren Tamura <ren.tamura.oss@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r--tools/testing/selftests/cgroup/test_cpu.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c
index 735a53bb222b..3456e3e988c6 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++) {