diff --git a/man/org.freedesktop.systemd1.xml b/man/org.freedesktop.systemd1.xml index 03ff1401e05..117f802a7a4 100644 --- a/man/org.freedesktop.systemd1.xml +++ b/man/org.freedesktop.systemd1.xml @@ -2782,6 +2782,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemorySwapPeak = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") + readonly t MemoryZswapCurrent = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemoryAvailable = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t CPUUsageNSec = ...; @@ -3415,6 +3417,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { + + @@ -4053,6 +4057,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { + + @@ -4855,6 +4861,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket { @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemorySwapPeak = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") + readonly t MemoryZswapCurrent = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemoryAvailable = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t CPUUsageNSec = ...; @@ -5498,6 +5506,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket { + + @@ -6118,6 +6128,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket { + + @@ -6794,6 +6806,8 @@ node /org/freedesktop/systemd1/unit/home_2emount { @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemorySwapPeak = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") + readonly t MemoryZswapCurrent = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemoryAvailable = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t CPUUsageNSec = ...; @@ -7365,6 +7379,8 @@ node /org/freedesktop/systemd1/unit/home_2emount { + + @@ -7899,6 +7915,8 @@ node /org/freedesktop/systemd1/unit/home_2emount { + + @@ -8698,6 +8716,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap { @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemorySwapPeak = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") + readonly t MemoryZswapCurrent = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemoryAvailable = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t CPUUsageNSec = ...; @@ -9255,6 +9275,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap { + + @@ -9775,6 +9797,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap { + + @@ -10433,6 +10457,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice { @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemorySwapPeak = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") + readonly t MemoryZswapCurrent = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemoryAvailable = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t CPUUsageNSec = ...; @@ -10616,6 +10642,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice { + + @@ -10800,6 +10828,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice { + + @@ -11012,6 +11042,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope { @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemorySwapPeak = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") + readonly t MemoryZswapCurrent = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t MemoryAvailable = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("false") readonly t CPUUsageNSec = ...; @@ -11215,6 +11247,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope { + + @@ -11429,6 +11463,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope { + + @@ -11827,8 +11863,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \ SetLoginEnvironment, CoredumpReceive, MemoryPeak, - MemorySwapCurrent, and - MemorySwapPeak were added in version 255. + MemorySwapCurrent, + MemorySwapPeak, and + MemoryZswapCurrent were added in version 255. Socket Unit Objects @@ -11857,8 +11894,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \ SetLoginEnvironment, CoredumpReceive, MemoryPeak, - MemorySwapCurrent, and - MemorySwapPeak were added in version 255. + MemorySwapCurrent, + MemorySwapPeak, and + MemoryZswapCurrent were added in version 255. Mount Unit Objects @@ -11885,8 +11923,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \ SetLoginEnvironment, CoredumpReceive, MemoryPeak, - MemorySwapCurrent, and - MemorySwapPeak were added in version 255. + MemorySwapCurrent, + MemorySwapPeak, and + MemoryZswapCurrent were added in version 255. Swap Unit Objects @@ -11913,8 +11952,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \ SetLoginEnvironment, CoredumpReceive, MemoryPeak, - MemorySwapCurrent, and - MemorySwapPeak were added in version 255. + MemorySwapCurrent, + MemorySwapPeak, and + MemoryZswapCurrent were added in version 255. Slice Unit Objects @@ -11932,8 +11972,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \ NFTSet, CoredumpReceive, MemoryPeak, - MemorySwapCurrent, and - MemorySwapPeak were added in version 255. + MemorySwapCurrent, + MemorySwapPeak, and + MemoryZswapCurrent were added in version 255. Scope Unit Objects @@ -11952,8 +11993,9 @@ $ gdbus introspect --system --dest org.freedesktop.systemd1 \ NFTSet, CoredumpReceive, MemoryPeak, - MemorySwapCurrent, and - MemorySwapPeak were added in version 255. + MemorySwapCurrent, + MemorySwapPeak, and + MemoryZswapCurrent were added in version 255. Job Objects diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 2aa4431ceb9..03fdc7388fc 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -4111,6 +4111,10 @@ int unit_get_memory_swap_peak(Unit *u, uint64_t *ret) { return unit_get_memory_attr_cached(u, "memory.swap.peak", &u->memory_swap_peak_last, ret); } +int unit_get_memory_zswap_current(Unit *u, uint64_t *ret) { + return unit_get_memory_attr_raw(u, "memory.zswap.current", ret); +} + int unit_get_tasks_current(Unit *u, uint64_t *ret) { assert(u); assert(ret); diff --git a/src/core/cgroup.h b/src/core/cgroup.h index 40c394f1091..203575ca343 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -356,6 +356,7 @@ int unit_get_memory_current(Unit *u, uint64_t *ret); int unit_get_memory_peak(Unit *u, uint64_t *ret); int unit_get_memory_swap_current(Unit *u, uint64_t *ret); int unit_get_memory_swap_peak(Unit *u, uint64_t *ret); +int unit_get_memory_zswap_current(Unit *u, uint64_t *ret); int unit_get_memory_available(Unit *u, uint64_t *ret); int unit_get_tasks_current(Unit *u, uint64_t *ret); int unit_get_cpu_usage(Unit *u, nsec_t *ret); diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 40cc16c28f6..242c80aba22 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -1149,6 +1149,29 @@ static int property_get_peak_swap_memory( return sd_bus_message_append(reply, "t", sz); } +static int property_get_current_zswap_memory( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + uint64_t sz = UINT64_MAX; + Unit *u = ASSERT_PTR(userdata); + int r; + + assert(bus); + assert(reply); + + r = unit_get_memory_swap_current(u, &sz); + if (r < 0 && r != -ENODATA) + log_unit_warning_errno(u, r, "Failed to get memory.zswap.current attribute: %m"); + + return sd_bus_message_append(reply, "t", sz); +} + static int property_get_available_memory( sd_bus *bus, const char *path, @@ -1608,6 +1631,7 @@ const sd_bus_vtable bus_unit_cgroup_vtable[] = { SD_BUS_PROPERTY("MemoryPeak", "t", property_get_peak_memory, 0, 0), SD_BUS_PROPERTY("MemorySwapCurrent", "t", property_get_current_swap_memory, 0, 0), SD_BUS_PROPERTY("MemorySwapPeak", "t", property_get_peak_swap_memory, 0, 0), + SD_BUS_PROPERTY("MemoryZswapCurrent", "t", property_get_current_zswap_memory, 0, 0), SD_BUS_PROPERTY("MemoryAvailable", "t", property_get_available_memory, 0, 0), SD_BUS_PROPERTY("CPUUsageNSec", "t", property_get_cpu_usage, 0, 0), SD_BUS_PROPERTY("EffectiveCPUs", "ay", property_get_cpuset_cpus, 0, 0), diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 71d93833f7f..25378ff0aa4 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -253,6 +253,7 @@ typedef struct UnitStatusInfo { uint64_t memory_peak; uint64_t memory_swap_current; uint64_t memory_swap_peak; + uint64_t memory_zswap_current; uint64_t memory_min; uint64_t memory_low; uint64_t startup_memory_low; @@ -707,9 +708,11 @@ static void print_status_info( /* 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). */ - bool show_memory_swap = !IN_SET(i->memory_swap_peak, 0, CGROUP_LIMIT_MAX); + 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); if (i->memory_peak != CGROUP_LIMIT_MAX || show_memory_swap || + show_memory_zswap_current || 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 || @@ -785,6 +788,10 @@ static void print_status_info( printf("%sswap peak: %s", prefix, FORMAT_BYTES(i->memory_swap_peak)); prefix = " "; } + if (show_memory_zswap_current) { + printf("%szswap: %s", prefix, FORMAT_BYTES(i->memory_zswap_current)); + prefix = " "; + } printf(")"); } printf("\n"); @@ -2054,6 +2061,7 @@ static int show_one( { "MemoryPeak", "t", NULL, offsetof(UnitStatusInfo, memory_peak) }, { "MemorySwapCurrent", "t", NULL, offsetof(UnitStatusInfo, memory_swap_current) }, { "MemorySwapPeak", "t", NULL, offsetof(UnitStatusInfo, memory_swap_peak) }, + { "MemoryZswapCurrent", "t", NULL, offsetof(UnitStatusInfo, memory_zswap_current) }, { "MemoryAvailable", "t", NULL, offsetof(UnitStatusInfo, memory_available) }, { "DefaultMemoryMin", "t", NULL, offsetof(UnitStatusInfo, default_memory_min) }, { "DefaultMemoryLow", "t", NULL, offsetof(UnitStatusInfo, default_memory_low) }, @@ -2113,6 +2121,7 @@ static int show_one( .memory_peak = CGROUP_LIMIT_MAX, .memory_swap_current = CGROUP_LIMIT_MAX, .memory_swap_peak = CGROUP_LIMIT_MAX, + .memory_zswap_current = CGROUP_LIMIT_MAX, .memory_available = CGROUP_LIMIT_MAX, .cpu_usage_nsec = UINT64_MAX, .tasks_current = UINT64_MAX,