Add to oomd the capability to define rulesets in /etc/systemd/oomd/rules.d/ and then reference them with a new config option OOMRule=
237 lines
12 KiB
XML
237 lines
12 KiB
XML
<?xml version='1.0'?> <!--*-nxml-*-->
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
|
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
|
|
|
<refentry id="oomd.conf" conditional='ENABLE_OOMD'
|
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
<refentryinfo>
|
|
<title>oomd.conf</title>
|
|
<productname>systemd</productname>
|
|
</refentryinfo>
|
|
|
|
<refmeta>
|
|
<refentrytitle>oomd.conf</refentrytitle>
|
|
<manvolnum>5</manvolnum>
|
|
</refmeta>
|
|
|
|
<refnamediv>
|
|
<refname>oomd.conf</refname>
|
|
<refname>oomd.conf.d</refname>
|
|
<refpurpose>Global <command>systemd-oomd</command> configuration files</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<para><simplelist>
|
|
<member><filename>/etc/systemd/oomd.conf</filename></member>
|
|
<member><filename>/run/systemd/oomd.conf</filename></member>
|
|
<member><filename>/usr/local/lib/systemd/oomd.conf</filename></member>
|
|
<member><filename>/usr/lib/systemd/oomd.conf</filename></member>
|
|
<member><filename>/etc/systemd/oomd.conf.d/*.conf</filename></member>
|
|
<member><filename>/run/systemd/oomd.conf.d/*.conf</filename></member>
|
|
<member><filename>/usr/local/lib/systemd/oomd.conf.d/*.conf</filename></member>
|
|
<member><filename>/usr/lib/systemd/oomd.conf.d/*.conf</filename></member>
|
|
</simplelist></para>
|
|
</refsynopsisdiv>
|
|
|
|
<refsect1>
|
|
<title>Description</title>
|
|
|
|
<para>These files configure the various parameters of the
|
|
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> userspace
|
|
out-of-memory (OOM) killer,
|
|
<citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
|
|
See <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry>
|
|
for a general description of the syntax.</para>
|
|
|
|
</refsect1>
|
|
|
|
<xi:include href="standard-conf.xml" xpointer="main-conf" />
|
|
|
|
<refsect1>
|
|
<title>Prekill event</title>
|
|
|
|
<para><command>systemd-oomd</command> supports notifying external components before killing a control
|
|
group.
|
|
This is done by sending a notification over varlink to all sockets found in
|
|
<filename>/run/systemd/oomd.prekill.hook/</filename> folder. Each socket should implement the
|
|
<constant>io.systemd.oom.Prekill</constant> interface. The notification contains the control group path
|
|
to allow the hook to identify which control group is being killed. This allows external components to
|
|
perform any necessary cleanup or logging before the control group is terminated. The hook is not intended
|
|
as a way to avoid the kill, but rather as a notification mechanism.
|
|
Note that this is a privileged option as, even if it has a timeout, is synchronous and delays the kill,
|
|
so use with care.
|
|
The typically preferable mechanism to process memory pressure is to do what
|
|
<ulink url="https://systemd.io/PRESSURE">Resource Pressure Handling</ulink> describes which is unprivileged,
|
|
asynchronous and does not delay the kill.
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1>
|
|
<title>OOM Rulesets</title>
|
|
|
|
<para><command>systemd-oomd</command> supports custom rulesets that define conditions and actions for
|
|
OOM handling on a per-unit basis. Ruleset files use the <filename>.oomrule</filename> extension and are
|
|
loaded from <filename>/etc/systemd/oomd/rules.d/</filename>,
|
|
<filename>/run/systemd/oomd/rules.d/</filename>,
|
|
<filename>/usr/local/lib/systemd/oomd/rules.d/</filename>, and
|
|
<filename>/usr/lib/systemd/oomd/rules.d/</filename>.
|
|
Units opt into rulesets via the <varname>OOMRules=</varname> setting in
|
|
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
|
which takes a space-separated list of ruleset names (the file name without the <filename>.oomrule</filename>
|
|
extension).</para>
|
|
|
|
<para>Each ruleset file contains a <literal>[Rule]</literal> section with the following options. At least
|
|
one of <varname>MemoryPressureAbove=</varname> or <varname>SwapUsageMax=</varname> must be configured;
|
|
rulesets with no conditions are ignored. If both are set, the conditions are combined with AND, i.e. the
|
|
action is only triggered when both thresholds are exceeded simultaneously.</para>
|
|
|
|
<variablelist class='config-directives'>
|
|
<varlistentry>
|
|
<term><varname>MemoryPressureAbove=</varname></term>
|
|
|
|
<listitem><para>Sets the memory pressure threshold above which the rule's action will be triggered.
|
|
The memory pressure represents the fraction of time in a 10 second window in which all tasks in the
|
|
control group were delayed (PSI <literal>full avg10</literal>). Takes a value specified in percent
|
|
(when suffixed with <literal>%</literal>), permille (<literal>‰</literal>) or permyriad
|
|
(<literal>‱</literal>), between 0% and 100%, inclusive. If unset, this condition is not
|
|
evaluated. A value of <literal>100%</literal> can never be exceeded and is
|
|
therefore rejected with a warning; a value of <literal>0%</literal> makes the condition true on any
|
|
observed pressure, which is usually not useful.</para>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v261"/></listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><varname>SwapUsageMax=</varname></term>
|
|
|
|
<listitem><para>Sets the system-wide swap usage threshold above which the rule's action will be
|
|
triggered. Takes a value specified in percent (when suffixed with <literal>%</literal>),
|
|
permille (<literal>‰</literal>) or permyriad (<literal>‱</literal>),
|
|
between 0% and 100%, inclusive. If unset, this condition is not evaluated. A value of
|
|
<literal>100%</literal> can never be exceeded and is therefore rejected with
|
|
a warning; a value of <literal>0%</literal> fires as soon as any swap is in use, which is usually
|
|
not useful.</para>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v261"/></listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><varname>Action=</varname></term>
|
|
|
|
<listitem><para>Specifies the action to take when the rule's conditions are met. Takes one of
|
|
<literal>kill-all</literal>, <literal>kill-by-pgscan</literal>, or
|
|
<literal>kill-by-swap</literal>. This setting is mandatory; rulesets without
|
|
<varname>Action=</varname> are ignored.</para>
|
|
|
|
<itemizedlist>
|
|
<listitem><para><literal>kill-all</literal> sends <constant>SIGKILL</constant> to every process
|
|
in the unit's cgroup hierarchy, including any descendant cgroups.</para></listitem>
|
|
|
|
<listitem><para><literal>kill-by-pgscan</literal> selects and kills the descendant cgroup with
|
|
the highest recent page scan (reclaim) rate.</para></listitem>
|
|
|
|
<listitem><para><literal>kill-by-swap</literal> selects and kills the descendant cgroup with the
|
|
highest swap usage.</para></listitem>
|
|
</itemizedlist>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v261"/></listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><varname>LastingSec=</varname></term>
|
|
|
|
<listitem><para>Sets the duration the conditions must be continuously met before the action is taken.
|
|
Takes a time span value, see
|
|
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>
|
|
for details on the permitted syntax. Defaults to 0, i.e. the action is taken
|
|
immediately when the conditions are met.</para>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v261"/></listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1>
|
|
<title>[OOM] Section Options</title>
|
|
|
|
<para>The following options are available in the [OOM] section:</para>
|
|
|
|
<variablelist class='config-directives'>
|
|
<varlistentry>
|
|
<term><varname>SwapUsedLimit=</varname></term>
|
|
|
|
<listitem><para>Sets the limit for memory and swap usage on the system before <command>systemd-oomd</command>
|
|
will take action. If the fraction of memory used and the fraction of swap used on the system are both more than
|
|
what is defined here, <command>systemd-oomd</command> will act on eligible descendant control groups with swap
|
|
usage greater than 5% of total swap, starting from the ones with the highest swap usage. Which
|
|
control groups are monitored and what action gets taken depends on what the unit has configured for
|
|
<varname>ManagedOOMSwap=</varname>. Takes a value specified in percent (when suffixed with "%"),
|
|
permille ("‰") or permyriad ("‱"), between 0% and 100%, inclusive. Defaults to 90%.</para>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v247"/></listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><varname>DefaultMemoryPressureLimit=</varname></term>
|
|
|
|
<listitem><para>Sets the limit for memory pressure on the unit's control group before
|
|
<command>systemd-oomd</command> will take action. A unit can override this value with
|
|
<varname>ManagedOOMMemoryPressureLimit=</varname>. The memory pressure for this property represents
|
|
the fraction of time in a 10 second window in which all tasks in the control group were delayed. For
|
|
each monitored control group, if the memory pressure on that control group exceeds the limit set for
|
|
longer than the duration set by <varname>DefaultMemoryPressureDurationSec=</varname>,
|
|
<command>systemd-oomd</command> will act on eligible descendant control groups, starting from the
|
|
ones with the most reclaim activity to the least reclaim activity. Which control groups are monitored
|
|
and what action gets taken depends on what the unit has configured for
|
|
<varname>ManagedOOMMemoryPressure=</varname>. Takes a fraction specified in the same way as
|
|
<varname>SwapUsedLimit=</varname> above. Defaults to 60%.</para>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v247"/></listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><varname>DefaultMemoryPressureDurationSec=</varname></term>
|
|
|
|
<listitem><para>Sets the amount of time a unit's control group needs to have exceeded memory pressure
|
|
limits before <command>systemd-oomd</command> will take action. A unit can override this value with
|
|
<varname>ManagedOOMMemoryPressureDurationSec=</varname>. Memory pressure limits are defined by
|
|
<varname>DefaultMemoryPressureLimit=</varname> and <varname>ManagedOOMMemoryPressureLimit=</varname>.
|
|
Must be set to 0, or at least 1 second. Defaults to 30 seconds when unset or 0.</para>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v248"/></listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><varname>PrekillHookTimeoutSec=</varname></term>
|
|
|
|
<listitem><para>Sets the amount of time <command>systemd-oomd</command> will wait for pre-kill hooks
|
|
to complete, before proceeding with the control group termination. Pre-kill hooks work by placing
|
|
varlink socket to <filename>/run/systemd/oomd.prekill.hook/</filename> folder. Each socket should
|
|
implement interface for notification to work. <command>systemd-oomd</command> sends a notification
|
|
before killing a control group for each discovered socket. The timeout is intended to be global and
|
|
not per hook. If all hooks return earlier, the kill is performed as soon as possible. The timeout
|
|
must be at least 1s.
|
|
Defaults to 0, which means <command>systemd-oomd</command> will not wait and no notifications
|
|
will be sent.</para>
|
|
|
|
<xi:include href="version-info.xml" xpointer="v260"/></listitem>
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1>
|
|
<title>See Also</title>
|
|
<para><simplelist type="inline">
|
|
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
|
<member><citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
|
|
<member><citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
|
|
<member><citerefentry><refentrytitle>oomctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
|
</simplelist></para>
|
|
</refsect1>
|
|
|
|
</refentry>
|