File 0014-cgroup-Make-empty-assignments-reset-to-default.patch of Package systemd-mini
From e9ed79fd155789850e4cf0921cdb0d26a71057fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>
Date: Thu, 9 Jul 2020 19:28:14 +0200
Subject: [PATCH 14/15] 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.
(cherry picked from commit db2b8d2e2895010f3443a589c9c1f1dfb25256a6)
[mkoutny: fixes bsc#1167471]
[mkoutny: adjusted to v234 dbus properties setting
dropped parts for MemoryMin,DefaultMemory{Min,Low} which we don't have]
---
src/core/load-fragment.c | 3 +++
src/shared/bus-unit-util.c | 4 +++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 213404ee31..dea1f10c69 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3043,6 +3043,9 @@ int config_parse_memory_limit(
uint64_t bytes = CGROUP_LIMIT_MAX;
int r;
+ if (STR_IN_SET(lvalue, "MemoryLow"))
+ bytes = CGROUP_LIMIT_MIN;
+
if (!isempty(rvalue) && !streq(rvalue, "infinity")) {
r = parse_percent(rvalue);
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index b3b76bfb17..e459dd248d 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -154,8 +154,10 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
} else if (STR_IN_SET(field, "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryLimit")) {
uint64_t bytes;
- if (isempty(eq) || streq(eq, "infinity"))
+ if (streq(eq, "infinity"))
bytes = CGROUP_LIMIT_MAX;
+ else if (isempty(eq))
+ bytes = streq(field, "MemoryLow") ? CGROUP_LIMIT_MIN : CGROUP_LIMIT_MAX;
else {
r = parse_percent(eq);
if (r >= 0) {
--
2.26.2