core: add cgroup memory controller support on the unified hierarchy (#3315)
On the unified hierarchy, memory controller implements three control knobs - low, high and max which enables more useable and versatile control over memory usage. This patch implements support for the three control knobs. * MemoryLow, MemoryHigh and MemoryMax are added for memory.low, memory.high and memory.max, respectively. * As all absolute limits on the unified hierarchy use "max" for no limit, make memory limit parse functions accept "max" in addition to "infinity" and document "max" for the new knobs. * Implement compatibility translation between MemoryMax and MemoryLimit. v2: - Fixed missing else's in config_parse_memory_limit(). - Fixed missing newline when writing out drop-ins. - Coding style updates to use "val > 0" instead of "val". - Minor updates to documentation.
This commit is contained in:
committed by
Lennart Poettering
parent
ffe54bf4bf
commit
da4d897e75
@@ -3493,6 +3493,9 @@ typedef struct UnitStatusInfo {
|
||||
|
||||
/* CGroup */
|
||||
uint64_t memory_current;
|
||||
uint64_t memory_low;
|
||||
uint64_t memory_high;
|
||||
uint64_t memory_max;
|
||||
uint64_t memory_limit;
|
||||
uint64_t cpu_usage_nsec;
|
||||
uint64_t tasks_current;
|
||||
@@ -3775,10 +3778,30 @@ static void print_status_info(
|
||||
|
||||
printf(" Memory: %s", format_bytes(buf, sizeof(buf), i->memory_current));
|
||||
|
||||
if (i->memory_limit != (uint64_t) -1)
|
||||
printf(" (limit: %s)\n", format_bytes(buf, sizeof(buf), i->memory_limit));
|
||||
else
|
||||
printf("\n");
|
||||
if (i->memory_low > 0 || i->memory_high != CGROUP_LIMIT_MAX || i->memory_max != CGROUP_LIMIT_MAX ||
|
||||
i->memory_limit != CGROUP_LIMIT_MAX) {
|
||||
const char *prefix = "";
|
||||
|
||||
printf(" (");
|
||||
if (i->memory_low > 0) {
|
||||
printf("%slow: %s", prefix, format_bytes(buf, sizeof(buf), i->memory_low));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_high != CGROUP_LIMIT_MAX) {
|
||||
printf("%shigh: %s", prefix, format_bytes(buf, sizeof(buf), i->memory_high));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_max != CGROUP_LIMIT_MAX) {
|
||||
printf("%smax: %s", prefix, format_bytes(buf, sizeof(buf), i->memory_max));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_limit != CGROUP_LIMIT_MAX) {
|
||||
printf("%slimit: %s", prefix, format_bytes(buf, sizeof(buf), i->memory_limit));
|
||||
prefix = " ";
|
||||
}
|
||||
printf(")");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (i->cpu_usage_nsec != (uint64_t) -1) {
|
||||
@@ -4007,6 +4030,12 @@ static int status_property(const char *name, sd_bus_message *m, UnitStatusInfo *
|
||||
i->assert_timestamp = (usec_t) u;
|
||||
else if (streq(name, "MemoryCurrent"))
|
||||
i->memory_current = u;
|
||||
else if (streq(name, "MemoryLow"))
|
||||
i->memory_low = u;
|
||||
else if (streq(name, "MemoryHigh"))
|
||||
i->memory_high = u;
|
||||
else if (streq(name, "MemoryMax"))
|
||||
i->memory_max = u;
|
||||
else if (streq(name, "MemoryLimit"))
|
||||
i->memory_limit = u;
|
||||
else if (streq(name, "TasksCurrent"))
|
||||
@@ -4500,6 +4529,8 @@ static int show_one(
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
UnitStatusInfo info = {
|
||||
.memory_current = (uint64_t) -1,
|
||||
.memory_high = CGROUP_LIMIT_MAX,
|
||||
.memory_max = CGROUP_LIMIT_MAX,
|
||||
.memory_limit = (uint64_t) -1,
|
||||
.cpu_usage_nsec = (uint64_t) -1,
|
||||
.tasks_current = (uint64_t) -1,
|
||||
|
||||
Reference in New Issue
Block a user