chiark / gitweb /
cgroup: get rid of MemorySoftLimit=
authorLennart Poettering <lennart@poettering.net>
Tue, 17 Sep 2013 19:58:00 +0000 (14:58 -0500)
committerLennart Poettering <lennart@poettering.net>
Tue, 17 Sep 2013 19:58:00 +0000 (14:58 -0500)
The cgroup attribute memory.soft_limit_in_bytes is unlikely to stay
around in the kernel for good, so let's not expose it for now. We can
readd something like it later when the kernel guys decided on a final
API for this.

TODO
man/systemd.cgroup.xml
src/core/cgroup.c
src/core/cgroup.h
src/core/dbus-cgroup.c
src/core/dbus-cgroup.h
src/core/load-fragment-gperf.gperf.m4
src/core/load-fragment.c
src/systemctl/systemctl.c

diff --git a/TODO b/TODO
index 6a96c7781adb05b823dbb33f1e2efb4b23346760..d109e01f71adadafcc87dbf00a047e3b7d172e3d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -60,8 +60,6 @@ Features:
 
 * always set memory.user_hierarchy for all cgroups we create
 
 
 * always set memory.user_hierarchy for all cgroups we create
 
-* Get rid of MemorySoftLimit=
-
 * After coming back from hibernation reset hibernation swap partition
 
 * mounts: do not test each mount unit against each other mount unit to
 * After coming back from hibernation reset hibernation swap partition
 
 * mounts: do not test each mount unit against each other mount unit to
index cc0eb15abb901976db4a2641ab3c793489c7128f..ac5896233c69733c4ceffbe19c85e008fbc5c7d2 100644 (file)
@@ -136,22 +136,17 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
       <varlistentry>
         <term><varname>MemoryLimit=<replaceable>bytes</replaceable></varname></term>
 
       <varlistentry>
         <term><varname>MemoryLimit=<replaceable>bytes</replaceable></varname></term>
-        <term><varname>MemorySoftLimit=<replaceable>bytes</replaceable></varname></term>
 
         <listitem>
 
         <listitem>
-          <para>Specify the hard and soft limits on maximum memory
-          usage of the executed processes. The "hard" limit specifies
-          how much process and kernel memory can be used by tasks in
-          this unit, when there is no memory contention. If the kernel
-          detects memory contention, memory reclaim will be performed
-          until the memory usage is within the "soft" limit. Takes a
+          <para>Specify the limit on maximum memory usage of the
+          executed processes. The limit specifies how much process and
+          kernel memory can be used by tasks in this unit. Takes a
           memory size in bytes. If the value is suffixed with K, M, G
           or T, the specified memory size is parsed as Kilobytes,
           Megabytes, Gigabytes, or Terabytes (with the base 1024),
           respectively. This controls the
           memory size in bytes. If the value is suffixed with K, M, G
           or T, the specified memory size is parsed as Kilobytes,
           Megabytes, Gigabytes, or Terabytes (with the base 1024),
           respectively. This controls the
-          <literal>memory.limit_in_bytes</literal> and
-          <literal>memory.soft_limit_in_bytes</literal> control group
-          attributes. For details about these control group attributes,
+          <literal>memory.limit_in_bytes</literal> control group
+          attribute. For details about this control group attribute,
           see <ulink
           url="https://www.kernel.org/doc/Documentation/cgroups/memory.txt">memory.txt</ulink>.</para>
 
           see <ulink
           url="https://www.kernel.org/doc/Documentation/cgroups/memory.txt">memory.txt</ulink>.</para>
 
index 9277dd69f6e42eb2d14a07fc49001e41a0def7df..d10f205a2ff431f807aa756fba53047c982fa11d 100644 (file)
@@ -33,7 +33,7 @@ void cgroup_context_init(CGroupContext *c) {
          * structure is preinitialized to 0 */
 
         c->cpu_shares = 1024;
          * structure is preinitialized to 0 */
 
         c->cpu_shares = 1024;
-        c->memory_limit = c->memory_soft_limit = (uint64_t) -1;
+        c->memory_limit = (uint64_t) -1;
         c->blockio_weight = 1000;
 }
 
         c->blockio_weight = 1000;
 }
 
@@ -94,7 +94,6 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
                 "%sCPUShares=%lu\n"
                 "%sBlockIOWeight=%lu\n"
                 "%sMemoryLimit=%" PRIu64 "\n"
                 "%sCPUShares=%lu\n"
                 "%sBlockIOWeight=%lu\n"
                 "%sMemoryLimit=%" PRIu64 "\n"
-                "%sMemorySoftLimit=%" PRIu64 "\n"
                 "%sDevicePolicy=%s\n",
                 prefix, yes_no(c->cpu_accounting),
                 prefix, yes_no(c->blockio_accounting),
                 "%sDevicePolicy=%s\n",
                 prefix, yes_no(c->cpu_accounting),
                 prefix, yes_no(c->blockio_accounting),
