diff options
author | Florian Schmaus <flo@geekplace.eu> | 2023-11-21 09:10:10 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-11-21 13:50:07 +0100 |
commit | f380473edfa899706d630bb64750ab50c5c04961 (patch) | |
tree | 851cfaf91afdb9496fcf35075f3288bab22dc438 /src | |
parent | TODO: register more mime types (diff) | |
download | systemd-f380473edfa899706d630bb64750ab50c5c04961.tar.xz systemd-f380473edfa899706d630bb64750ab50c5c04961.zip |
systemctl-show: only show available memory if it was artifically limited
Systemd 255 changed the semantic of MemoryAvailable with 3565c709f587 ("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.
Before 3565c709f587 ("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.
Diffstat (limited to 'src')
-rw-r--r-- | src/systemctl/systemctl-show.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index de3d8a3cdc..7c5bf1e679 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -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 = " "; } |