[LTP] [PATCH v1] controllers: skip the test on systems where cgroup v2 is already loaded
Jin Guojie
guojie.jin@gmail.com
Wed Dec 4 02:23:35 CET 2024
When running "controllers" case on some newer Linux distributions, there
will be 10 ERROR messages during the setup phase, and several TFAIL
results at the end, even though the kernel support for cgroups in these
distributions is correct.
(1) Test platform
* Linux distribution: Ubuntu 24.10
* CPU: X86_64, Arm64
* Kernel: 6.6 longterm, with CONFIG_CGROUPS=y enabled
* glibc: 2.40
* LTP version: commit b21fd2072, Thu Nov 14 11:47:10 2024
(2) Error logs
The output of running the controllers on the above platforms is
(simplified to highlight important content):
root@vm:/opt/ltp# ./runltp -s controllers
Running tests.......
<<<test_start>>>
tag=controllers stime=1732238600
cmdline="test_controllers.sh"
contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
TEST 1: CPU CONTROLLER TESTING
RUNNING SETUP.....
ERROR: Could not mount cgroup filesystem on /dev/cpuctl..Exiting test
Cleanup called
cat: /dev/cpuctl/group_def/tasks: No such file or directory
TEST 3: CPU CONTROLLER TESTING
RUNNING SETUP.....
ERROR: Could not mount cgroup filesystem on /dev/cpuctl..Exiting test
Cleanup called
cat: /dev/cpuctl/group_def/tasks: No such file or directory
...{{Repeat between TEST 4 to 9}}...
TEST 10: CPU CONTROLLER STRESS TESTING
RUNNING SETUP.....
ERROR: Could not mount cgroup filesystem on /dev/cpuctl..Exiting test
Cleanup called
cat: /dev/cpuctl/group_def/tasks: No such file or directory
FAIL The Latency test 1 failed
TINFO Running cpuctl Latency Test 2
mount: /dev/cpuctl: cpuctl already mounted or mount point busy.
dmesg(1) may have more information after failed mount system
call.
cpuctl_test_fj 1 TFAIL : ltpapicmd.c:188: failed to mount cpu
subsystem... Exiting
cpuctl_test_fj 1 TFAIL : ltpapicmd.c:188: case1 FAIL
......
On the other hand, multiple applications running on this system(e.g. systemd,
docker) can prove that the kernel's support for cgroups is working properly.
(3) Cause analysis
Current "controllers" case in LTP only implements tests for the cgroup
v1 file interface. Currently,
many Linux distributions, including Ubuntu 24.10, mount the cgroup v2
hierarchy to /sys/fs/cgroup
at startup, which has occupied cpu, memory and other controllers, resulting
in the inability to load the v1 hierarchy again in another directory.
In this case, loading the v1 hierarchy is meaningless and subsequent
tests cannot be executed.
(4) Behavior of the patch
In order to make LTP more elegantly reflect the actual running
situation, a simple solution is to skip the test on systems where the v2
hierarchy has already been loaded.
a. Check whether the cgroup v2 file system has been loaded in the system
b. Make precise prompts, skip the test with TCONF result
On other systems that have cgroup v1 loaded by default, the behavior of
the program is not affected.
(5) Running results after code modification
a. On Ubuntu 24.10
cmdline="test_controllers.sh"
contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
(null) 1 TCONF : ltpapicmd.c:172: V1 'memory' controller
required, but it's mounted on V2
(null) 2 TCONF : ltpapicmd.c:172: Remaining cases not
appropriate for configuration
b. On other systems that have cgroup v1 loaded by default, this use case
still works correctly.
(6) Future work
At present, some distributions use cgroup v1 by default, while others
use cgroup v2 by default.
Since cgroup v1 and v2 are incompatible in terms of interface, many test
programs in LTP need to modify their code to support cgroup v2. This is
a large amount of work and will be completed in the future.
Signed-off-by: Jin Guojie <guojie.jin@gmail.com>
---
.../kernel/controllers/test_controllers.sh | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/testcases/kernel/controllers/test_controllers.sh
b/testcases/kernel/controllers/test_controllers.sh
index 7aa974ff2..6675e5618 100755
--- a/testcases/kernel/controllers/test_controllers.sh
+++ b/testcases/kernel/controllers/test_controllers.sh
@@ -37,6 +37,27 @@
#
#
##################################################################################
+
+# Check for cgroup v2, and skip it.
+# In the script called by test_controllers.sh, only the file
interface of cgroup v1
+# is tested. Since many Linux distributions are now turning to v2, cgroup v2
+# hierarchy is mounted to /sys/fs/cgroup at startup, and Linux
documentation does
+# not recommend using v2 hierarchy and v2 hierarchy at the same time
in a running
+# system. Therefore, when the v2 hierarchy is already loaded in the
system, skip the test.
+# In fact, the safest way is to add a new set of test scripts for
cgroup v2 in LTP.
+# But this workload is relatively large, hope someone will do it in the future.
+mount | grep " type cgroup2 " &>/dev/null
+if [ $? == 0 ]
+then
+ tst_brkm TCONF "" "test_controllers.sh: V1 'memory' controller
required, but it's mounted on V2"
+ exit 32
+fi
+
if [ -f /proc/cgroups ]
then
CPU_CONTROLLER=`grep -w cpu /proc/cgroups | cut -f1`;
--
2.45.2
More information about the ltp
mailing list