@@ -102,7 +101,6 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
                 prefix, c->cpu_shares,
                 prefix, c->blockio_weight,
                 prefix, c->memory_limit,
                 prefix, c->cpu_shares,
                 prefix, c->blockio_weight,
                 prefix, c->memory_limit,
-                prefix, c->memory_soft_limit,
                 prefix, cgroup_device_policy_to_string(c->device_policy));
 
         LIST_FOREACH(device_allow, a, c->device_allow)
                 prefix, cgroup_device_policy_to_string(c->device_policy));
 
         LIST_FOREACH(device_allow, a, c->device_allow)
@@ -265,15 +263,6 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
 
                 if (r < 0)
                         log_error("Failed to set memory.limit_in_bytes on %s: %s", path, strerror(-r));
 
                 if (r < 0)
                         log_error("Failed to set memory.limit_in_bytes on %s: %s", path, strerror(-r));
-
-                if (c->memory_soft_limit != (uint64_t) -1) {
-                        sprintf(buf, "%" PRIu64 "\n", c->memory_soft_limit);
-                        r = cg_set_attribute("memory", path, "memory.soft_limit_in_bytes", buf);
-                } else
-                        r = cg_set_attribute("memory", path, "memory.soft_limit_in_bytes", "-1");
-
-                if (r < 0)
-                        log_error("Failed to set memory.soft_limit_in_bytes on %s: %s", path, strerror(-r));
         }
 
         if (mask & CGROUP_DEVICE) {
         }
 
         if (mask & CGROUP_DEVICE) {
@@ -336,8 +325,7 @@ CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) {
                 mask |= CGROUP_BLKIO;
 
         if (c->memory_accounting ||
                 mask |= CGROUP_BLKIO;
 
         if (c->memory_accounting ||
-            c->memory_limit != (uint64_t) -1 ||
-            c->memory_soft_limit != (uint64_t) -1)
+            c->memory_limit != (uint64_t) -1)
                 mask |= CGROUP_MEMORY;
 
         if (c->device_allow || c->device_policy != CGROUP_AUTO)
                 mask |= CGROUP_MEMORY;
 
         if (c->device_allow || c->device_policy != CGROUP_AUTO)
index 786bd71c8ba2a16bd903b8a164a66e7c03a57d91..0a079e909d16c9f60d1c9b9a1635ae4e8328cbb8 100644 (file)
@@ -77,7 +77,6 @@ struct CGroupContext {
         LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths);
 
         uint64_t memory_limit;
         LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths);
 
         uint64_t memory_limit;
-        uint64_t memory_soft_limit;
 
         CGroupDevicePolicy device_policy;
         LIST_HEAD(CGroupDeviceAllow, device_allow);
 
         CGroupDevicePolicy device_policy;
         LIST_HEAD(CGroupDeviceAllow, device_allow);
index 1f2a396a6da488a59acefe5d23ed8c9bd9de2c60..9ebcad9da6934b4f5999194e93ac2396cb367afb 100644 (file)
@@ -133,7 +133,6 @@ const BusProperty bus_cgroup_context_properties[] = {
         { "BlockIOWriteBandwidth",   bus_cgroup_append_device_bandwidths, "a(st)", 0                                           },
         { "MemoryAccounting",        bus_property_append_bool,            "b",     offsetof(CGroupContext, memory_accounting)  },
         { "MemoryLimit",             bus_property_append_uint64,          "t",     offsetof(CGroupContext, memory_limit)       },
         { "BlockIOWriteBandwidth",   bus_cgroup_append_device_bandwidths, "a(st)", 0                                           },
         { "MemoryAccounting",        bus_property_append_bool,            "b",     offsetof(CGroupContext, memory_accounting)  },
         { "MemoryLimit",             bus_property_append_uint64,          "t",     offsetof(CGroupContext, memory_limit)       },
-        { "MemorySoftLimit",         bus_property_append_uint64,          "t",     offsetof(CGroupContext, memory_soft_limit)  },
         { "DevicePolicy",            bus_cgroup_append_device_policy,     "s",     offsetof(CGroupContext, device_policy)      },
         { "DeviceAllow",             bus_cgroup_append_device_allow,      "a(ss)", 0                                           },
         {}
         { "DevicePolicy",            bus_cgroup_append_device_policy,     "s",     offsetof(CGroupContext, device_policy)      },
         { "DeviceAllow",             bus_cgroup_append_device_allow,      "a(ss)", 0                                           },
         {}
@@ -418,21 +417,16 @@ int bus_cgroup_set_property(
 
                 return 1;
 
 
                 return 1;
 
-        } else if (streq(name, "MemoryLimit") || streq(name, "MemorySoftLimit")) {
+        } else if (streq(name, "MemoryLimit")) {
 
                 if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_UINT64)
                         return -EINVAL;
 
                 if (mode != UNIT_CHECK) {
                         uint64_t limit;
 
                 if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_UINT64)
                         return -EINVAL;
 
                 if (mode != UNIT_CHECK) {
                         uint64_t limit;
-
                         dbus_message_iter_get_basic(i, &limit);
 
                         dbus_message_iter_get_basic(i, &limit);
 
-                        if (streq(name, "MemoryLimit"))
-                                c->memory_limit = limit;
-                        else
-                                c->memory_soft_limit = limit;
-
+                        c->memory_limit = limit;
                         unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64, name, limit);
                 }
 
                         unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64, name, limit);
                 }
 
