dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
c2dfb7
From 4e7a3af028dfe6b5a4a85c31d670df73c08a0719 Mon Sep 17 00:00:00 2001
c2dfb7
From: Chris Down <chris@chrisdown.name>
c2dfb7
Date: Mon, 30 Sep 2019 18:36:13 +0100
c2dfb7
Subject: [PATCH] cgroup: Mark memory protections as explicitly set in
c2dfb7
 transient units
c2dfb7
c2dfb7
A later version of the DefaultMemory{Low,Min} patch changed these to
c2dfb7
require explicitly setting memory_foo_set, but we only set that in
c2dfb7
load-fragment, not dbus-cgroup.
c2dfb7
c2dfb7
Without these, we may fall back to either DefaultMemoryFoo or
c2dfb7
CGROUP_LIMIT_MIN when we really shouldn't.
c2dfb7
c2dfb7
(cherry picked from commit 184e989d7da4648bd36511ffa28a9f2b469589d1)
c2dfb7
c2dfb7
Related: #1763435
c2dfb7
---
c2dfb7
 src/core/dbus-cgroup.c | 64 +++++++++++++++++++++++++++++++-----------
c2dfb7
 1 file changed, 48 insertions(+), 16 deletions(-)
c2dfb7
c2dfb7
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
c2dfb7
index 39778a8dd4..de85a4851b 100644
c2dfb7
--- a/src/core/dbus-cgroup.c
c2dfb7
+++ b/src/core/dbus-cgroup.c
c2dfb7
@@ -665,17 +665,33 @@ int bus_cgroup_set_property(
c2dfb7
         if (streq(name, "MemoryAccounting"))
c2dfb7
                 return bus_cgroup_set_boolean(u, name, &c->memory_accounting, CGROUP_MASK_MEMORY, message, flags, error);
c2dfb7
 
c2dfb7
-        if (streq(name, "MemoryMin"))
c2dfb7
-                return bus_cgroup_set_memory_protection(u, name, &c->memory_min, message, flags, error);
c2dfb7
+        if (streq(name, "MemoryMin")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection(u, name, &c->memory_min, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->memory_min_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
-        if (streq(name, "MemoryLow"))
c2dfb7
-                return bus_cgroup_set_memory_protection(u, name, &c->memory_low, message, flags, error);
c2dfb7
+        if (streq(name, "MemoryLow")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection(u, name, &c->memory_low, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->memory_low_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
-        if (streq(name, "DefaultMemoryMin"))
c2dfb7
-                return bus_cgroup_set_memory_protection(u, name, &c->default_memory_min, message, flags, error);
c2dfb7
+        if (streq(name, "DefaultMemoryMin")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection(u, name, &c->default_memory_min, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->default_memory_min_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
-        if (streq(name, "DefaultMemoryLow"))
c2dfb7
-                return bus_cgroup_set_memory_protection(u, name, &c->default_memory_low, message, flags, error);
c2dfb7
+        if (streq(name, "DefaultMemoryLow")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection(u, name, &c->default_memory_low, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->default_memory_low_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
         if (streq(name, "MemoryHigh"))
c2dfb7
                 return bus_cgroup_set_memory(u, name, &c->memory_high, message, flags, error);
c2dfb7
@@ -689,17 +705,33 @@ int bus_cgroup_set_property(
c2dfb7
         if (streq(name, "MemoryLimit"))
c2dfb7
                 return bus_cgroup_set_memory(u, name, &c->memory_limit, message, flags, error);
c2dfb7
 
c2dfb7
-        if (streq(name, "MemoryMinScale"))
c2dfb7
-                return bus_cgroup_set_memory_protection_scale(u, name, &c->memory_min, message, flags, error);
c2dfb7
+        if (streq(name, "MemoryMinScale")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection_scale(u, name, &c->memory_min, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->memory_min_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
-        if (streq(name, "MemoryLowScale"))
c2dfb7
-                return bus_cgroup_set_memory_protection_scale(u, name, &c->memory_low, message, flags, error);
c2dfb7
+        if (streq(name, "MemoryLowScale")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection_scale(u, name, &c->memory_low, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->memory_low_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
-        if (streq(name, "DefaultMemoryMinScale"))
c2dfb7
-                return bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_min, message, flags, error);
c2dfb7
+        if (streq(name, "DefaultMemoryMinScale")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_min, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->default_memory_min_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
-        if (streq(name, "DefaultMemoryLowScale"))
c2dfb7
-                return bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_low, message, flags, error);
c2dfb7
+        if (streq(name, "DefaultMemoryLowScale")) {
c2dfb7
+                r = bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_low, message, flags, error);
c2dfb7
+                if (r > 0)
c2dfb7
+                        c->default_memory_low_set = true;
c2dfb7
+                return r;
c2dfb7
+        }
c2dfb7
 
c2dfb7
         if (streq(name, "MemoryHighScale"))
c2dfb7
                 return bus_cgroup_set_memory_scale(u, name, &c->memory_high, message, flags, error);