cgroup: add support for memory.peak
Linux's Control Group v2 interfaces exposes memory.peak, which contains the "max memory usage recorded for the cgroup and its descendants since the creation of the cgroup." This commit adds a new property "MemoryPeak" for units and makes "systemctl show" display this value if it is available. Fixes #29878. Signed-off-by: Florian Schmaus <flo@geekplace.eu>
This commit is contained in:
@@ -250,6 +250,7 @@ typedef struct UnitStatusInfo {
|
||||
|
||||
/* CGroup */
|
||||
uint64_t memory_current;
|
||||
uint64_t memory_peak;
|
||||
uint64_t memory_min;
|
||||
uint64_t memory_low;
|
||||
uint64_t startup_memory_low;
|
||||
@@ -702,7 +703,8 @@ static void print_status_info(
|
||||
if (i->memory_current != UINT64_MAX) {
|
||||
printf(" Memory: %s", FORMAT_BYTES(i->memory_current));
|
||||
|
||||
if (i->memory_min > 0 ||
|
||||
if (i->memory_peak != CGROUP_LIMIT_MAX ||
|
||||
i->memory_min > 0 ||
|
||||
i->memory_low > 0 || i->startup_memory_low > 0 ||
|
||||
i->memory_high != CGROUP_LIMIT_MAX || i->startup_memory_high != CGROUP_LIMIT_MAX ||
|
||||
i->memory_max != CGROUP_LIMIT_MAX || i->startup_memory_max != CGROUP_LIMIT_MAX ||
|
||||
@@ -765,6 +767,10 @@ static void print_status_info(
|
||||
printf("%savailable: %s", prefix, FORMAT_BYTES(i->memory_available));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_peak != CGROUP_LIMIT_MAX) {
|
||||
printf("%speak: %s", prefix, FORMAT_BYTES(i->memory_peak));
|
||||
prefix = " ";
|
||||
}
|
||||
printf(")");
|
||||
}
|
||||
printf("\n");
|
||||
@@ -2031,6 +2037,7 @@ static int show_one(
|
||||
{ "Where", "s", NULL, offsetof(UnitStatusInfo, where) },
|
||||
{ "What", "s", NULL, offsetof(UnitStatusInfo, what) },
|
||||
{ "MemoryCurrent", "t", NULL, offsetof(UnitStatusInfo, memory_current) },
|
||||
{ "MemoryPeak", "t", NULL, offsetof(UnitStatusInfo, memory_peak) },
|
||||
{ "MemoryAvailable", "t", NULL, offsetof(UnitStatusInfo, memory_available) },
|
||||
{ "DefaultMemoryMin", "t", NULL, offsetof(UnitStatusInfo, default_memory_min) },
|
||||
{ "DefaultMemoryLow", "t", NULL, offsetof(UnitStatusInfo, default_memory_low) },
|
||||
@@ -2087,6 +2094,7 @@ static int show_one(
|
||||
.memory_zswap_max = CGROUP_LIMIT_MAX,
|
||||
.startup_memory_zswap_max = CGROUP_LIMIT_MAX,
|
||||
.memory_limit = CGROUP_LIMIT_MAX,
|
||||
.memory_peak = CGROUP_LIMIT_MAX,
|
||||
.memory_available = CGROUP_LIMIT_MAX,
|
||||
.cpu_usage_nsec = UINT64_MAX,
|
||||
.tasks_current = UINT64_MAX,
|
||||
|
||||
Reference in New Issue
Block a user