[PATCH] cgroup: In cgroup_no_v1() check v1 controllers only

From: Kamalesh Babulal
Date: Wed Sep 20 2023 - 06:25:56 EST


cgroup v1 or v2 or both controller names can be passed as arguments to
the 'cgroup_no_v1' kernel parameter, though most of the controller's
names are the same for both cgroup versions. This can be confusing when
both versions are used interchangeably, i.e., passing cgroup_no_v1=io

$ sudo dmesg |grep cgroup
...
cgroup: Disabling io control group subsystem in v1 mounts
cgroup: Disabled controller 'blkio'

Restrict the check to ss->legacy_name only, when parsing the controller
names passed to cgroup_no_v1 parameter and also, use ss->legacy_name in
pr_info(), that prints the controller disabling information.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@xxxxxxxxxx>
---
kernel/cgroup/cgroup-v1.c | 3 +--
kernel/cgroup/cgroup.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index c487ffef6652..942872b83bf2 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -1297,8 +1297,7 @@ static int __init cgroup_no_v1(char *str)
}

for_each_subsys(ss, i) {
- if (strcmp(token, ss->name) &&
- strcmp(token, ss->legacy_name))
+ if (strcmp(token, ss->legacy_name))
continue;

cgroup_no_v1_mask |= 1 << i;
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 1fb7f562289d..622fb53a806b 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -6121,7 +6121,7 @@ int __init cgroup_init(void)

if (cgroup1_ssid_disabled(ssid))
pr_info("Disabling %s control group subsystem in v1 mounts\n",
- ss->name);
+ ss->legacy_name);

cgrp_dfl_root.subsys_mask |= 1 << ss->id;


base-commit: 2cf0f715623872823a72e451243bbf555d10d032
--
2.41.0