| 1 |
<?xml version='1.0'?> <!--*-nxml-*--> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="oomd.conf" conditional='ENABLE_OOMD' |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
<refentryinfo> |
| 9 |
<title>oomd.conf</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>oomd.conf</refentrytitle> |
| 15 |
<manvolnum>5</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>oomd.conf</refname> |
| 20 |
<refname>oomd.conf.d</refname> |
| 21 |
<refpurpose>Global <command>systemd-oomd</command> configuration files</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<para><simplelist> |
| 26 |
<member><filename>/etc/systemd/oomd.conf</filename></member> |
| 27 |
<member><filename>/run/systemd/oomd.conf</filename></member> |
| 28 |
<member><filename>/usr/local/lib/systemd/oomd.conf</filename></member> |
| 29 |
<member><filename>/usr/lib/systemd/oomd.conf</filename></member> |
| 30 |
<member><filename>/etc/systemd/oomd.conf.d/*.conf</filename></member> |
| 31 |
<member><filename>/run/systemd/oomd.conf.d/*.conf</filename></member> |
| 32 |
<member><filename>/usr/local/lib/systemd/oomd.conf.d/*.conf</filename></member> |
| 33 |
<member><filename>/usr/lib/systemd/oomd.conf.d/*.conf</filename></member> |
| 34 |
</simplelist></para> |
| 35 |
</refsynopsisdiv> |
| 36 |
|
| 37 |
<refsect1> |
| 38 |
<title>Description</title> |
| 39 |
|
| 40 |
<para>These files configure the various parameters of the |
| 41 |
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> userspace |
| 42 |
out-of-memory (OOM) killer, |
| 43 |
<citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>. |
| 44 |
See <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry> |
| 45 |
for a general description of the syntax.</para> |
| 46 |
|
| 47 |
</refsect1> |
| 48 |
|
| 49 |
<xi:include href="standard-conf.xml" xpointer="main-conf" /> |
| 50 |
|
| 51 |
<refsect1> |
| 52 |
<title>Prekill event</title> |
| 53 |
|
| 54 |
<para><command>systemd-oomd</command> supports notifying external components before killing a control |
| 55 |
group. |
| 56 |
This is done by sending a notification over varlink to all sockets found in |
| 57 |
<filename>/run/systemd/oomd.prekill.hook/</filename> folder. Each socket should implement the |
| 58 |
<constant>io.systemd.oom.Prekill</constant> interface. The notification contains the control group path |
| 59 |
to allow the hook to identify which control group is being killed. This allows external components to |
| 60 |
perform any necessary cleanup or logging before the control group is terminated. The hook is not intended |
| 61 |
as a way to avoid the kill, but rather as a notification mechanism. |
| 62 |
Note that this is a privileged option as, even if it has a timeout, is synchronous and delays the kill, |
| 63 |
so use with care. |
| 64 |
The typically preferable mechanism to process memory pressure is to do what |
| 65 |
<ulink url="https://systemd.io/PRESSURE">Resource Pressure Handling</ulink> describes which is unprivileged, |
| 66 |
asynchronous and does not delay the kill. |
| 67 |
</para> |
| 68 |
|
| 69 |
</refsect1> |
| 70 |
|
| 71 |
<refsect1> |
| 72 |
<title>OOM Rulesets</title> |
| 73 |
|
| 74 |
<para><command>systemd-oomd</command> supports custom rulesets that define conditions and actions for |
| 75 |
OOM handling on a per-unit basis. Ruleset files use the <filename>.oomrule</filename> extension and are |
| 76 |
loaded from <filename>/etc/systemd/oomd/rules.d/</filename>, |
| 77 |
<filename>/run/systemd/oomd/rules.d/</filename>, |
| 78 |
<filename>/usr/local/lib/systemd/oomd/rules.d/</filename>, and |
| 79 |
<filename>/usr/lib/systemd/oomd/rules.d/</filename>. |
| 80 |
Units opt into rulesets via the <varname>OOMRules=</varname> setting in |
| 81 |
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
| 82 |
which takes a space-separated list of ruleset names (the file name without the <filename>.oomrule</filename> |
| 83 |
extension).</para> |
| 84 |
|
| 85 |
<para>Each ruleset file contains a <literal>[Rule]</literal> section with the following options. At least |
| 86 |
one of <varname>MemoryPressureAbove=</varname> or <varname>SwapUsageMax=</varname> must be configured; |
| 87 |
rulesets with no conditions are ignored. If both are set, the conditions are combined with AND, i.e. the |
| 88 |
action is only triggered when both thresholds are exceeded simultaneously.</para> |
| 89 |
|
| 90 |
<variablelist class='config-directives'> |
| 91 |
<varlistentry> |
| 92 |
<term><varname>MemoryPressureAbove=</varname></term> |
| 93 |
|
| 94 |
<listitem><para>Sets the memory pressure threshold above which the rule's action will be triggered. |
| 95 |
The memory pressure represents the fraction of time in a 10 second window in which all tasks in the |
| 96 |
control group were delayed (PSI <literal>full avg10</literal>). Takes a value specified in percent |
| 97 |
(when suffixed with <literal>%</literal>), permille (<literal>‰</literal>) or permyriad |
| 98 |
(<literal>‱</literal>), between 0% and 100%, inclusive. If unset, this condition is not |
| 99 |
evaluated. A value of <literal>100%</literal> can never be exceeded and is |
| 100 |
therefore rejected with a warning; a value of <literal>0%</literal> makes the condition true on any |
| 101 |
observed pressure, which is usually not useful.</para> |
| 102 |
|
| 103 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 104 |
</varlistentry> |
| 105 |
|
| 106 |
<varlistentry> |
| 107 |
<term><varname>SwapUsageMax=</varname></term> |
| 108 |
|
| 109 |
<listitem><para>Sets the system-wide swap usage threshold above which the rule's action will be |
| 110 |
triggered. Takes a value specified in percent (when suffixed with <literal>%</literal>), |
| 111 |
permille (<literal>‰</literal>) or permyriad (<literal>‱</literal>), |
| 112 |
between 0% and 100%, inclusive. If unset, this condition is not evaluated. A value of |
| 113 |
<literal>100%</literal> can never be exceeded and is therefore rejected with |
| 114 |
a warning; a value of <literal>0%</literal> fires as soon as any swap is in use, which is usually |
| 115 |
not useful.</para> |
| 116 |
|
| 117 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 118 |
</varlistentry> |
| 119 |
|
| 120 |
<varlistentry> |
| 121 |
<term><varname>Action=</varname></term> |
| 122 |
|
| 123 |
<listitem><para>Specifies the action to take when the rule's conditions are met. Takes one of |
| 124 |
<literal>kill-all</literal>, <literal>kill-by-pgscan</literal>, or |
| 125 |
<literal>kill-by-swap</literal>. This setting is mandatory; rulesets without |
| 126 |
<varname>Action=</varname> are ignored.</para> |
| 127 |
|
| 128 |
<itemizedlist> |
| 129 |
<listitem><para><literal>kill-all</literal> sends <constant>SIGKILL</constant> to every process |
| 130 |
in the unit's cgroup hierarchy, including any descendant cgroups.</para></listitem> |
| 131 |
|
| 132 |
<listitem><para><literal>kill-by-pgscan</literal> selects and kills the descendant cgroup with |
| 133 |
the highest recent page scan (reclaim) rate.</para></listitem> |
| 134 |
|
| 135 |
<listitem><para><literal>kill-by-swap</literal> selects and kills the descendant cgroup with the |
| 136 |
highest swap usage.</para></listitem> |
| 137 |
</itemizedlist> |
| 138 |
|
| 139 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 140 |
</varlistentry> |
| 141 |
|
| 142 |
<varlistentry> |
| 143 |
<term><varname>LastingSec=</varname></term> |
| 144 |
|
| 145 |
<listitem><para>Sets the duration the conditions must be continuously met before the action is taken. |
| 146 |
Takes a time span value, see |
| 147 |
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> |
| 148 |
for details on the permitted syntax. Defaults to 0, i.e. the action is taken |
| 149 |
immediately when the conditions are met.</para> |
| 150 |
|
| 151 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 152 |
</varlistentry> |
| 153 |
</variablelist> |
| 154 |
|
| 155 |
</refsect1> |
| 156 |
|
| 157 |
<refsect1> |
| 158 |
<title>[OOM] Section Options</title> |
| 159 |
|
| 160 |
<para>The following options are available in the [OOM] section:</para> |
| 161 |
|
| 162 |
<variablelist class='config-directives'> |
| 163 |
<varlistentry> |
| 164 |
<term><varname>SwapUsedLimit=</varname></term> |
| 165 |
|
| 166 |
<listitem><para>Sets the limit for memory and swap usage on the system before <command>systemd-oomd</command> |
| 167 |
will take action. If the fraction of memory used and the fraction of swap used on the system are both more than |
| 168 |
what is defined here, <command>systemd-oomd</command> will act on eligible descendant control groups with swap |
| 169 |
usage greater than 5% of total swap, starting from the ones with the highest swap usage. Which |
| 170 |
control groups are monitored and what action gets taken depends on what the unit has configured for |
| 171 |
<varname>ManagedOOMSwap=</varname>. Takes a value specified in percent (when suffixed with "%"), |
| 172 |
permille ("‰") or permyriad ("‱"), between 0% and 100%, inclusive. Defaults to 90%.</para> |
| 173 |
|
| 174 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 175 |
</varlistentry> |
| 176 |
|
| 177 |
<varlistentry> |
| 178 |
<term><varname>DefaultMemoryPressureLimit=</varname></term> |
| 179 |
|
| 180 |
<listitem><para>Sets the limit for memory pressure on the unit's control group before |
| 181 |
<command>systemd-oomd</command> will take action. A unit can override this value with |
| 182 |
<varname>ManagedOOMMemoryPressureLimit=</varname>. The memory pressure for this property represents |
| 183 |
the fraction of time in a 10 second window in which all tasks in the control group were delayed. For |
| 184 |
each monitored control group, if the memory pressure on that control group exceeds the limit set for |
| 185 |
longer than the duration set by <varname>DefaultMemoryPressureDurationSec=</varname>, |
| 186 |
<command>systemd-oomd</command> will act on eligible descendant control groups, starting from the |
| 187 |
ones with the most reclaim activity to the least reclaim activity. Which control groups are monitored |
| 188 |
and what action gets taken depends on what the unit has configured for |
| 189 |
<varname>ManagedOOMMemoryPressure=</varname>. Takes a fraction specified in the same way as |
| 190 |
<varname>SwapUsedLimit=</varname> above. Defaults to 60%.</para> |
| 191 |
|
| 192 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 193 |
</varlistentry> |
| 194 |
|
| 195 |
<varlistentry> |
| 196 |
<term><varname>DefaultMemoryPressureDurationSec=</varname></term> |
| 197 |
|
| 198 |
<listitem><para>Sets the amount of time a unit's control group needs to have exceeded memory pressure |
| 199 |
limits before <command>systemd-oomd</command> will take action. A unit can override this value with |
| 200 |
<varname>ManagedOOMMemoryPressureDurationSec=</varname>. Memory pressure limits are defined by |
| 201 |
<varname>DefaultMemoryPressureLimit=</varname> and <varname>ManagedOOMMemoryPressureLimit=</varname>. |
| 202 |
Must be set to 0, or at least 1 second. Defaults to 30 seconds when unset or 0.</para> |
| 203 |
|
| 204 |
<xi:include href="version-info.xml" xpointer="v248"/></listitem> |
| 205 |
</varlistentry> |
| 206 |
|
| 207 |
<varlistentry> |
| 208 |
<term><varname>PrekillHookTimeoutSec=</varname></term> |
| 209 |
|
| 210 |
<listitem><para>Sets the amount of time <command>systemd-oomd</command> will wait for pre-kill hooks |
| 211 |
to complete, before proceeding with the control group termination. Pre-kill hooks work by placing |
| 212 |
varlink socket to <filename>/run/systemd/oomd.prekill.hook/</filename> folder. Each socket should |
| 213 |
implement interface for notification to work. <command>systemd-oomd</command> sends a notification |
| 214 |
before killing a control group for each discovered socket. The timeout is intended to be global and |
| 215 |
not per hook. If all hooks return earlier, the kill is performed as soon as possible. The timeout |
| 216 |
must be at least 1s. |
| 217 |
Defaults to 0, which means <command>systemd-oomd</command> will not wait and no notifications |
| 218 |
will be sent.</para> |
| 219 |
|
| 220 |
<xi:include href="version-info.xml" xpointer="v260"/></listitem> |
| 221 |
</varlistentry> |
| 222 |
|
| 223 |
</variablelist> |
| 224 |
</refsect1> |
| 225 |
|
| 226 |
<refsect1> |
| 227 |
<title>See Also</title> |
| 228 |
<para><simplelist type="inline"> |
| 229 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 230 |
<member><citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 231 |
<member><citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 232 |
<member><citerefentry><refentrytitle>oomctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 233 |
</simplelist></para> |
| 234 |
</refsect1> |
| 235 |
|
| 236 |
</refentry> |