cgroup: Add EffectiveMemoryMax=, EffectiveMemoryHigh= and EffectiveTasksMax= properties
Users become perplexed when they run their workload in a unit with no explicit limits configured (moreover, listing the limit property would even show it's infinity) but they experience unexpected resource limitation. The memory and pid limits come as the most visible, therefore add new unit read-only properties: - EffectiveMemoryMax=, - EffectiveMemoryHigh=, - EffectiveTasksMax=. These properties represent the most stringent limit systemd is aware of for the given unit -- and that is typically(*) the effective value. Implement the properties by simply traversing all parents in the leaf-slice tree and picking the minimum value. Note that effective limits are thus defined even for units that don't enable explicit accounting (because of the hierarchy). (*) The evasive case is when systemd runs in a cgroupns and cannot reason about outer setup. Complete solution would need kernel support.
This commit is contained in:
@@ -164,9 +164,11 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
|
||||
|
||||
bus_print_property_value(name, expected_value, flags, "[not set]");
|
||||
|
||||
else if ((ENDSWITH_SET(name, "MemoryLow", "MemoryMin", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryZSwapMax", "MemoryLimit") &&
|
||||
else if ((ENDSWITH_SET(name, "MemoryLow", "MemoryMin",
|
||||
"MemoryHigh", "MemoryMax",
|
||||
"MemorySwapMax", "MemoryZSwapMax", "MemoryLimit") &&
|
||||
u == CGROUP_LIMIT_MAX) ||
|
||||
(STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == UINT64_MAX) ||
|
||||
(endswith(name, "TasksMax") && u == UINT64_MAX) ||
|
||||
(startswith(name, "Limit") && u == UINT64_MAX) ||
|
||||
(startswith(name, "DefaultLimit") && u == UINT64_MAX))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user