core/cgroup: rename CGROUP_PRESSURE_WATCH_ON/OFF -> CGROUP_PRESSURE_WATCH_YES/NO
No functional change, but let's print yes/no rather than on/off in systemd-analyze. Similar to2e8a581b9candedd3f4d9b7. (Note, the commit messages of those commits are wrong, as parse_boolean() supports on/off anyway.)
This commit is contained in:
@@ -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
|
||||
|
||||
+3
-3
@@ -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",
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user