cgroup: Make empty assignments reset to default

When MemoryLow= or MemoryMin= is set, it is interpretted as setting the
values to infinity. This is inconsistent with the default initialization
to 0.
It'd be nice to interpret the empty assignment as fallback to
DefaultMemory* of parent slice, however, current DBus API cannot convey
such a NULL value, so stick to simply interpretting that as hard-wired
default.
This commit is contained in:
Michal Koutný
2020-06-02 18:59:47 +02:00
parent 21c8397694
commit db2b8d2e28
2 changed files with 22 additions and 9 deletions
+8 -8
View File
@@ -3371,6 +3371,12 @@ int config_parse_memory_limit(
uint64_t bytes = CGROUP_LIMIT_MAX;
int r;
if (STR_IN_SET(lvalue, "DefaultMemoryLow",
"DefaultMemoryMin",
"MemoryLow",
"MemoryMin"))
bytes = CGROUP_LIMIT_MIN;
if (!isempty(rvalue) && !streq(rvalue, "infinity")) {
r = parse_permille(rvalue);
@@ -3391,17 +3397,11 @@ int config_parse_memory_limit(
}
if (streq(lvalue, "DefaultMemoryLow")) {
c->default_memory_low = bytes;
c->default_memory_low_set = true;
if (isempty(rvalue))
c->default_memory_low = CGROUP_LIMIT_MIN;
else
c->default_memory_low = bytes;
} else if (streq(lvalue, "DefaultMemoryMin")) {
c->default_memory_min = bytes;
c->default_memory_min_set = true;
if (isempty(rvalue))
c->default_memory_min = CGROUP_LIMIT_MIN;
else
c->default_memory_min = bytes;
} else if (streq(lvalue, "MemoryMin")) {
c->memory_min = bytes;
c->memory_min_set = true;