From 76f8ea87dbf85781e4481fc5e181fb2e26926708 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Wed, 24 Nov 2021 04:23:14 +0000 Subject: [PATCH] import rt-tests-2.1-4.el8 --- ...deadline-Fix-double-mount-of-cgroups.patch | 87 +++++++++++++++++++ ...ine_test-Fix-double-mount-of-cgroups.patch | 87 +++++++++++++++++++ SPECS/rt-tests.spec | 11 ++- 3 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 SOURCES/rt-tests-cyclicdeadline-Fix-double-mount-of-cgroups.patch create mode 100644 SOURCES/rt-tests-deadline_test-Fix-double-mount-of-cgroups.patch diff --git a/SOURCES/rt-tests-cyclicdeadline-Fix-double-mount-of-cgroups.patch b/SOURCES/rt-tests-cyclicdeadline-Fix-double-mount-of-cgroups.patch new file mode 100644 index 0000000..d66e0fc --- /dev/null +++ b/SOURCES/rt-tests-cyclicdeadline-Fix-double-mount-of-cgroups.patch @@ -0,0 +1,87 @@ +From a933af2b82ea90a51a2600cf88cfcc5f2fba9804 Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Thu, 18 Nov 2021 14:12:23 -0500 +Subject: [PATCH 2/2] rt-tests: cyclicdeadline: Fix double mount of cgroups + +If /sys/fs/cgroup exists and it is type cgroup2, cyclicdeadline mounts it a +second time as cgroup. + +systemd is creating cgroup2 for logins and this can hang the machine and +not allow logins. + +Fix this by: + +If /sys/fs/cgroup exists, then use it for cyclicdeadline_test. + +If it exists but the type is not recognized, exit with an error. +Do not simply mount it as type cgroup. + +TODO: If the file doesn't exit but cgroups are supported in the kernel, +the file could be created and mounted. + +Signed-off-by: John Kacur +--- + src/sched_deadline/cyclicdeadline.c | 39 +++++++++++++++++++++++------ + 1 file changed, 32 insertions(+), 7 deletions(-) + +diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c +index 4860a40f5e6b..1f9a5df42d4f 100644 +--- a/src/sched_deadline/cyclicdeadline.c ++++ b/src/sched_deadline/cyclicdeadline.c +@@ -358,6 +358,32 @@ static int mounted(const char *path, long magic) + #define CGROUP_PATH "/sys/fs/cgroup" + #define CPUSET_PATH CGROUP_PATH "/cpuset" + ++/** ++ * cgroup_mounted - test if the path /sys/fs/cgroup exists ++ * and is a supported type ++ * ++ * Returns -1 if the path does not exist ++ * Returns 0 if the path exists but is not a cgroup type ++ * Returns 1 if the path exists and supports cgroups ++ */ ++static int cgroup_mounted(void) ++{ ++ int ret; ++ ++ ret = mounted(CGROUP_PATH, TMPFS_MAGIC); ++ if (ret == -1) ++ return -1; /* path doesn't exist */ ++ if (ret == 1) ++ return 1; /* tmpfs */ ++ ret = mounted(CGROUP_PATH, CGROUP_SUPER_MAGIC); ++ if (ret == 1) ++ return 1; /* cgroup v1 */ ++ ret = mounted(CGROUP_PATH, CGROUP2_SUPER_MAGIC); ++ if (ret == 1) ++ return 1; ++ return 0; /* path exists but type is not recognized */ ++} ++ + static int open_cpuset(const char *path, const char *name) + { + char buf[MAXPATH]; +@@ -383,14 +409,13 @@ static int mount_cpuset(void) + int fd; + + /* Check if cgroups is already mounted. */ +- ret = mounted(CGROUP_PATH, TMPFS_MAGIC); +- if (ret < 0) ++ ret = cgroup_mounted(); ++ if (ret < 0) /* /sys/fs/cgroup doesn't exist */ + return ret; +- if (!ret) { +- ret = mount("cgroup_root", CGROUP_PATH, "tmpfs", 0, NULL); +- if (ret < 0) +- return ret; +- } ++ ++ if (!ret) /* /sys/fs/cgroup exists, but we don't recognize the type */ ++ return -1; ++ + ret = stat(CPUSET_PATH, &st); + if (ret < 0) { + ret = mkdir(CPUSET_PATH, 0755); +-- +2.31.1 + diff --git a/SOURCES/rt-tests-deadline_test-Fix-double-mount-of-cgroups.patch b/SOURCES/rt-tests-deadline_test-Fix-double-mount-of-cgroups.patch new file mode 100644 index 0000000..9cee3c8 --- /dev/null +++ b/SOURCES/rt-tests-deadline_test-Fix-double-mount-of-cgroups.patch @@ -0,0 +1,87 @@ +From 8100a3ae8c6abff99fb512d126055f4b603f4517 Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Thu, 18 Nov 2021 13:48:10 -0500 +Subject: [PATCH 1/2] rt-tests: deadline_test: Fix double mount of cgroups + +If /sys/fs/cgroup exists and it is type cgroup2, deadline mounts it a +second time as cgroup. + +systemd is creating cgroup2 for logins and this can hang the machine and +not allow logins. + +Fix this by: + +If /sys/fs/cgroup exists, then use it for deadline_test. + +If it exists but the type is not recognized, exit with an error. +Do not simply mount it as type cgroup. + +TODO: If the file doesn't exit but cgroups are supported in the kernel, +the file could be created and mounted. + +Signed-off-by: John Kacur +--- + src/sched_deadline/deadline_test.c | 39 ++++++++++++++++++++++++------ + 1 file changed, 32 insertions(+), 7 deletions(-) + +diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c +index b7e1e045b57c..11d669025425 100644 +--- a/src/sched_deadline/deadline_test.c ++++ b/src/sched_deadline/deadline_test.c +@@ -518,6 +518,32 @@ static int mounted(const char *path, long magic) + #define CGROUP_PATH "/sys/fs/cgroup" + #define CPUSET_PATH CGROUP_PATH "/cpuset" + ++/** ++ * cgroup_mounted - test if the path /sys/fs/cgroup exists ++ * and is a supported type ++ * ++ * Returns -1 if the path does not exist ++ * Returns 0 if the path exists but is not a cgroup type ++ * Returns 1 if the path exists and supports cgroups ++ */ ++static int cgroup_mounted(void) ++{ ++ int ret; ++ ++ ret = mounted(CGROUP_PATH, TMPFS_MAGIC); ++ if (ret == -1) ++ return -1; /* path doesn't exist */ ++ if (ret == 1) ++ return 1; /* tmpfs */ ++ ret = mounted(CGROUP_PATH, CGROUP_SUPER_MAGIC); ++ if (ret == 1) ++ return 1; /* cgroup v1 */ ++ ret = mounted(CGROUP_PATH, CGROUP2_SUPER_MAGIC); ++ if (ret == 1) ++ return 1; ++ return 0; /* path exists but type is not recognized */ ++} ++ + /** + * open_cpuset - open a file (usually a cpuset file) + * @path: The path of the directory the file is in +@@ -568,14 +594,13 @@ static int mount_cpuset(void) + int fd; + + /* Check if cgroups is already mounted. */ +- ret = mounted(CGROUP_PATH, TMPFS_MAGIC); +- if (ret < 0) ++ ret = cgroup_mounted(); ++ if (ret < 0) /* /sys/fs/cgroup doesn't exist */ + return ret; +- if (!ret) { +- ret = mount("cgroup_root", CGROUP_PATH, "tmpfs", 0, NULL); +- if (ret < 0) +- return ret; +- } ++ ++ if (!ret) /* /sys/fs/cgroup exists, but we don't recognize the type */ ++ return -1; ++ + ret = stat(CPUSET_PATH, &st); + if (ret < 0) { + ret = mkdir(CPUSET_PATH, 0755); +-- +2.31.1 + diff --git a/SPECS/rt-tests.spec b/SPECS/rt-tests.spec index 357dfff..34b95d2 100644 --- a/SPECS/rt-tests.spec +++ b/SPECS/rt-tests.spec @@ -6,7 +6,7 @@ Name: rt-tests # Numa argument to make: NUMA=1 # Version: 2.1 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Group: Development/Tools URL: git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git @@ -23,6 +23,8 @@ Requires: bash bc #Patches Patch1: rt-tests-Add-missing-option-F-to-optstring.patch Patch2: rt-tests-deadline_tests-Null-check-to-prevent-exception.patch +Patch3: rt-tests-deadline_test-Fix-double-mount-of-cgroups.patch +Patch4: rt-tests-cyclicdeadline-Fix-double-mount-of-cgroups.patch %description rt-tests is a set of programs that test and measure various components of @@ -33,6 +35,8 @@ latency. It also tests the functioning of priority-inheritance mutexes. %setup -q -n %{name}-%{version} %patch1 -p1 %patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build %set_build_flags @@ -87,6 +91,11 @@ rm -rf ${build_root} %{_mandir}/man8/determine_maximum_mpps.8.* %changelog +* Fri Nov 19 2021 John Kacur - 2.1-4 +- Fix potential double mount of cgroups for deadline_test +- Fix potential double mount of cgroups for cyclicdeadline +Resolves: rhbz#2024957 + * Fri Nov 12 2021 John Kacur - 2.1-3 - Null check to prevent floating point exception in deadline test Resolves: rhbz#1995005