mirror of
https://github.com/systemd/systemd
synced 2024-07-21 18:24:38 +00:00
systemctl-show: only show available memory if it was artifically limited
Systemd 255 changed the semantic of MemoryAvailable with3565c709f5
("cgroup: Fix MemoryAvailable= by considering physical memory"). If there is no artificial constraint, it will hold the amount of available physical memory, while it previously contained UINT64_MAX. While the change in MemoryAvailable's semantic is sensible, it causes `systemctl status` to always display the available physical memory. This creates a lot of noise, especially since systemd recently started to also show the "peak" memory. For example $ systemctl status foo … Memory: 3.9G (available: 21.2G peak: 5.4G) … However, while peak memory is a unit specific value, the available memory, when not derived from artificial memory limits, is a generic property that holds the same value for all units that are not under memory accounting constraints. Displaying it under those circumstances can therefore be considered being noisy. Before3565c709f5
("cgroup: Fix MemoryAvailable= by considering physical memory") "systemctl status" would only show the available memory if it was caused by a explicit memory limitation due to MemoryHigh or MemoryMax. This commit restores this behavior by supressing displaying the available memory if is is merely the available phyiscal memory. For example $ systemctl status foo … Memory: 3.9G (peak: 5.4G) … Fixes #30102.
This commit is contained in:
parent
dc78603a58
commit
f380473edf
|
@ -707,12 +707,15 @@ static void print_status_info(
|
|||
printf(" Memory: %s", FORMAT_BYTES(i->memory_current));
|
||||
|
||||
/* Only show current swap if it ever was non-zero or is currently non-zero. In both cases
|
||||
memory_swap_peak will be non-zero (and not CGROUP_LIMIT_MAX). */
|
||||
memory_swap_peak will be non-zero (and not CGROUP_LIMIT_MAX).
|
||||
Only show the available memory if it was artifically limited. */
|
||||
bool show_memory_swap = !IN_SET(i->memory_swap_peak, 0, CGROUP_LIMIT_MAX),
|
||||
show_memory_zswap_current = !IN_SET(i->memory_zswap_current, 0, CGROUP_LIMIT_MAX);
|
||||
show_memory_zswap_current = !IN_SET(i->memory_zswap_current, 0, CGROUP_LIMIT_MAX),
|
||||
show_memory_available = i->memory_high != CGROUP_LIMIT_MAX || i->memory_max != CGROUP_LIMIT_MAX;
|
||||
if (i->memory_peak != CGROUP_LIMIT_MAX ||
|
||||
show_memory_swap ||
|
||||
show_memory_zswap_current ||
|
||||
show_memory_available ||
|
||||
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 ||
|
||||
|
@ -772,7 +775,7 @@ static void print_status_info(
|
|||
printf("%slimit: %s", prefix, FORMAT_BYTES(i->memory_limit));
|
||||
prefix = " ";
|
||||
}
|
||||
if (i->memory_available != CGROUP_LIMIT_MAX) {
|
||||
if (show_memory_available) {
|
||||
printf("%savailable: %s", prefix, FORMAT_BYTES(i->memory_available));
|
||||
prefix = " ";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue