systemctl-show: only show available memory if it was artifically limited
authorFlorian Schmaus <flo@geekplace.eu>
Tue, 21 Nov 2023 08:10:10 +0000 (09:10 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 21 Nov 2023 12:50:07 +0000 (12:50 +0000)
commitf380473edfa899706d630bb64750ab50c5c04961
tree851cfaf91afdb9496fcf35075f3288bab22dc438
parentdc78603a583d199baa7a7a0a257095ad65861242
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.
src/systemctl/systemctl-show.c