summaryrefslogtreecommitdiffstats
path: root/src/systemctl
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-05-08 19:12:17 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2024-05-08 21:20:05 +0200
commit8f9acf8e10e398c982d3372b686f5bcdc1ca966a (patch)
tree59797348b863789b72a4897e8596283a5b8c9c4f /src/systemctl
parentMerge pull request #32717 from keszybz/very-important-fixes (diff)
downloadsystemd-8f9acf8e10e398c982d3372b686f5bcdc1ca966a.tar.xz
systemd-8f9acf8e10e398c982d3372b686f5bcdc1ca966a.zip
systemctl-show: make show_memory_available cover memory_available itself
Follow-up for f380473edfa899706d630bb64750ab50c5c04961 This cleans up the code a bit. Also, before this commit, if MemoryAvailable is set but show_memory_available is false, and we have nothing else to output, empty parenthesis is shown. This can be easily reproduced on -.slice: > systemctl status -- -.slice > ... > Memory: 1.8G () > ...
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-show.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index aee839de4c..74d6465739 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -714,13 +714,12 @@ static void print_status_info(
if (i->memory_current != UINT64_MAX) {
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).
- Only show the available memory if it was artificially limited. */
bool 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;
+ /* Only show the available memory if it was artificially limited. */
+ show_memory_available = i->memory_available != CGROUP_LIMIT_MAX &&
+ (i->memory_high != CGROUP_LIMIT_MAX || i->memory_max != CGROUP_LIMIT_MAX);
if (show_memory_peak ||
- show_memory_swap_peak ||
+ show_memory_swap_peak || /* We don't need to check memory_swap_current, as if peak is 0 that must also be 0 */
show_memory_zswap_current ||
show_memory_available ||
i->memory_min > 0 ||
@@ -729,7 +728,6 @@ static void print_status_info(
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 = "";