cgroup: get rid of MemorySoftLimit=
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.
This commit is contained in:
+2
-14
@@ -33,7 +33,7 @@ void cgroup_context_init(CGroupContext *c) {
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
||||
"%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),
|
||||
@@ -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->memory_soft_limit,
|
||||
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 (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) {
|
||||
@@ -336,8 +325,7 @@ CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) {
|
||||
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)
|
||||
|
||||
@@ -77,7 +77,6 @@ struct CGroupContext {
|
||||
LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths);
|
||||
|
||||
uint64_t memory_limit;
|
||||
uint64_t memory_soft_limit;
|
||||
|
||||
CGroupDevicePolicy device_policy;
|
||||
LIST_HEAD(CGroupDeviceAllow, device_allow);
|
||||
|
||||
@@ -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) },
|
||||
{ "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 },
|
||||
{}
|
||||
@@ -418,21 +417,16 @@ int bus_cgroup_set_property(
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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=\"MemorySoftLimit\" type=\"t\" access=\"read\"/>\n" \
|
||||
" <property name=\"DevicePolicy\" type=\"s\" access=\"read\"/>\n" \
|
||||
" <property name=\"DeviceAllow\" type=\"a(ss)\" access=\"read\"/>\n"
|
||||
|
||||
|
||||
@@ -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.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)
|
||||
|
||||
@@ -2036,14 +2036,11 @@ int config_parse_memory_limit(
|
||||
void *userdata) {
|
||||
|
||||
CGroupContext *c = data;
|
||||
uint64_t *limit;
|
||||
off_t bytes;
|
||||
int r;
|
||||
|
||||
limit = streq(lvalue, "MemoryLimit") ? &c->memory_limit : &c->memory_soft_limit;
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
*limit = (uint64_t) -1;
|
||||
c->memory_limit = (uint64_t) -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2056,7 +2053,7 @@ int config_parse_memory_limit(
|
||||
return 0;
|
||||
}
|
||||
|
||||
*limit = (uint64_t) bytes;
|
||||
c->memory_limit = (uint64_t) bytes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user