summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-02-25 03:05:26 +0100
committerMike Yuan <me@yhndnzj.com>2024-02-27 16:10:49 +0100
commit31323f21bb0ae7c712f43500c42997c91a6d20bf (patch)
tree99f0444f444b4f2e07e9f68f3afe3d3d4d8dda3e
parentcore: refuse cgroupv1 unless SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE (diff)
downloadsystemd-31323f21bb0ae7c712f43500c42997c91a6d20bf.tar.xz
systemd-31323f21bb0ae7c712f43500c42997c91a6d20bf.zip
meson: drop default-hierarchy= option, always use unified
-rw-r--r--meson.build12
-rw-r--r--meson_options.txt4
-rw-r--r--src/basic/build.c1
-rw-r--r--src/shared/cgroup-setup.c27
-rw-r--r--src/test/test-cgroup-setup.c4
5 files changed, 15 insertions, 33 deletions
diff --git a/meson.build b/meson.build
index 5f5fa2eaf8..10404cebd6 100644
--- a/meson.build
+++ b/meson.build
@@ -761,17 +761,6 @@ if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0
endif
conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
-default_hierarchy = get_option('default-hierarchy')
-conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
- description : 'default cgroup hierarchy as string')
-if default_hierarchy == 'legacy'
- conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
-elif default_hierarchy == 'hybrid'
- conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
-else
- conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
-endif
-
extra_net_naming_schemes = []
extra_net_naming_map = []
foreach scheme: get_option('extra-net-naming-schemes').split(',')
@@ -2768,7 +2757,6 @@ summary({
'default LLMNR mode' : default_llmnr,
'default DNS servers' : dns_servers.split(' '),
'default NTP servers' : ntp_servers.split(' '),
- 'default cgroup hierarchy' : default_hierarchy,
'default net.naming-scheme value' : default_net_naming_scheme,
'default KillUserProcesses value' : kill_user_processes,
'default locale' : default_locale,
diff --git a/meson_options.txt b/meson_options.txt
index 4dea1a8bf3..51434f74b3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -227,8 +227,8 @@ option('configfiledir', type : 'string', value : '',
option('fallback-hostname', type : 'string', value : 'localhost',
description : 'the hostname used if none configured')
option('default-hierarchy', type : 'combo',
- choices : ['legacy', 'hybrid', 'unified'], value : 'unified',
- description : 'default cgroup hierarchy')
+ choices : ['legacy', 'hybrid', 'unified'], deprecated : true,
+ description : '''This option is deprecated and will be removed in a future release''')
option('extra-net-naming-schemes', type : 'string',
description : 'comma-separated list of extra net.naming-scheme= definitions')
option('default-net-naming-scheme', type : 'string', value : 'latest',
diff --git a/src/basic/build.c b/src/basic/build.c
index 7d6fbf43da..3ab25f72a7 100644
--- a/src/basic/build.c
+++ b/src/basic/build.c
@@ -244,7 +244,6 @@ const char* const systemd_features =
" -LIBARCHIVE"
#endif
- " default-hierarchy=" DEFAULT_HIERARCHY_NAME
;
static char *systemd_features_with_color(void) {
diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c
index ab76ee5102..a528d4292d 100644
--- a/src/shared/cgroup-setup.c
+++ b/src/shared/cgroup-setup.c
@@ -81,9 +81,6 @@ static int cg_any_controller_used_for_v1(void) {
bool cg_is_unified_wanted(void) {
static thread_local int wanted = -1;
- bool b;
- const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_ALL;
- _cleanup_free_ char *c = NULL;
int r;
/* If we have a cached value, return that. */
@@ -96,21 +93,20 @@ bool cg_is_unified_wanted(void) {
return (wanted = r >= CGROUP_UNIFIED_ALL);
/* If we were explicitly passed systemd.unified_cgroup_hierarchy, respect that. */
+ bool b;
r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", /* flags = */ 0, &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. */
+ _cleanup_free_ char *c = NULL;
r = proc_cmdline_get_key("cgroup_no_v1", 0, &c);
if (r > 0 && streq_ptr(c, "all"))
return (wanted = true);
/* If any controller is in use as v1, don't use unified. */
- if (cg_any_controller_used_for_v1() > 0)
- return (wanted = false);
-
- return (wanted = is_default);
+ return (wanted = cg_any_controller_used_for_v1() <= 0);
}
bool cg_is_legacy_wanted(void) {
@@ -132,10 +128,6 @@ bool cg_is_legacy_wanted(void) {
bool cg_is_hybrid_wanted(void) {
static thread_local int wanted = -1;
int r;
- bool b;
- const bool is_default = DEFAULT_HIERARCHY >= CGROUP_UNIFIED_SYSTEMD;
- /* We default to true if the default is "hybrid", obviously, but also when the default is "unified",
- * because if we get called, it means that unified hierarchy was not mounted. */
/* If we have a cached value, return that. */
if (wanted >= 0)
@@ -146,12 +138,17 @@ bool cg_is_hybrid_wanted(void) {
return (wanted = false);
/* Otherwise, let's see what the kernel command line has to say. Since checking is expensive, cache
- * a non-error result. */
+ * a non-error result.
+ * The meaning of the kernel option is reversed wrt. to the return value of this function, hence the
+ * negation. */
+ bool b;
r = proc_cmdline_get_bool("systemd.legacy_systemd_cgroup_controller", /* flags = */ 0, &b);
+ if (r > 0)
+ return (wanted = !b);
- /* The meaning of the kernel option is reversed wrt. to the return value of this function, hence the
- * negation. */
- return (wanted = r > 0 ? !b : is_default);
+ /* The default hierarchy is "unified". But if this is reached, it means that unified hierarchy was
+ * not mounted, so return true too. */
+ return (wanted = true);
}
bool cg_is_legacy_force_enabled(void) {
diff --git a/src/test/test-cgroup-setup.c b/src/test/test-cgroup-setup.c
index e669e9b5ab..ada32cbeb5 100644
--- a/src/test/test-cgroup-setup.c
+++ b/src/test/test-cgroup-setup.c
@@ -16,10 +16,8 @@ static void test_is_wanted_print_one(bool header) {
log_info("-- %s --", __func__);
assert_se(proc_cmdline(&cmdline) >= 0);
log_info("cmdline: %s", cmdline);
- if (header) {
- log_info("default-hierarchy=" DEFAULT_HIERARCHY_NAME);
+ if (header)
(void) system("findmnt -n /sys/fs/cgroup");
- }
log_info("is_unified_wanted() → %s", yes_no(cg_is_unified_wanted()));
log_info("is_hybrid_wanted() → %s", yes_no(cg_is_hybrid_wanted()));