[LTP] [PATCH] API/cgroup: Try to mount V2 with memory_recursiveprot

Richard Palethorpe rpalethorpe@suse.com
Tue Mar 1 13:23:53 CET 2022


Moving forwards system managers should always mount with
memory_recursiveprot. So we should test with this by default when it
is available.

This change will only effect SUTs which do not already have CGroups
mounted.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 lib/tst_cgroup.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index dc090b70a..8cca0654d 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -471,6 +471,7 @@ void tst_cg_scan(void)
 
 static void cgroup_mount_v2(void)
 {
+	int ret;
 	char mnt_path[PATH_MAX];
 
 	sprintf(mnt_path, "%s%s", cgroup_mount_ltp_prefix, cgroup_v2_ltp_mount);
@@ -494,7 +495,13 @@ static void cgroup_mount_v2(void)
 	return;
 
 mount:
-	if (!mount("cgroup2", mnt_path, "cgroup2", 0, NULL)) {
+	ret = mount("cgroup2", mnt_path, "cgroup2",
+		    0, "memory_recursiveprot");
+
+	if (ret && errno == EINVAL)
+		ret = mount("cgroup2", mnt_path, "cgroup2", 0, NULL);
+
+	if (!ret) {
 		tst_res(TINFO, "Mounted V2 CGroups on %s", mnt_path);
 		tst_cg_scan();
 		roots[0].we_mounted_it = 1;
-- 
2.34.1



More information about the ltp mailing list