index 4ce1e7e7fa0dc5dc4d2de2348d3dddf0ff770be6..e5ac4c3af788b64b9767cb063a3eb3082fc1c0ea 100644 (file)
@@ -37,7 +37,6 @@
         "  <property name=\"BlockIOWriteBandwidth=\" type=\"a(st)\" access=\"read\"/>\n" \
         "  <property name=\"MemoryAccounting\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"MemoryLimit\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"BlockIOWriteBandwidth=\" type=\"a(st)\" access=\"read\"/>\n" \
         "  <property name=\"MemoryAccounting\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"MemoryLimit\" type=\"t\" access=\"read\"/>\n" \
-        "  <property name=\"MemorySoftLimit\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"DevicePolicy\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"DeviceAllow\" type=\"a(ss)\" access=\"read\"/>\n"
 
         "  <property name=\"DevicePolicy\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"DeviceAllow\" type=\"a(ss)\" access=\"read\"/>\n"
 
index 33c6880b5d803004cb3a2eb71f0f66a2e9ede69c..25bd3aae47b862a6b78860d8f5ab66ee3f63db7a 100644 (file)
@@ -89,7 +89,6 @@ $1.CPUAccounting,                config_parse_bool,                  0,
 $1.CPUShares,                    config_parse_cpu_shares,            0,                             offsetof($1, cgroup_context)
 $1.MemoryAccounting,             config_parse_bool,                  0,                             offsetof($1, cgroup_context.memory_accounting)
 $1.MemoryLimit,                  config_parse_memory_limit,          0,                             offsetof($1, cgroup_context)
 $1.CPUShares,                    config_parse_cpu_shares,            0,                             offsetof($1, cgroup_context)
 $1.MemoryAccounting,             config_parse_bool,                  0,                             offsetof($1, cgroup_context.memory_accounting)
 $1.MemoryLimit,                  config_parse_memory_limit,          0,                             offsetof($1, cgroup_context)
-$1.MemorySoftLimit,              config_parse_memory_limit,          0,                             offsetof($1, cgroup_context)
 $1.DeviceAllow,                  config_parse_device_allow,          0,                             offsetof($1, cgroup_context)
 $1.DevicePolicy,                 config_parse_device_policy,         0,                             offsetof($1, cgroup_context.device_policy)
 $1.BlockIOAccounting,            config_parse_bool,                  0,                             offsetof($1, cgroup_context.blockio_accounting)
 $1.DeviceAllow,                  config_parse_device_allow,          0,                             offsetof($1, cgroup_context)
 $1.DevicePolicy,                 config_parse_device_policy,         0,                             offsetof($1, cgroup_context.device_policy)
 $1.BlockIOAccounting,            config_parse_bool,                  0,                             offsetof($1, cgroup_context.blockio_accounting)
index cfc6f078a653c6e24ab2073149ee7796cf126956..74454abe49888bce1232ce9504e0fc07a9aa589d 100644 (file)
@@ -2036,14 +2036,11 @@ int config_parse_memory_limit(
                 void *userdata) {
 
         CGroupContext *c = data;
                 void *userdata) {
 
         CGroupContext *c = data;
-        uint64_t *limit;
         off_t bytes;
         int r;
 
         off_t bytes;
         int r;
 
-        limit = streq(lvalue, "MemoryLimit") ? &c->memory_limit : &c->memory_soft_limit;
-
         if (isempty(rvalue)) {
         if (isempty(rvalue)) {
-                *limit = (uint64_t) -1;
+                c->memory_limit = (uint64_t) -1;
                 return 0;
         }
 
                 return 0;
         }
 
@@ -2056,7 +2053,7 @@ int config_parse_memory_limit(
                 return 0;
         }
 
                 return 0;
         }
 
-        *limit = (uint64_t) bytes;
+        c->memory_limit = (uint64_t) bytes;
         return 0;
 }
 
         return 0;
 }
 
index 57e5bb941b50338db49ce2a6fd16872640318dc3..62b5616d8084c35c2aadc85a9f7a66d83d906fab 100644 (file)
@@ -3657,7 +3657,7 @@ static int append_assignment(DBusMessageIter *iter, const char *assignment) {
                     !dbus_message_iter_append_basic(&sub, DBUS_TYPE_BOOLEAN, &b))
                         return log_oom();
 
                     !dbus_message_iter_append_basic(&sub, DBUS_TYPE_BOOLEAN, &b))
                         return log_oom();
 
-        } else if (streq(field, "MemoryLimit") || streq(field, "MemorySoftLimit")) {
+        } else if (streq(field, "MemoryLimit")) {
                 off_t bytes;
                 uint64_t u;
 
                 off_t bytes;
                 uint64_t u;