core: add support for Startup memory limits
We support separate Startup configurations for CPU and I/O, so add it for memory too. Only cover cgroupsv2 settings.
This commit is contained in:
committed by
Luca Boccassi
parent
f129d0e77c
commit
53fda560dc
@@ -249,10 +249,15 @@ typedef struct UnitStatusInfo {
|
||||
uint64_t memory_current;
|
||||
uint64_t memory_min;
|
||||
uint64_t memory_low;
|
||||
uint64_t startup_memory_low;
|
||||
uint64_t memory_high;
|
||||
uint64_t startup_memory_high;
|
||||
uint64_t memory_max;
|
||||
uint64_t startup_memory_max;
|
||||
uint64_t memory_swap_max;
|
||||
uint64_t startup_memory_swap_max;
|
||||
uint64_t memory_zswap_max;
|
||||
uint64_t startup_memory_zswap_max;
|
||||
uint64_t memory_limit;
|
||||
uint64_t memory_available;
|
||||
uint64_t cpu_usage_nsec;
|
||||
@@ -265,6 +270,7 @@ typedef struct UnitStatusInfo {
|
||||
|
||||
uint64_t default_memory_min;
|
||||
uint64_t default_memory_low;
|
||||
uint64_t default_startup_memory_low;
|
||||
|
||||
LIST_HEAD(ExecStatusInfo, exec_status_info_list);
|
||||
} UnitStatusInfo;
|
||||
@@ -700,10 +706,12 @@ static void print_status_info(
|
||||
if (i->memory_current != UINT64_MAX) {
|
||||
printf(" Memory: %s", FORMAT_BYTES(i->memory_current));
|
||||
|
||||
if (i->memory_min > 0 || i->memory_low > 0 ||
|
||||
i->memory_high != CGROUP_LIMIT_MAX || i->memory_max != CGROUP_LIMIT_MAX ||
|
||||
i->memory_swap_max != CGROUP_LIMIT_MAX ||
|
||||
i->memory_zswap_max != CGROUP_LIMIT_MAX ||
|
||||
if (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 ||
|
||||
i->memory_swap_max != CGROUP_LIMIT_MAX || i->startup_memory_swap_max != CGROUP_LIMIT_MAX ||
|
||||
i->memory_zswap_max != CGROUP_LIMIT_MAX || i->startup_memory_zswap_max != CGROUP_LIMIT_MAX ||
|
||||
i->memory_available != CGROUP_LIMIT_MAX ||
|
||||
i->memory_limit != CGROUP_LIMIT_MAX) {
|
||||
const char *prefix = "";
|
||||
@@ -717,22 +725,42 @@ static void print_status_info(
|
||||
printf("%slow: %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->memory_low));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->startup_memory_low > 0) {
|
||||
printf("%slow (startup): %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->startup_memory_low));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_high != CGROUP_LIMIT_MAX) {
|
||||
printf("%shigh: %s", prefix, FORMAT_BYTES(i->memory_high));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->startup_memory_high != CGROUP_LIMIT_MAX) {
|
||||
printf("%shigh (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_high));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_max != CGROUP_LIMIT_MAX) {
|
||||
printf("%smax: %s", prefix, FORMAT_BYTES(i->memory_max));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->startup_memory_max != CGROUP_LIMIT_MAX) {
|
||||
printf("%smax (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_max));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_swap_max != CGROUP_LIMIT_MAX) {
|
||||
printf("%sswap max: %s", prefix, FORMAT_BYTES(i->memory_swap_max));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->startup_memory_swap_max != CGROUP_LIMIT_MAX) {
|
||||
printf("%sswap max (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_swap_max));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_zswap_max != CGROUP_LIMIT_MAX) {
|
||||
printf("%szswap max: %s", prefix, FORMAT_BYTES(i->memory_zswap_max));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->startup_memory_zswap_max != CGROUP_LIMIT_MAX) {
|
||||
printf("%szswap max (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_zswap_max));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_limit != CGROUP_LIMIT_MAX) {
|
||||
printf("%slimit: %s", prefix, FORMAT_BYTES(i->memory_limit));
|
||||
prefix = " ";
|
||||
@@ -1988,12 +2016,18 @@ static int show_one(
|
||||
{ "MemoryAvailable", "t", NULL, offsetof(UnitStatusInfo, memory_available) },
|
||||
{ "DefaultMemoryMin", "t", NULL, offsetof(UnitStatusInfo, default_memory_min) },
|
||||
{ "DefaultMemoryLow", "t", NULL, offsetof(UnitStatusInfo, default_memory_low) },
|
||||
{ "DefaultStartupMemoryLow", "t", NULL, offsetof(UnitStatusInfo, default_startup_memory_low) },
|
||||
{ "MemoryMin", "t", NULL, offsetof(UnitStatusInfo, memory_min) },
|
||||
{ "MemoryLow", "t", NULL, offsetof(UnitStatusInfo, memory_low) },
|
||||
{ "StartupMemoryLow", "t", NULL, offsetof(UnitStatusInfo, startup_memory_low) },
|
||||
{ "MemoryHigh", "t", NULL, offsetof(UnitStatusInfo, memory_high) },
|
||||
{ "StartupMemoryHigh", "t", NULL, offsetof(UnitStatusInfo, startup_memory_high) },
|
||||
{ "MemoryMax", "t", NULL, offsetof(UnitStatusInfo, memory_max) },
|
||||
{ "StartupMemoryMax", "t", NULL, offsetof(UnitStatusInfo, startup_memory_max) },
|
||||
{ "MemorySwapMax", "t", NULL, offsetof(UnitStatusInfo, memory_swap_max) },
|
||||
{ "StartupMemorySwapMax", "t", NULL, offsetof(UnitStatusInfo, startup_memory_swap_max) },
|
||||
{ "MemoryZSwapMax", "t", NULL, offsetof(UnitStatusInfo, memory_zswap_max) },
|
||||
{ "StartupMemoryZSwapMax", "t", NULL, offsetof(UnitStatusInfo, startup_memory_zswap_max) },
|
||||
{ "MemoryLimit", "t", NULL, offsetof(UnitStatusInfo, memory_limit) },
|
||||
{ "CPUUsageNSec", "t", NULL, offsetof(UnitStatusInfo, cpu_usage_nsec) },
|
||||
{ "TasksCurrent", "t", NULL, offsetof(UnitStatusInfo, tasks_current) },
|
||||
|
||||
Reference in New Issue
Block a user