teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0415-cgroup-Mark-memory-protections-as-explicitly-set-in-.patch

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