aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-21 19:48:51 +0100
committerGitHub <noreply@github.com>2018-12-21 19:48:51 +0100
commit9d6e839ed8b2fb5e611864f6ed5d278c5222c270 (patch)
tree9e63144b38b772a21db5e137ff21b8319fa3a805 /src
parentsd-device: ignore bind/unbind events for now (diff)
parentcgroup: Add NEWS entry for cgroup_no_v1=all implying unified usage (diff)
downloadsystemd-9d6e839ed8b2fb5e611864f6ed5d278c5222c270.tar.gz
systemd-9d6e839ed8b2fb5e611864f6ed5d278c5222c270.tar.bz2
systemd-9d6e839ed8b2fb5e611864f6ed5d278c5222c270.zip
Merge pull request #11206 from cdown/cgroup_no_v1
cgroup: Imply systemd.unified_cgroup_hierarchy=1 on cgroup_no_v1=all
Diffstat (limited to 'src')
-rw-r--r--src/basic/cgroup-util.c15
-rw-r--r--src/test/test-cgroup-util.c11
2 files changed, 23 insertions, 3 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index ec29a6f4c..830a63c18 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -2706,6 +2706,7 @@ bool cg_is_unified_wanted(void) {
int r;
bool b;
const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_ALL;
+ _cleanup_free_ char *c = NULL;
/* If we have a cached value, return that. */
if (wanted >= 0)
@@ -2716,11 +2717,19 @@ bool cg_is_unified_wanted(void) {
if (cg_unified_flush() >= 0)
return (wanted = unified_cache >= CGROUP_UNIFIED_ALL);
- /* Otherwise, let's see what the kernel command line has to say.
- * Since checking is expensive, cache a non-error result. */
+ /* If we were explicitly passed systemd.unified_cgroup_hierarchy,
+ * respect that. */
r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", &b);
+ if (r > 0)
+ return (wanted = b);
+
+ /* If we passed cgroup_no_v1=all with no other instructions, it seems
+ * highly unlikely that we want to use hybrid or legacy hierarchy. */
+ r = proc_cmdline_get_key("cgroup_no_v1", 0, &c);
+ if (r > 0 && streq_ptr(c, "all"))
+ return (wanted = true);
- return (wanted = r > 0 ? b : is_default);
+ return (wanted = is_default);
}
bool cg_is_legacy_wanted(void) {
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
index 058cc44c4..a3239d73f 100644
--- a/src/test/test-cgroup-util.c
+++ b/src/test/test-cgroup-util.c
@@ -369,6 +369,17 @@ static void test_is_wanted(void) {
"systemd.unified_cgroup_hierarchy=0 "
"systemd.legacy_systemd_cgroup_controller=0", 1) >= 0);
test_is_wanted_print(false);
+
+ /* cgroup_no_v1=all implies unified cgroup hierarchy, unless otherwise
+ * explicitly specified. */
+ assert_se(setenv("SYSTEMD_PROC_CMDLINE",
+ "cgroup_no_v1=all", 1) >= 0);
+ test_is_wanted_print(false);
+
+ assert_se(setenv("SYSTEMD_PROC_CMDLINE",
+ "cgroup_no_v1=all "
+ "systemd.unified_cgroup_hierarchy=0", 1) >= 0);
+ test_is_wanted_print(false);
}
static void test_cg_tests(void) {