]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/cgroup: rename CGROUP_PRESSURE_WATCH_ON/OFF -> CGROUP_PRESSURE_WATCH_YES/NO
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 26 Oct 2024 16:24:49 +0000 (01:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 26 Oct 2024 18:04:35 +0000 (03:04 +0900)
No functional change, but let's print yes/no rather than on/off in systemd-analyze.

Similar to 2e8a581b9cc1132743c2341fc334461096266ad4 and
edd3f4d9b7a63dc9a142ef20119e80d1d9527f2f.
(Note, the commit messages of those commits are wrong, as
 parse_boolean() supports on/off anyway.)

man/systemd.resource-control.xml
src/core/cgroup.c
src/core/cgroup.h
src/core/exec-invoke.c

index 1f16052a3350a6ceba02e89ca767d5227c838a37..ce4dfabfdd92562af64a7538bb162005d4653549 100644 (file)
@@ -1611,20 +1611,19 @@ DeviceAllow=/dev/loop-control
       <varlistentry>
         <term><varname>MemoryPressureWatch=</varname></term>
 
-        <listitem><para>Controls memory pressure monitoring for invoked processes. Takes one of
-        <literal>off</literal>, <literal>on</literal>, <literal>auto</literal> or <literal>skip</literal>. If
-        <literal>off</literal> tells the service not to watch for memory pressure events, by setting the
-        <varname>$MEMORY_PRESSURE_WATCH</varname> environment variable to the literal string
-        <filename>/dev/null</filename>. If <literal>on</literal> tells the service to watch for memory
-        pressure events. This enables memory accounting for the service, and ensures the
-        <filename>memory.pressure</filename> cgroup attribute file is accessible for reading and writing by the
-        service's user. It then sets the <varname>$MEMORY_PRESSURE_WATCH</varname> environment variable for
-        processes invoked by the unit to the file system path to this file. The threshold information
-        configured with <varname>MemoryPressureThresholdSec=</varname> is encoded in the
-        <varname>$MEMORY_PRESSURE_WRITE</varname> environment variable. If the <literal>auto</literal> value
-        is set the protocol is enabled if memory accounting is anyway enabled for the unit, and disabled
-        otherwise. If set to <literal>skip</literal> the logic is neither enabled, nor disabled and the two
-        environment variables are not set.</para>
+        <listitem><para>Controls memory pressure monitoring for invoked processes. Takes a boolean or one of
+        <literal>auto</literal> and <literal>skip</literal>. If <literal>no</literal>, tells the service not
+        to watch for memory pressure events, by setting the <varname>$MEMORY_PRESSURE_WATCH</varname>
+        environment variable to the literal string <filename>/dev/null</filename>. If <literal>yes</literal>,
+        tells the service to watch for memory pressure events. This enables memory accounting for the
+        service, and ensures the <filename>memory.pressure</filename> cgroup attribute file is accessible for
+        reading and writing by the service's user. It then sets the <varname>$MEMORY_PRESSURE_WATCH</varname>
+        environment variable for processes invoked by the unit to the file system path to this file. The
+        threshold information configured with <varname>MemoryPressureThresholdSec=</varname> is encoded in
+        the <varname>$MEMORY_PRESSURE_WRITE</varname> environment variable. If the <literal>auto</literal>
+        value is set the protocol is enabled if memory accounting is anyway enabled for the unit, and
+        disabled otherwise. If set to <literal>skip</literal> the logic is neither enabled, nor disabled and
+        the two environment variables are not set.</para>
 
         <para>Note that services are free to use the two environment variables, but it's unproblematic if
         they ignore them. Memory pressure handling must be implemented individually in each service, and
index 47a771d51e0191cc2f2d402369b5e92b6966bc34..6933aae54de4833a50964bf2e37cbe2e57323b03 100644 (file)
@@ -5614,13 +5614,13 @@ static const char* const cgroup_device_policy_table[_CGROUP_DEVICE_POLICY_MAX] =
 DEFINE_STRING_TABLE_LOOKUP(cgroup_device_policy, CGroupDevicePolicy);
 
 static const char* const cgroup_pressure_watch_table[_CGROUP_PRESSURE_WATCH_MAX] = {
-        [CGROUP_PRESSURE_WATCH_OFF]  = "off",
+        [CGROUP_PRESSURE_WATCH_NO]   = "no",
+        [CGROUP_PRESSURE_WATCH_YES]  = "yes",
         [CGROUP_PRESSURE_WATCH_AUTO] = "auto",
-        [CGROUP_PRESSURE_WATCH_ON]   = "on",
         [CGROUP_PRESSURE_WATCH_SKIP] = "skip",
 };
 
-DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(cgroup_pressure_watch, CGroupPressureWatch, CGROUP_PRESSURE_WATCH_ON);
+DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(cgroup_pressure_watch, CGroupPressureWatch, CGROUP_PRESSURE_WATCH_YES);
 
 static const char* const cgroup_ip_accounting_metric_table[_CGROUP_IP_ACCOUNTING_METRIC_MAX] = {
         [CGROUP_IP_INGRESS_BYTES]   = "IPIngressBytes",
index 550c1ea88fa2312c2e7ef9005814e794570404b8..1ed74831c8a6644b1628df1bec25c4e21b96a976 100644 (file)
@@ -126,9 +126,9 @@ struct CGroupSocketBindItem {
 };
 
 typedef enum CGroupPressureWatch {
-        CGROUP_PRESSURE_WATCH_OFF,      /* → tells the service payload explicitly not to watch for memory pressure */
+        CGROUP_PRESSURE_WATCH_NO,       /* → tells the service payload explicitly not to watch for memory pressure */
+        CGROUP_PRESSURE_WATCH_YES,
         CGROUP_PRESSURE_WATCH_AUTO,     /* → on if memory account is on anyway for the unit, otherwise off */
-        CGROUP_PRESSURE_WATCH_ON,
         CGROUP_PRESSURE_WATCH_SKIP,     /* → doesn't set up memory pressure watch, but also doesn't explicitly tell payload to avoid it */
         _CGROUP_PRESSURE_WATCH_MAX,
         _CGROUP_PRESSURE_WATCH_INVALID = -EINVAL,
@@ -403,7 +403,7 @@ void cgroup_context_remove_socket_bind(CGroupSocketBindItem **head);
 static inline bool cgroup_context_want_memory_pressure(const CGroupContext *c) {
         assert(c);
 
-        return c->memory_pressure_watch == CGROUP_PRESSURE_WATCH_ON ||
+        return c->memory_pressure_watch == CGROUP_PRESSURE_WATCH_YES ||
                 (c->memory_pressure_watch == CGROUP_PRESSURE_WATCH_AUTO && c->memory_accounting);
 }
 
index 4b63e2a204027649c6a25a6e59286e7eea465035..0dbf34042d6ed473f8d2bf4358bbeb06137689b8 100644 (file)
@@ -4607,7 +4607,7 @@ int exec_invoke(
                                                             "Failed to adjust ownership of '%s', ignoring: %m", memory_pressure_path);
                                         memory_pressure_path = mfree(memory_pressure_path);
                                 }
-                        } else if (cgroup_context->memory_pressure_watch == CGROUP_PRESSURE_WATCH_OFF) {
+                        } else if (cgroup_context->memory_pressure_watch == CGROUP_PRESSURE_WATCH_NO) {
                                 memory_pressure_path = strdup("/dev/null"); /* /dev/null is explicit indicator for turning of memory pressure watch */
                                 if (!memory_pressure_path) {
                                         *exit_status = EXIT_MEMORY;