|
|
4cad4c |
From 69dbbc29f26569fd09f0109e6fbebde98c0c8567 Mon Sep 17 00:00:00 2001
|
|
|
4cad4c |
From: Chris Down <chris@chrisdown.name>
|
|
|
4cad4c |
Date: Tue, 16 Apr 2019 18:44:05 +0100
|
|
|
4cad4c |
Subject: [PATCH] unit: Add DefaultMemoryMin
|
|
|
4cad4c |
|
|
|
4cad4c |
(cherry picked from commit 7ad5439e0663e39e36619957fa37eefe8026bcab)
|
|
|
4cad4c |
|
|
|
4cad4c |
Related: #1763435
|
|
|
4cad4c |
---
|
|
|
4cad4c |
src/core/cgroup.c | 3 +++
|
|
|
4cad4c |
src/core/cgroup.h | 4 ++++
|
|
|
4cad4c |
src/core/dbus-cgroup.c | 6 ++++++
|
|
|
4cad4c |
src/core/load-fragment.c | 11 +++++++++--
|
|
|
4cad4c |
src/systemctl/systemctl.c | 2 ++
|
|
|
4cad4c |
5 files changed, 24 insertions(+), 2 deletions(-)
|
|
|
4cad4c |
|
|
|
4cad4c |
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
|
|
|
4cad4c |
index 46a89ff5e1..d40f9cbc2a 100644
|
|
|
4cad4c |
--- a/src/core/cgroup.c
|
|
|
4cad4c |
+++ b/src/core/cgroup.c
|
|
|
4cad4c |
@@ -220,6 +220,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
|
|
4cad4c |
"%sStartupIOWeight=%" PRIu64 "\n"
|
|
|
4cad4c |
"%sBlockIOWeight=%" PRIu64 "\n"
|
|
|
4cad4c |
"%sStartupBlockIOWeight=%" PRIu64 "\n"
|
|
|
4cad4c |
+ "%sDefaultMemoryMin=%" PRIu64 "\n"
|
|
|
4cad4c |
"%sDefaultMemoryLow=%" PRIu64 "\n"
|
|
|
4cad4c |
"%sMemoryMin=%" PRIu64 "\n"
|
|
|
4cad4c |
"%sMemoryLow=%" PRIu64 "\n"
|
|
|
4cad4c |
@@ -248,6 +249,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
|
|
4cad4c |
prefix, c->startup_io_weight,
|
|
|
4cad4c |
prefix, c->blockio_weight,
|
|
|
4cad4c |
prefix, c->startup_blockio_weight,
|
|
|
4cad4c |
+ prefix, c->default_memory_min,
|
|
|
4cad4c |
prefix, c->default_memory_low,
|
|
|
4cad4c |
prefix, c->memory_min,
|
|
|
4cad4c |
prefix, c->memory_low,
|
|
|
4cad4c |
@@ -402,6 +404,7 @@ int cgroup_add_device_allow(CGroupContext *c, const char *dev, const char *mode)
|
|
|
4cad4c |
}
|
|
|
4cad4c |
|
|
|
4cad4c |
UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP(memory_low);
|
|
|
4cad4c |
+UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP(memory_min);
|
|
|
4cad4c |
|
|
|
4cad4c |
static int lookup_block_device(const char *p, dev_t *ret) {
|
|
|
4cad4c |
struct stat st;
|
|
|
4cad4c |
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
|
|
|
4cad4c |
index a263d6a169..976224336d 100644
|
|
|
4cad4c |
--- a/src/core/cgroup.h
|
|
|
4cad4c |
+++ b/src/core/cgroup.h
|
|
|
4cad4c |
@@ -95,6 +95,7 @@ struct CGroupContext {
|
|
|
4cad4c |
LIST_HEAD(CGroupIODeviceLimit, io_device_limits);
|
|
|
4cad4c |
LIST_HEAD(CGroupIODeviceLatency, io_device_latencies);
|
|
|
4cad4c |
|
|
|
4cad4c |
+ uint64_t default_memory_min;
|
|
|
4cad4c |
uint64_t default_memory_low;
|
|
|
4cad4c |
uint64_t memory_min;
|
|
|
4cad4c |
uint64_t memory_low;
|
|
|
4cad4c |
@@ -102,7 +103,9 @@ struct CGroupContext {
|
|
|
4cad4c |
uint64_t memory_max;
|
|
|
4cad4c |
uint64_t memory_swap_max;
|
|
|
4cad4c |
|
|
|
4cad4c |
+ bool default_memory_min_set;
|
|
|
4cad4c |
bool default_memory_low_set;
|
|
|
4cad4c |
+ bool memory_min_set;
|
|
|
4cad4c |
bool memory_low_set;
|
|
|
4cad4c |
|
|
|
4cad4c |
LIST_HEAD(IPAddressAccessItem, ip_address_allow);
|
|
|
4cad4c |
@@ -195,6 +198,7 @@ Unit *manager_get_unit_by_cgroup(Manager *m, const char *cgroup);
|
|
|
4cad4c |
Unit *manager_get_unit_by_pid_cgroup(Manager *m, pid_t pid);
|
|
|
4cad4c |
Unit* manager_get_unit_by_pid(Manager *m, pid_t pid);
|
|
|
4cad4c |
|
|
|
4cad4c |
+uint64_t unit_get_ancestor_memory_min(Unit *u);
|
|
|
4cad4c |
uint64_t unit_get_ancestor_memory_low(Unit *u);
|
|
|
4cad4c |
|
|
|
4cad4c |
int unit_search_main_pid(Unit *u, pid_t *ret);
|
|
|
4cad4c |
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
|
|
|
4cad4c |
index 2115d43b0c..e1278c317a 100644
|
|
|
4cad4c |
--- a/src/core/dbus-cgroup.c
|
|
|
4cad4c |
+++ b/src/core/dbus-cgroup.c
|
|
|
4cad4c |
@@ -669,6 +669,9 @@ int bus_cgroup_set_property(
|
|
|
4cad4c |
if (streq(name, "MemoryLow"))
|
|
|
4cad4c |
return bus_cgroup_set_memory(u, name, &c->memory_low, message, flags, error);
|
|
|
4cad4c |
|
|
|
4cad4c |
+ if (streq(name, "DefaultMemoryMin"))
|
|
|
4cad4c |
+ return bus_cgroup_set_memory(u, name, &c->default_memory_min, message, flags, error);
|
|
|
4cad4c |
+
|
|
|
4cad4c |
if (streq(name, "DefaultMemoryLow"))
|
|
|
4cad4c |
return bus_cgroup_set_memory(u, name, &c->default_memory_low, message, flags, error);
|
|
|
4cad4c |
|
|
|
4cad4c |
@@ -690,6 +693,9 @@ int bus_cgroup_set_property(
|
|
|
4cad4c |
if (streq(name, "MemoryLowScale"))
|
|
|
4cad4c |
return bus_cgroup_set_memory_scale(u, name, &c->memory_low, message, flags, error);
|
|
|
4cad4c |
|
|
|
4cad4c |
+ if (streq(name, "DefaultMemoryMinScale"))
|
|
|
4cad4c |
+ return bus_cgroup_set_memory_scale(u, name, &c->default_memory_min, message, flags, error);
|
|
|
4cad4c |
+
|
|
|
4cad4c |
if (streq(name, "DefaultMemoryLowScale"))
|
|
|
4cad4c |
return bus_cgroup_set_memory_scale(u, name, &c->default_memory_low, message, flags, error);
|
|
|
4cad4c |
|
|
|
4cad4c |
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
|
|
|
4cad4c |
index 20faed02ad..3b8ee6b124 100644
|
|
|
4cad4c |
--- a/src/core/load-fragment.c
|
|
|
4cad4c |
+++ b/src/core/load-fragment.c
|
|
|
4cad4c |
@@ -3102,9 +3102,16 @@ int config_parse_memory_limit(
|
|
|
4cad4c |
c->default_memory_low = CGROUP_LIMIT_MIN;
|
|
|
4cad4c |
else
|
|
|
4cad4c |
c->default_memory_low = bytes;
|
|
|
4cad4c |
- } else if (streq(lvalue, "MemoryMin"))
|
|
|
4cad4c |
+ } else if (streq(lvalue, "DefaultMemoryMin")) {
|
|
|
4cad4c |
+ c->default_memory_min_set = true;
|
|
|
4cad4c |
+ if (isempty(rvalue))
|
|
|
4cad4c |
+ c->default_memory_min = CGROUP_LIMIT_MIN;
|
|
|
4cad4c |
+ else
|
|
|
4cad4c |
+ c->default_memory_min = bytes;
|
|
|
4cad4c |
+ } else if (streq(lvalue, "MemoryMin")) {
|
|
|
4cad4c |
c->memory_min = bytes;
|
|
|
4cad4c |
- else if (streq(lvalue, "MemoryLow")) {
|
|
|
4cad4c |
+ c->memory_min_set = true;
|
|
|
4cad4c |
+ } else if (streq(lvalue, "MemoryLow")) {
|
|
|
4cad4c |
c->memory_low = bytes;
|
|
|
4cad4c |
c->memory_low_set = true;
|
|
|
4cad4c |
} else if (streq(lvalue, "MemoryHigh"))
|
|
|
4cad4c |
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
|
4cad4c |
index 763ca0c6b7..e0db97e339 100644
|
|
|
4cad4c |
--- a/src/systemctl/systemctl.c
|
|
|
4cad4c |
+++ b/src/systemctl/systemctl.c
|
|
|
4cad4c |
@@ -3918,6 +3918,7 @@ typedef struct UnitStatusInfo {
|
|
|
4cad4c |
uint64_t ip_ingress_bytes;
|
|
|
4cad4c |
uint64_t ip_egress_bytes;
|
|
|
4cad4c |
|
|
|
4cad4c |
+ uint64_t default_memory_min;
|
|
|
4cad4c |
uint64_t default_memory_low;
|
|
|
4cad4c |
|
|
|
4cad4c |
LIST_HEAD(ExecStatusInfo, exec);
|
|
|
4cad4c |
@@ -5030,6 +5031,7 @@ static int show_one(
|
|
|
4cad4c |
{ "Where", "s", NULL, offsetof(UnitStatusInfo, where) },
|
|
|
4cad4c |
{ "What", "s", NULL, offsetof(UnitStatusInfo, what) },
|
|
|
4cad4c |
{ "MemoryCurrent", "t", NULL, offsetof(UnitStatusInfo, memory_current) },
|
|
|
4cad4c |
+ { "DefaultMemoryMin", "t", NULL, offsetof(UnitStatusInfo, default_memory_min) },
|
|
|
4cad4c |
{ "DefaultMemoryLow", "t", NULL, offsetof(UnitStatusInfo, default_memory_low) },
|
|
|
4cad4c |
{ "MemoryMin", "t", NULL, offsetof(UnitStatusInfo, memory_min) },
|
|
|
4cad4c |
{ "MemoryLow", "t", NULL, offsetof(UnitStatusInfo, memory_low) },
|