Skip to contentSkip to conversation

selftests: cgroup: skip the cpu.max tests without CFS bandwidth control

PATCH New Sasha Levin 1 participant 1 message Nov 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: cgroup: skip the cpu.max tests without CFS bandwidth control

cpu.max only exists when the kernel is built with CONFIG_CFS_BANDWIDTH, which arm64's defconfig does not enable. test_cpucg_max and test_cpucg_max_nested then fail to write it and report a failure.

Skip both tests when cpu.max does not exist, and add CONFIG_CFS_BANDWIDTH to the cgroup selftests' config.

Fixes 889ab8113ef1 ("cgroup: Add test_cpucg_max() testcase")
Fixes a79906570f96 ("cgroup: Add test_cpucg_max_nested() testcase")

---
Tested on a 144-CPU Grace with KernelCI's arm64 defconfig build of 05441d697f7f9, which has CONFIG_CFS_BANDWIDTH unset: both tests now skip.

 tools/testing/selftests/cgroup/config     |  1 +
 tools/testing/selftests/cgroup/test_cpu.c | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/config +1 -0
index 39f979690dd3b..aaf5872c71410 100644
@@ -1,3 +1,4 @@
+CONFIG_CFS_BANDWIDTH=y
 CONFIG_CGROUPS=y
 CONFIG_CGROUP_CPUACCT=y
 CONFIG_CGROUP_FREEZER=y
tools/testing/selftests/cgroup/test_cpu.c +8 -2
index 3456e3e988c68..7119aa1db496c 100644
@@ -694,8 +694,11 @@ static int test_cpucg_max(const char *root)
 	if (cg_create(cpucg))
 		goto cleanup;
 
-	if (cg_write(cpucg, "cpu.max", quota_buf))
+	if (cg_write(cpucg, "cpu.max", quota_buf)) {
+		if (errno == ENOENT)
+			ret = KSFT_SKIP;
 		goto cleanup;
+	}
 
 	struct cpu_hog_func_param param = {
 		.nprocs = 1,
@@ -768,8 +771,11 @@ static int test_cpucg_max_nested(const char *root)
 	if (cg_create(child))
 		goto cleanup;
 
-	if (cg_write(parent, "cpu.max", quota_buf))
+	if (cg_write(parent, "cpu.max", quota_buf)) {
+		if (errno == ENOENT)
+			ret = KSFT_SKIP;
 		goto cleanup;
+	}
 
 	struct cpu_hog_func_param param = {
 		.nprocs = 1,
Signature · 1 line
2.53.0