1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

MemoryZSwapMax directive to configure new memory.zswap.max cgroup file

This commit is contained in:
Pasha Vorobyev 2022-02-04 11:49:46 -08:00 committed by Daan De Meyer
parent 2b0cff0469
commit d7fe0a6723
11 changed files with 77 additions and 9 deletions

View File

@ -2707,6 +2707,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemorySwapMax = ...; readonly t MemorySwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryZSwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryLimit = ...; readonly t MemoryLimit = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s DevicePolicy = '...'; readonly s DevicePolicy = '...';
@ -3278,6 +3280,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
<!--property MemorySwapMax is not documented!--> <!--property MemorySwapMax is not documented!-->
<!--property MemoryZSwapMax is not documented!-->
<!--property MemoryLimit is not documented!--> <!--property MemoryLimit is not documented!-->
<!--property DevicePolicy is not documented!--> <!--property DevicePolicy is not documented!-->
@ -3858,6 +3862,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
<variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/> <variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryZSwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/> <variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/>
<variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/> <variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/>
@ -4595,6 +4601,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemorySwapMax = ...; readonly t MemorySwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryZSwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryLimit = ...; readonly t MemoryLimit = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s DevicePolicy = '...'; readonly s DevicePolicy = '...';
@ -5190,6 +5198,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
<!--property MemorySwapMax is not documented!--> <!--property MemorySwapMax is not documented!-->
<!--property MemoryZSwapMax is not documented!-->
<!--property MemoryLimit is not documented!--> <!--property MemoryLimit is not documented!-->
<!--property DevicePolicy is not documented!--> <!--property DevicePolicy is not documented!-->
@ -5764,6 +5774,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
<variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/> <variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryZSwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/> <variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/>
<variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/> <variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/>
@ -6390,6 +6402,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemorySwapMax = ...; readonly t MemorySwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryZSwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryLimit = ...; readonly t MemoryLimit = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s DevicePolicy = '...'; readonly s DevicePolicy = '...';
@ -6913,6 +6927,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
<!--property MemorySwapMax is not documented!--> <!--property MemorySwapMax is not documented!-->
<!--property MemoryZSwapMax is not documented!-->
<!--property MemoryLimit is not documented!--> <!--property MemoryLimit is not documented!-->
<!--property DevicePolicy is not documented!--> <!--property DevicePolicy is not documented!-->
@ -7405,6 +7421,8 @@ node /org/freedesktop/systemd1/unit/home_2emount {
<variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/> <variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryZSwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/> <variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/>
<variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/> <variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/>
@ -8158,6 +8176,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemorySwapMax = ...; readonly t MemorySwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryZSwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryLimit = ...; readonly t MemoryLimit = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s DevicePolicy = '...'; readonly s DevicePolicy = '...';
@ -8667,6 +8687,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
<!--property MemorySwapMax is not documented!--> <!--property MemorySwapMax is not documented!-->
<!--property MemoryZSwapMax is not documented!-->
<!--property MemoryLimit is not documented!--> <!--property MemoryLimit is not documented!-->
<!--property DevicePolicy is not documented!--> <!--property DevicePolicy is not documented!-->
@ -9145,6 +9167,8 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
<variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/> <variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryZSwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/> <variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/>
<variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/> <variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/>
@ -9757,6 +9781,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemorySwapMax = ...; readonly t MemorySwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryZSwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryLimit = ...; readonly t MemoryLimit = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s DevicePolicy = '...'; readonly s DevicePolicy = '...';
@ -9908,6 +9934,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
<!--property MemorySwapMax is not documented!--> <!--property MemorySwapMax is not documented!-->
<!--property MemoryZSwapMax is not documented!-->
<!--property MemoryLimit is not documented!--> <!--property MemoryLimit is not documented!-->
<!--property DevicePolicy is not documented!--> <!--property DevicePolicy is not documented!-->
@ -10066,6 +10094,8 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
<variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/> <variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryZSwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/> <variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/>
<variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/> <variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/>
@ -10246,6 +10276,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemorySwapMax = ...; readonly t MemorySwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryZSwapMax = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly t MemoryLimit = ...; readonly t MemoryLimit = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s DevicePolicy = '...'; readonly s DevicePolicy = '...';
@ -10415,6 +10447,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
<!--property MemorySwapMax is not documented!--> <!--property MemorySwapMax is not documented!-->
<!--property MemoryZSwapMax is not documented!-->
<!--property MemoryLimit is not documented!--> <!--property MemoryLimit is not documented!-->
<!--property DevicePolicy is not documented!--> <!--property DevicePolicy is not documented!-->
@ -10601,6 +10635,8 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
<variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/> <variablelist class="dbus-property" generated="True" extra-ref="MemorySwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryZSwapMax"/>
<variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/> <variablelist class="dbus-property" generated="True" extra-ref="MemoryLimit"/>
<variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/> <variablelist class="dbus-property" generated="True" extra-ref="DevicePolicy"/>

View File

@ -325,14 +325,15 @@
<varlistentry> <varlistentry>
<term><varname>MemorySwapMax=<replaceable>bytes</replaceable></varname></term> <term><varname>MemorySwapMax=<replaceable>bytes</replaceable></varname></term>
<term><varname>MemoryZSwapMax=<replaceable>bytes</replaceable></varname></term>
<listitem> <listitem>
<para>Specify the absolute limit on swap usage of the executed processes in this unit.</para> <para>Specify the absolute limit on (z)swap usage of the executed processes in this unit.</para>
<para>Takes a swap size in bytes. If the value is suffixed with K, M, G or T, the specified swap size is <para>Takes a swap size in bytes. If the value is suffixed with K, M, G or T, the specified swap size is
parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively. If assigned the parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively. If assigned the
special value <literal>infinity</literal>, no swap limit is applied. This controls the special value <literal>infinity</literal>, no swap limit is applied. These settings control the
<literal>memory.swap.max</literal> control group attribute. For details about this control group attribute, <literal>memory.(z)swap.max</literal> control group attributes. For details about these control group attributes,
see <ulink url="https://docs.kernel.org/admin-guide/cgroup-v2.html#memory-interface-files">Memory Interface Files</ulink>.</para> see <ulink url="https://docs.kernel.org/admin-guide/cgroup-v2.html#memory-interface-files">Memory Interface Files</ulink>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -151,6 +151,7 @@ void cgroup_context_init(CGroupContext *c) {
.memory_high = CGROUP_LIMIT_MAX, .memory_high = CGROUP_LIMIT_MAX,
.memory_max = CGROUP_LIMIT_MAX, .memory_max = CGROUP_LIMIT_MAX,
.memory_swap_max = CGROUP_LIMIT_MAX, .memory_swap_max = CGROUP_LIMIT_MAX,
.memory_zswap_max = CGROUP_LIMIT_MAX,
.memory_limit = CGROUP_LIMIT_MAX, .memory_limit = CGROUP_LIMIT_MAX,
@ -354,6 +355,9 @@ static int unit_compare_memory_limit(Unit *u, const char *property_name, uint64_
} else if (streq(property_name, "MemorySwapMax")) { } else if (streq(property_name, "MemorySwapMax")) {
unit_value = c->memory_swap_max; unit_value = c->memory_swap_max;
file = "memory.swap.max"; file = "memory.swap.max";
} else if (streq(property_name, "MemoryZSwapMax")) {
unit_value = c->memory_zswap_max;
file = "memory.zswap.max";
} else } else
return -EINVAL; return -EINVAL;
@ -396,9 +400,10 @@ static char *format_cgroup_memory_limit_comparison(char *buf, size_t l, Unit *u,
/* memory.swap.max is special in that it relies on CONFIG_MEMCG_SWAP (and the default swapaccount=1). /* memory.swap.max is special in that it relies on CONFIG_MEMCG_SWAP (and the default swapaccount=1).
* In the absence of reliably being able to detect whether memcg swap support is available or not, * In the absence of reliably being able to detect whether memcg swap support is available or not,
* only complain if the error is not ENOENT. */ * only complain if the error is not ENOENT. This is similarly the case for memory.zswap.max relying
* on CONFIG_ZSWAP. */
if (r > 0 || IN_SET(r, -ENODATA, -EOWNERDEAD) || if (r > 0 || IN_SET(r, -ENODATA, -EOWNERDEAD) ||
(r == -ENOENT && streq(property_name, "MemorySwapMax"))) (r == -ENOENT && STR_IN_SET(property_name, "MemorySwapMax", "MemoryZSwapMax")))
buf[0] = 0; buf[0] = 0;
else if (r < 0) { else if (r < 0) {
errno = -r; errno = -r;
@ -462,6 +467,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
"%sMemoryHigh: %" PRIu64 "%s\n" "%sMemoryHigh: %" PRIu64 "%s\n"
"%sMemoryMax: %" PRIu64 "%s\n" "%sMemoryMax: %" PRIu64 "%s\n"
"%sMemorySwapMax: %" PRIu64 "%s\n" "%sMemorySwapMax: %" PRIu64 "%s\n"
"%sMemoryZSwapMax: %" PRIu64 "%s\n"
"%sMemoryLimit: %" PRIu64 "\n" "%sMemoryLimit: %" PRIu64 "\n"
"%sTasksMax: %" PRIu64 "\n" "%sTasksMax: %" PRIu64 "\n"
"%sDevicePolicy: %s\n" "%sDevicePolicy: %s\n"
@ -498,6 +504,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
prefix, c->memory_high, format_cgroup_memory_limit_comparison(cdc, sizeof(cdc), u, "MemoryHigh"), prefix, c->memory_high, format_cgroup_memory_limit_comparison(cdc, sizeof(cdc), u, "MemoryHigh"),
prefix, c->memory_max, format_cgroup_memory_limit_comparison(cdd, sizeof(cdd), u, "MemoryMax"), prefix, c->memory_max, format_cgroup_memory_limit_comparison(cdd, sizeof(cdd), u, "MemoryMax"),
prefix, c->memory_swap_max, format_cgroup_memory_limit_comparison(cde, sizeof(cde), u, "MemorySwapMax"), prefix, c->memory_swap_max, format_cgroup_memory_limit_comparison(cde, sizeof(cde), u, "MemorySwapMax"),
prefix, c->memory_zswap_max, format_cgroup_memory_limit_comparison(cde, sizeof(cde), u, "MemoryZSwapMax"),
prefix, c->memory_limit, prefix, c->memory_limit,
prefix, tasks_max_resolve(&c->tasks_max), prefix, tasks_max_resolve(&c->tasks_max),
prefix, cgroup_device_policy_to_string(c->device_policy), prefix, cgroup_device_policy_to_string(c->device_policy),
@ -1209,7 +1216,7 @@ static bool unit_has_unified_memory_config(Unit *u) {
return unit_get_ancestor_memory_min(u) > 0 || unit_get_ancestor_memory_low(u) > 0 || return unit_get_ancestor_memory_min(u) > 0 || unit_get_ancestor_memory_low(u) > 0 ||
c->memory_high != CGROUP_LIMIT_MAX || c->memory_max != CGROUP_LIMIT_MAX || c->memory_high != CGROUP_LIMIT_MAX || c->memory_max != CGROUP_LIMIT_MAX ||
c->memory_swap_max != CGROUP_LIMIT_MAX; c->memory_swap_max != CGROUP_LIMIT_MAX || c->memory_zswap_max != CGROUP_LIMIT_MAX;
} }
static void cgroup_apply_unified_memory_limit(Unit *u, const char *file, uint64_t v) { static void cgroup_apply_unified_memory_limit(Unit *u, const char *file, uint64_t v) {
@ -1569,11 +1576,12 @@ static void cgroup_context_apply(
if ((apply_mask & CGROUP_MASK_MEMORY) && !is_local_root) { if ((apply_mask & CGROUP_MASK_MEMORY) && !is_local_root) {
if (cg_all_unified() > 0) { if (cg_all_unified() > 0) {
uint64_t max, swap_max = CGROUP_LIMIT_MAX; uint64_t max, swap_max = CGROUP_LIMIT_MAX, zswap_max = CGROUP_LIMIT_MAX;
if (unit_has_unified_memory_config(u)) { if (unit_has_unified_memory_config(u)) {
max = c->memory_max; max = c->memory_max;
swap_max = c->memory_swap_max; swap_max = c->memory_swap_max;
zswap_max = c->memory_zswap_max;
} else { } else {
max = c->memory_limit; max = c->memory_limit;
@ -1586,6 +1594,7 @@ static void cgroup_context_apply(
cgroup_apply_unified_memory_limit(u, "memory.high", c->memory_high); cgroup_apply_unified_memory_limit(u, "memory.high", c->memory_high);
cgroup_apply_unified_memory_limit(u, "memory.max", max); cgroup_apply_unified_memory_limit(u, "memory.max", max);
cgroup_apply_unified_memory_limit(u, "memory.swap.max", swap_max); cgroup_apply_unified_memory_limit(u, "memory.swap.max", swap_max);
cgroup_apply_unified_memory_limit(u, "memory.zswap.max", zswap_max);
(void) set_attribute_and_warn(u, "memory", "memory.oom.group", one_zero(c->memory_oom_group)); (void) set_attribute_and_warn(u, "memory", "memory.oom.group", one_zero(c->memory_oom_group));

View File

@ -149,6 +149,7 @@ struct CGroupContext {
uint64_t memory_high; uint64_t memory_high;
uint64_t memory_max; uint64_t memory_max;
uint64_t memory_swap_max; uint64_t memory_swap_max;
uint64_t memory_zswap_max;
bool default_memory_min_set:1; bool default_memory_min_set:1;
bool default_memory_low_set:1; bool default_memory_low_set:1;

View File

@ -468,6 +468,7 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
SD_BUS_PROPERTY("MemoryHigh", "t", NULL, offsetof(CGroupContext, memory_high), 0), SD_BUS_PROPERTY("MemoryHigh", "t", NULL, offsetof(CGroupContext, memory_high), 0),
SD_BUS_PROPERTY("MemoryMax", "t", NULL, offsetof(CGroupContext, memory_max), 0), SD_BUS_PROPERTY("MemoryMax", "t", NULL, offsetof(CGroupContext, memory_max), 0),
SD_BUS_PROPERTY("MemorySwapMax", "t", NULL, offsetof(CGroupContext, memory_swap_max), 0), SD_BUS_PROPERTY("MemorySwapMax", "t", NULL, offsetof(CGroupContext, memory_swap_max), 0),
SD_BUS_PROPERTY("MemoryZSwapMax", "t", NULL, offsetof(CGroupContext, memory_zswap_max), 0),
SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), 0), SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), 0),
SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), 0), SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), 0),
SD_BUS_PROPERTY("DeviceAllow", "a(ss)", property_get_device_allow, 0, 0), SD_BUS_PROPERTY("DeviceAllow", "a(ss)", property_get_device_allow, 0, 0),
@ -887,6 +888,7 @@ BUS_DEFINE_SET_CGROUP_WEIGHT(blockio_weight, CGROUP_MASK_BLKIO, CGROUP_BLKIO_WEI
BUS_DEFINE_SET_CGROUP_LIMIT(memory, CGROUP_MASK_MEMORY, physical_memory_scale, 1); BUS_DEFINE_SET_CGROUP_LIMIT(memory, CGROUP_MASK_MEMORY, physical_memory_scale, 1);
BUS_DEFINE_SET_CGROUP_LIMIT(memory_protection, CGROUP_MASK_MEMORY, physical_memory_scale, 0); BUS_DEFINE_SET_CGROUP_LIMIT(memory_protection, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
BUS_DEFINE_SET_CGROUP_LIMIT(swap, CGROUP_MASK_MEMORY, physical_memory_scale, 0); BUS_DEFINE_SET_CGROUP_LIMIT(swap, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
BUS_DEFINE_SET_CGROUP_LIMIT(zswap, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
REENABLE_WARNING; REENABLE_WARNING;
static int bus_cgroup_set_cpu_weight( static int bus_cgroup_set_cpu_weight(
@ -1075,6 +1077,9 @@ int bus_cgroup_set_property(
if (streq(name, "MemorySwapMax")) if (streq(name, "MemorySwapMax"))
return bus_cgroup_set_swap(u, name, &c->memory_swap_max, message, flags, error); return bus_cgroup_set_swap(u, name, &c->memory_swap_max, message, flags, error);
if (streq(name, "MemoryZSwapMax"))
return bus_cgroup_set_zswap(u, name, &c->memory_zswap_max, message, flags, error);
if (streq(name, "MemoryMax")) if (streq(name, "MemoryMax"))
return bus_cgroup_set_memory(u, name, &c->memory_max, message, flags, error); return bus_cgroup_set_memory(u, name, &c->memory_max, message, flags, error);
@ -1115,6 +1120,9 @@ int bus_cgroup_set_property(
if (streq(name, "MemorySwapMaxScale")) if (streq(name, "MemorySwapMaxScale"))
return bus_cgroup_set_swap_scale(u, name, &c->memory_swap_max, message, flags, error); return bus_cgroup_set_swap_scale(u, name, &c->memory_swap_max, message, flags, error);
if (streq(name, "MemoryZSwapMaxScale"))
return bus_cgroup_set_zswap_scale(u, name, &c->memory_zswap_max, message, flags, error);
if (streq(name, "MemoryMaxScale")) if (streq(name, "MemoryMaxScale"))
return bus_cgroup_set_memory_scale(u, name, &c->memory_max, message, flags, error); return bus_cgroup_set_memory_scale(u, name, &c->memory_max, message, flags, error);

View File

@ -205,6 +205,7 @@
{{type}}.MemoryHigh, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) {{type}}.MemoryHigh, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context)
{{type}}.MemoryMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) {{type}}.MemoryMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context)
{{type}}.MemorySwapMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) {{type}}.MemorySwapMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context)
{{type}}.MemoryZSwapMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context)
{{type}}.MemoryLimit, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) {{type}}.MemoryLimit, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context)
{{type}}.DeviceAllow, config_parse_device_allow, 0, offsetof({{type}}, cgroup_context) {{type}}.DeviceAllow, config_parse_device_allow, 0, offsetof({{type}}, cgroup_context)
{{type}}.DevicePolicy, config_parse_device_policy, 0, offsetof({{type}}, cgroup_context.device_policy) {{type}}.DevicePolicy, config_parse_device_policy, 0, offsetof({{type}}, cgroup_context.device_policy)

View File

@ -3826,7 +3826,7 @@ int config_parse_memory_limit(
bytes = physical_memory_scale(r, 10000U); bytes = physical_memory_scale(r, 10000U);
if (bytes >= UINT64_MAX || if (bytes >= UINT64_MAX ||
(bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) { (bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryZSwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Memory limit '%s' out of range, ignoring.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Memory limit '%s' out of range, ignoring.", rvalue);
return 0; return 0;
} }
@ -3850,6 +3850,8 @@ int config_parse_memory_limit(
c->memory_max = bytes; c->memory_max = bytes;
else if (streq(lvalue, "MemorySwapMax")) else if (streq(lvalue, "MemorySwapMax"))
c->memory_swap_max = bytes; c->memory_swap_max = bytes;
else if (streq(lvalue, "MemoryZSwapMax"))
c->memory_zswap_max = bytes;
else if (streq(lvalue, "MemoryLimit")) { else if (streq(lvalue, "MemoryLimit")) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unit uses MemoryLimit=; please use MemoryMax= instead. Support for MemoryLimit= will be removed soon."); "Unit uses MemoryLimit=; please use MemoryMax= instead. Support for MemoryLimit= will be removed soon.");

View File

@ -162,7 +162,7 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
bus_print_property_value(name, expected_value, flags, "[not set]"); bus_print_property_value(name, expected_value, flags, "[not set]");
else if ((STR_IN_SET(name, "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryLimit", "MemoryAvailable") && u == CGROUP_LIMIT_MAX) || else if ((STR_IN_SET(name, "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryZSwapMax", "MemoryLimit", "MemoryAvailable") && u == CGROUP_LIMIT_MAX) ||
(STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == UINT64_MAX) || (STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == UINT64_MAX) ||
(startswith(name, "Limit") && u == UINT64_MAX) || (startswith(name, "Limit") && u == UINT64_MAX) ||
(startswith(name, "DefaultLimit") && u == UINT64_MAX)) (startswith(name, "DefaultLimit") && u == UINT64_MAX))

View File

@ -523,6 +523,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
"MemoryHigh", "MemoryHigh",
"MemoryMax", "MemoryMax",
"MemorySwapMax", "MemorySwapMax",
"MemoryZSwapMax",
"MemoryLimit", "MemoryLimit",
"TasksMax")) { "TasksMax")) {

View File

@ -250,6 +250,7 @@ typedef struct UnitStatusInfo {
uint64_t memory_high; uint64_t memory_high;
uint64_t memory_max; uint64_t memory_max;
uint64_t memory_swap_max; uint64_t memory_swap_max;
uint64_t memory_zswap_max;
uint64_t memory_limit; uint64_t memory_limit;
uint64_t memory_available; uint64_t memory_available;
uint64_t cpu_usage_nsec; uint64_t cpu_usage_nsec;
@ -700,6 +701,7 @@ static void print_status_info(
if (i->memory_min > 0 || i->memory_low > 0 || if (i->memory_min > 0 || i->memory_low > 0 ||
i->memory_high != CGROUP_LIMIT_MAX || i->memory_max != CGROUP_LIMIT_MAX || i->memory_high != CGROUP_LIMIT_MAX || i->memory_max != CGROUP_LIMIT_MAX ||
i->memory_swap_max != CGROUP_LIMIT_MAX || i->memory_swap_max != CGROUP_LIMIT_MAX ||
i->memory_zswap_max != CGROUP_LIMIT_MAX ||
i->memory_available != CGROUP_LIMIT_MAX || i->memory_available != CGROUP_LIMIT_MAX ||
i->memory_limit != CGROUP_LIMIT_MAX) { i->memory_limit != CGROUP_LIMIT_MAX) {
const char *prefix = ""; const char *prefix = "";
@ -725,6 +727,10 @@ static void print_status_info(
printf("%sswap max: %s", prefix, FORMAT_BYTES(i->memory_swap_max)); printf("%sswap max: %s", prefix, FORMAT_BYTES(i->memory_swap_max));
prefix = " "; prefix = " ";
} }
if (i->memory_zswap_max != CGROUP_LIMIT_MAX) {
printf("%szswap max: %s", prefix, FORMAT_BYTES(i->memory_zswap_max));
prefix = " ";
}
if (i->memory_limit != CGROUP_LIMIT_MAX) { if (i->memory_limit != CGROUP_LIMIT_MAX) {
printf("%slimit: %s", prefix, FORMAT_BYTES(i->memory_limit)); printf("%slimit: %s", prefix, FORMAT_BYTES(i->memory_limit));
prefix = " "; prefix = " ";
@ -1935,6 +1941,7 @@ static int show_one(
{ "MemoryHigh", "t", NULL, offsetof(UnitStatusInfo, memory_high) }, { "MemoryHigh", "t", NULL, offsetof(UnitStatusInfo, memory_high) },
{ "MemoryMax", "t", NULL, offsetof(UnitStatusInfo, memory_max) }, { "MemoryMax", "t", NULL, offsetof(UnitStatusInfo, memory_max) },
{ "MemorySwapMax", "t", NULL, offsetof(UnitStatusInfo, memory_swap_max) }, { "MemorySwapMax", "t", NULL, offsetof(UnitStatusInfo, memory_swap_max) },
{ "MemoryZSwapMax", "t", NULL, offsetof(UnitStatusInfo, memory_zswap_max) },
{ "MemoryLimit", "t", NULL, offsetof(UnitStatusInfo, memory_limit) }, { "MemoryLimit", "t", NULL, offsetof(UnitStatusInfo, memory_limit) },
{ "CPUUsageNSec", "t", NULL, offsetof(UnitStatusInfo, cpu_usage_nsec) }, { "CPUUsageNSec", "t", NULL, offsetof(UnitStatusInfo, cpu_usage_nsec) },
{ "TasksCurrent", "t", NULL, offsetof(UnitStatusInfo, tasks_current) }, { "TasksCurrent", "t", NULL, offsetof(UnitStatusInfo, tasks_current) },
@ -1969,6 +1976,7 @@ static int show_one(
.memory_high = CGROUP_LIMIT_MAX, .memory_high = CGROUP_LIMIT_MAX,
.memory_max = CGROUP_LIMIT_MAX, .memory_max = CGROUP_LIMIT_MAX,
.memory_swap_max = CGROUP_LIMIT_MAX, .memory_swap_max = CGROUP_LIMIT_MAX,
.memory_zswap_max = CGROUP_LIMIT_MAX,
.memory_limit = UINT64_MAX, .memory_limit = UINT64_MAX,
.memory_available = CGROUP_LIMIT_MAX, .memory_available = CGROUP_LIMIT_MAX,
.cpu_usage_nsec = UINT64_MAX, .cpu_usage_nsec = UINT64_MAX,

View File

@ -160,6 +160,7 @@ MemoryLimit=
MemoryLow= MemoryLow=
MemoryMax= MemoryMax=
MemorySwapMax= MemorySwapMax=
MemoryZSwapMax=
MessageQueueMaxMessages= MessageQueueMaxMessages=
MessageQueueMessageSize= MessageQueueMessageSize=
MountAPIVFS= MountAPIVFS=