mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
cgroup: Support 0-value for memory protection directives
These make sense to be explicitly set at 0 (which has a different effect than the default, since it can affect processing of `DefaultMemoryXXX`). Without this, it's not easily possible to relinquish memory protection for a subtree, which is not great.
This commit is contained in:
parent
7e7223b3d5
commit
22bf131be2
3
NEWS
3
NEWS
@ -24,6 +24,9 @@ CHANGES WITH 243 in spe:
|
||||
hierarchically set default memory protection values for a particular
|
||||
subtree of the unit hierarchy.
|
||||
|
||||
* Memory protection directives can now take a value of zero, allowing
|
||||
explicit opting out of a default value propagated by an ancestor.
|
||||
|
||||
…
|
||||
|
||||
CHANGES WITH 242:
|
||||
|
@ -613,6 +613,7 @@ BUS_DEFINE_SET_CGROUP_WEIGHT(cpu_shares, CGROUP_MASK_CPU, CGROUP_CPU_SHARES_IS_O
|
||||
BUS_DEFINE_SET_CGROUP_WEIGHT(io_weight, CGROUP_MASK_IO, CGROUP_WEIGHT_IS_OK, CGROUP_WEIGHT_INVALID);
|
||||
BUS_DEFINE_SET_CGROUP_WEIGHT(blockio_weight, CGROUP_MASK_BLKIO, CGROUP_BLKIO_WEIGHT_IS_OK, CGROUP_BLKIO_WEIGHT_INVALID);
|
||||
BUS_DEFINE_SET_CGROUP_LIMIT(memory, CGROUP_MASK_MEMORY, physical_memory_scale, 1);
|
||||
BUS_DEFINE_SET_CGROUP_LIMIT(memory_protection, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
|
||||
BUS_DEFINE_SET_CGROUP_LIMIT(swap, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
|
||||
BUS_DEFINE_SET_CGROUP_LIMIT(tasks_max, CGROUP_MASK_PIDS, system_tasks_max_scale, 1);
|
||||
#pragma GCC diagnostic pop
|
||||
@ -672,16 +673,16 @@ int bus_cgroup_set_property(
|
||||
return bus_cgroup_set_boolean(u, name, &c->memory_accounting, CGROUP_MASK_MEMORY, message, flags, error);
|
||||
|
||||
if (streq(name, "MemoryMin"))
|
||||
return bus_cgroup_set_memory(u, name, &c->memory_min, message, flags, error);
|
||||
return bus_cgroup_set_memory_protection(u, name, &c->memory_min, message, flags, error);
|
||||
|
||||
if (streq(name, "MemoryLow"))
|
||||
return bus_cgroup_set_memory(u, name, &c->memory_low, message, flags, error);
|
||||
return bus_cgroup_set_memory_protection(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);
|
||||
return bus_cgroup_set_memory_protection(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);
|
||||
return bus_cgroup_set_memory_protection(u, name, &c->default_memory_low, message, flags, error);
|
||||
|
||||
if (streq(name, "MemoryHigh"))
|
||||
return bus_cgroup_set_memory(u, name, &c->memory_high, message, flags, error);
|
||||
@ -696,16 +697,16 @@ int bus_cgroup_set_property(
|
||||
return bus_cgroup_set_memory(u, name, &c->memory_limit, message, flags, error);
|
||||
|
||||
if (streq(name, "MemoryMinScale"))
|
||||
return bus_cgroup_set_memory_scale(u, name, &c->memory_min, message, flags, error);
|
||||
return bus_cgroup_set_memory_protection_scale(u, name, &c->memory_min, message, flags, error);
|
||||
|
||||
if (streq(name, "MemoryLowScale"))
|
||||
return bus_cgroup_set_memory_scale(u, name, &c->memory_low, message, flags, error);
|
||||
return bus_cgroup_set_memory_protection_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);
|
||||
return bus_cgroup_set_memory_protection_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);
|
||||
return bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_low, message, flags, error);
|
||||
|
||||
if (streq(name, "MemoryHighScale"))
|
||||
return bus_cgroup_set_memory_scale(u, name, &c->memory_high, message, flags, error);
|
||||
|
@ -3137,7 +3137,7 @@ int config_parse_memory_limit(
|
||||
bytes = physical_memory_scale(r, 1000U);
|
||||
|
||||
if (bytes >= UINT64_MAX ||
|
||||
(bytes <= 0 && !streq(lvalue, "MemorySwapMax"))) {
|
||||
(bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Memory limit '%s' out of range, ignoring.", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user