From ae6b2682f10eab1366b42566715bce58056827f8 Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Fri, 13 Jan 2023 13:41:32 -0700 Subject: [PATCH] ftests/cgroup.py: add support to list shared mount point Cgroup::get_cgroup_mounts(), could create a list of mount points and in the case of shared mount points such as cpu,cpuacct in the cgroup v1. It would only add a mount point for the last of the two controllers listed as the mount point, for example: cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0 mount list will look over cpu controller. Add support to recognize and add both controllers to the list of mount points. Reported-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- tests/ftests/cgroup.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/ftests/cgroup.py b/tests/ftests/cgroup.py index 49ac3945..d5fd1d00 100644 --- a/tests/ftests/cgroup.py +++ b/tests/ftests/cgroup.py @@ -20,7 +20,7 @@ import os class CgroupMount(object): - def __init__(self, mount_line): + def __init__(self, mount_line, controller=None): entries = mount_line.split() if entries[2] == 'cgroup': @@ -32,14 +32,17 @@ class CgroupMount(object): self.mount_point = entries[1] - self.controller = None - if self.version == CgroupVersion.CGROUP_V1: - self.controller = entries[3].split(',')[-1] + if controller: + self.controller = controller + else: + self.controller = None + if self.version == CgroupVersion.CGROUP_V1: + self.controller = entries[3].split(',')[-1] - if self.controller == 'clone_children': - # the cpuset controller may append this option to the end - # rather than the controller name like all other controllers - self.controller = 'cpuset' + if self.controller == 'clone_children': + # the cpuset controller may append this option to the end + # rather than the controller name like all other controllers + self.controller = 'cpuset' def __str__(self): out_str = 'CgroupMount' @@ -835,6 +838,13 @@ class Cgroup(object): if mount.version == CgroupVersion.CGROUP_V1 or \ expand_v2_mounts is False: mount_list.append(mount) + + if entry[1].find(',') > 0: + # multiple controllers are mounted together. Also add the + # first controller to the mount_list + controller = os.path.basename(entry[1].split(',')[0]) + mount = CgroupMount(line, controller=controller) + mount_list.append(mount) continue with open(os.path.join(mount.mount_point, -- 2.47.2