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