]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit: Add DefaultMemoryMin 12332/head
authorChris Down <chris@chrisdown.name>
Tue, 16 Apr 2019 17:44:05 +0000 (18:44 +0100)
committerChris Down <chris@chrisdown.name>
Tue, 16 Apr 2019 17:45:04 +0000 (18:45 +0100)
src/core/cgroup.c
src/core/cgroup.h
src/core/dbus-cgroup.c
src/core/load-fragment.c
src/systemctl/systemctl.c

index 8884981b29d362172e42fc522278da18fcebf1d5..3cf6b53ff2d3ca8ac066d07d027fa53828315ad6 100644 (file)
@@ -234,6 +234,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
                 "%sStartupIOWeight=%" PRIu64 "\n"
                 "%sBlockIOWeight=%" PRIu64 "\n"
                 "%sStartupBlockIOWeight=%" PRIu64 "\n"
+                "%sDefaultMemoryMin=%" PRIu64 "\n"
                 "%sDefaultMemoryLow=%" PRIu64 "\n"
                 "%sMemoryMin=%" PRIu64 "\n"
                 "%sMemoryLow=%" PRIu64 "\n"
@@ -260,6 +261,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
                 prefix, c->startup_io_weight,
                 prefix, c->blockio_weight,
                 prefix, c->startup_blockio_weight,
+                prefix, c->default_memory_min,
                 prefix, c->default_memory_low,
                 prefix, c->memory_min,
                 prefix, c->memory_low,
@@ -414,6 +416,7 @@ int cgroup_add_device_allow(CGroupContext *c, const char *dev, const char *mode)
 }
 
 UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP(memory_low);
+UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP(memory_min);
 
 static void cgroup_xattr_apply(Unit *u) {
         char ids[SD_ID128_STRING_MAX];
index 4bbfa2c3a7f19fc210e030cc295a95f78a16b5a7..0cac8ce76b9f4131e4583080d204aee30f716f50 100644 (file)
@@ -98,6 +98,7 @@ struct CGroupContext {
         LIST_HEAD(CGroupIODeviceLimit, io_device_limits);
         LIST_HEAD(CGroupIODeviceLatency, io_device_latencies);
 
+        uint64_t default_memory_min;
         uint64_t default_memory_low;
         uint64_t memory_min;
         uint64_t memory_low;
@@ -105,7 +106,9 @@ struct CGroupContext {
         uint64_t memory_max;
         uint64_t memory_swap_max;
 
+        bool default_memory_min_set;
         bool default_memory_low_set;
+        bool memory_min_set;
         bool memory_low_set;
 
         LIST_HEAD(IPAddressAccessItem, ip_address_allow);
@@ -196,6 +199,7 @@ Unit *manager_get_unit_by_cgroup(Manager *m, const char *cgroup);
 Unit *manager_get_unit_by_pid_cgroup(Manager *m, pid_t pid);
 Unit* manager_get_unit_by_pid(Manager *m, pid_t pid);
 
+uint64_t unit_get_ancestor_memory_min(Unit *u);
 uint64_t unit_get_ancestor_memory_low(Unit *u);
 
 int unit_search_main_pid(Unit *u, pid_t *ret);
index 5327bfb17d901045d77884e3251e806378084083..c8fcf448ede70dd9564c4c6f06767f39a3f07567 100644 (file)
@@ -664,6 +664,9 @@ int bus_cgroup_set_property(
         if (streq(name, "MemoryLow"))
                 return bus_cgroup_set_memory(u, name, &c->memory_low, message, flags, error);
 
+        if (streq(name, "DefaultMemoryMin"))
+                return bus_cgroup_set_memory(u, name, &c->default_memory_min, message, flags, error);
+
         if (streq(name, "DefaultMemoryLow"))
                 return bus_cgroup_set_memory(u, name, &c->default_memory_low, message, flags, error);
 
@@ -685,6 +688,9 @@ int bus_cgroup_set_property(
         if (streq(name, "MemoryLowScale"))
                 return bus_cgroup_set_memory_scale(u, name, &c->memory_low, message, flags, error);
 
+        if (streq(name, "DefaultMemoryMinScale"))
+                return bus_cgroup_set_memory_scale(u, name, &c->default_memory_min, message, flags, error);
+
         if (streq(name, "DefaultMemoryLowScale"))
                 return bus_cgroup_set_memory_scale(u, name, &c->default_memory_low, message, flags, error);
 
index e7a1f4206bb7d4a271f60546e3d739931a2104c9..bb302fb46b85a442aca1bb3762cbebc25fc1ed7e 100644 (file)
@@ -3149,9 +3149,16 @@ int config_parse_memory_limit(
                         c->default_memory_low = CGROUP_LIMIT_MIN;
                 else
                         c->default_memory_low = bytes;
-        } else if (streq(lvalue, "MemoryMin"))
+        } else if (streq(lvalue, "DefaultMemoryMin")) {
+                c->default_memory_min_set = true;
+                if (isempty(rvalue))
+                        c->default_memory_min = CGROUP_LIMIT_MIN;
+                else
+                        c->default_memory_min = bytes;
+        } else if (streq(lvalue, "MemoryMin")) {
                 c->memory_min = bytes;
-        else if (streq(lvalue, "MemoryLow")) {
+                c->memory_min_set = true;
+        } else if (streq(lvalue, "MemoryLow")) {
                 c->memory_low = bytes;
                 c->memory_low_set = true;
         } else if (streq(lvalue, "MemoryHigh"))
index c9edefdd8218fd2cd2f6e58a289d496f913624d2..25621745b18427a052e7f065d56ad0af1a931639 100644 (file)
@@ -4129,6 +4129,7 @@ typedef struct UnitStatusInfo {
         uint64_t ip_ingress_bytes;
         uint64_t ip_egress_bytes;
 
+        uint64_t default_memory_min;
         uint64_t default_memory_low;
 
         LIST_HEAD(ExecStatusInfo, exec);
@@ -5481,6 +5482,7 @@ static int show_one(
                 { "Where",                          "s",              NULL,           offsetof(UnitStatusInfo, where)                             },
                 { "What",                           "s",              NULL,           offsetof(UnitStatusInfo, what)                              },
                 { "MemoryCurrent",                  "t",              NULL,           offsetof(UnitStatusInfo, memory_current)                    },
+                { "DefaultMemoryMin",               "t",              NULL,           offsetof(UnitStatusInfo, default_memory_min)                },
                 { "DefaultMemoryLow",               "t",              NULL,           offsetof(UnitStatusInfo, default_memory_low)                },
                 { "MemoryMin",                      "t",              NULL,           offsetof(UnitStatusInfo, memory_min)                        },
                 { "MemoryLow",                      "t",              NULL,           offsetof(UnitStatusInfo, memory_low)                        },