Merge pull request #11206 from cdown/cgroup_no_v1
cgroup: Imply systemd.unified_cgroup_hierarchy=1 on cgroup_no_v1=all
This commit is contained in:
commit
9d6e839ed8
4
NEWS
4
NEWS
|
@ -127,6 +127,10 @@ CHANGES WITH 240 in spe:
|
||||||
* Support for disabling a particular cgroup controller within a sub-tree
|
* Support for disabling a particular cgroup controller within a sub-tree
|
||||||
has been added through the DisableControllers= directive.
|
has been added through the DisableControllers= directive.
|
||||||
|
|
||||||
|
* cgroup_no_v1=all on the kernel command line now also implies
|
||||||
|
using the unified cgroup hierarchy, unless one explicitly passes
|
||||||
|
systemd.unified_cgroup_hierarchy=0 on the kernel command line.
|
||||||
|
|
||||||
* The new "MemoryMin=" unit file property may now be used to set the
|
* The new "MemoryMin=" unit file property may now be used to set the
|
||||||
memory usage protection limit of processes invoked by the unit. This
|
memory usage protection limit of processes invoked by the unit. This
|
||||||
controls the cgroupsv2 memory.min attribute. Similarly, the new
|
controls the cgroupsv2 memory.min attribute. Similarly, the new
|
||||||
|
|
|
@ -2706,6 +2706,7 @@ bool cg_is_unified_wanted(void) {
|
||||||
int r;
|
int r;
|
||||||
bool b;
|
bool b;
|
||||||
const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_ALL;
|
const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_ALL;
|
||||||
|
_cleanup_free_ char *c = NULL;
|
||||||
|
|
||||||
/* If we have a cached value, return that. */
|
/* If we have a cached value, return that. */
|
||||||
if (wanted >= 0)
|
if (wanted >= 0)
|
||||||
|
@ -2716,11 +2717,19 @@ bool cg_is_unified_wanted(void) {
|
||||||
if (cg_unified_flush() >= 0)
|
if (cg_unified_flush() >= 0)
|
||||||
return (wanted = unified_cache >= CGROUP_UNIFIED_ALL);
|
return (wanted = unified_cache >= CGROUP_UNIFIED_ALL);
|
||||||
|
|
||||||
/* Otherwise, let's see what the kernel command line has to say.
|
/* If we were explicitly passed systemd.unified_cgroup_hierarchy,
|
||||||
* Since checking is expensive, cache a non-error result. */
|
* respect that. */
|
||||||
r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", &b);
|
r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", &b);
|
||||||
|
if (r > 0)
|
||||||
|
return (wanted = b);
|
||||||
|
|
||||||
return (wanted = r > 0 ? b : is_default);
|
/* 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 = is_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cg_is_legacy_wanted(void) {
|
bool cg_is_legacy_wanted(void) {
|
||||||
|
|
|
@ -369,6 +369,17 @@ static void test_is_wanted(void) {
|
||||||
"systemd.unified_cgroup_hierarchy=0 "
|
"systemd.unified_cgroup_hierarchy=0 "
|
||||||
"systemd.legacy_systemd_cgroup_controller=0", 1) >= 0);
|
"systemd.legacy_systemd_cgroup_controller=0", 1) >= 0);
|
||||||
test_is_wanted_print(false);
|
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) {
|
static void test_cg_tests(void) {
|
||||||
|
|
Loading…
Reference in a new issue