1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-24 02:03:54 +03:00

Merge pull request #25725 from keszybz/oom-policy-fixup

Add missing integration of OOMPolicy in scope units
This commit is contained in:
Luca Boccassi 2022-12-14 01:38:11 +01:00 committed by GitHub
commit 71f7cc6a9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 19 deletions

View File

@ -105,6 +105,8 @@
of scope units are the following:</para>
<variablelist class='unit-directives'>
<xi:include href="systemd.service.xml" xpointer="oom-policy" />
<varlistentry>
<term><varname>RuntimeMaxSec=</varname></term>

View File

@ -1120,30 +1120,30 @@
above.</para></listitem>
</varlistentry>
<varlistentry>
<varlistentry id='oom-policy'>
<term><varname>OOMPolicy=</varname></term>
<listitem><para>Configure the out-of-memory (OOM) kernel killer policy. Note that the userspace OOM
<listitem><para>Configure the out-of-memory (OOM) killing policy for the kernel and the userspace OOM
killer
<citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
is a more flexible solution that aims to prevent out-of-memory situations for the userspace, not just
the kernel.</para>
<citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
On Linux, when memory becomes scarce to the point that the kernel has trouble allocating memory for
itself, it might decide to kill a running process in order to free up memory and reduce memory
pressure. Note that <filename>systemd-oomd.service</filename> is a more flexible solution that aims
to prevent out-of-memory situations for the userspace too, not just the kernel, by attempting to
terminate services earlier, before the kernel would have to act.</para>
<para>On Linux, when memory becomes scarce to the point that the kernel has trouble allocating memory
for itself, it might decide to kill a running process in order to free up memory and reduce memory
pressure. This setting takes one of <constant>continue</constant>, <constant>stop</constant> or
<constant>kill</constant>. If set to <constant>continue</constant> and a process of the service is
killed by the kernel's OOM killer this is logged but the service continues running. If set to
<constant>stop</constant> the event is logged but the service is terminated cleanly by the service
manager. If set to <constant>kill</constant> and one of the service's processes is killed by the OOM
killer the kernel is instructed to kill all remaining processes of the service too, by setting the
<para>This setting takes one of <constant>continue</constant>, <constant>stop</constant> or
<constant>kill</constant>. If set to <constant>continue</constant> and a process in the unit is
killed by the OOM killer, this is logged but the unit continues running. If set to
<constant>stop</constant> the event is logged but the unit is terminated cleanly by the service
manager. If set to <constant>kill</constant> and one of the unit's processes is killed by the OOM
killer the kernel is instructed to kill all remaining processes of the unit too, by setting the
<filename>memory.oom.group</filename> attribute to <constant>1</constant>; also see <ulink
url="https://docs.kernel.org/admin-guide/cgroup-v2.html">kernel documentation</ulink>.
</para>
url="https://docs.kernel.org/admin-guide/cgroup-v2.html">kernel documentation</ulink>.</para>
<para>Defaults to the setting <varname>DefaultOOMPolicy=</varname> in
<citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
is set to, except for services where <varname>Delegate=</varname> is turned on, where it defaults to
is set to, except for units where <varname>Delegate=</varname> is turned on, where it defaults to
<constant>continue</constant>.</para>
<para>Use the <varname>OOMScoreAdjust=</varname> setting to configure whether processes of the unit
@ -1153,10 +1153,9 @@
details.</para>
<para>This setting also applies to <command>systemd-oomd</command>. Similarly to the kernel OOM
kills, this setting determines the state of the service after <command>systemd-oomd</command> kills a
cgroup associated with the service.</para></listitem>
kills, this setting determines the state of the unit after <command>systemd-oomd</command> kills a
cgroup associated with it.</para></listitem>
</varlistentry>
</variablelist>
<para id='shared-unit-options'>Check

View File

@ -556,6 +556,7 @@ Path.TriggerLimitBurst, config_parse_unsigned,
Scope.RuntimeMaxSec, config_parse_sec, 0, offsetof(Scope, runtime_max_usec)
Scope.RuntimeRandomizedExtraSec, config_parse_sec, 0, offsetof(Scope, runtime_rand_extra_usec)
Scope.TimeoutStopSec, config_parse_sec, 0, offsetof(Scope, timeout_stop_usec)
Scope.OOMPolicy, config_parse_oom_policy, 0, offsetof(Scope, oom_policy)
{# The [Install] section is ignored here #}
Install.Alias, NULL, 0, 0
Install.WantedBy, NULL, 0, 0