2aacef
From 6013f45b86f39a502d9e92b96adee402a32de062 Mon Sep 17 00:00:00 2001
2aacef
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
2aacef
Date: Tue, 13 Dec 2022 15:26:58 +0100
2aacef
Subject: [PATCH] core,man: add missing integration of OOMPolicy= in scopes
2aacef
2aacef
Fixup for 5fa098357e0ea9f05b00ed5b04a36ef9f64037db.
2aacef
2aacef
(cherry picked from commit d5a1657d5a78e9a101fa91e60921bed54ec162b8)
2aacef
2aacef
Resolves: #2175619
2aacef
---
2aacef
 man/systemd.scope.xml                 |  2 ++
2aacef
 man/systemd.service.xml               | 22 ++++++++++------------
2aacef
 src/core/load-fragment-gperf.gperf.in |  1 +
2aacef
 3 files changed, 13 insertions(+), 12 deletions(-)
2aacef
2aacef
diff --git a/man/systemd.scope.xml b/man/systemd.scope.xml
2aacef
index 17d2700069..95969bf097 100644
2aacef
--- a/man/systemd.scope.xml
2aacef
+++ b/man/systemd.scope.xml
2aacef
@@ -105,6 +105,8 @@
2aacef
     of scope units are the following:</para>
2aacef
 
2aacef
     <variablelist class='unit-directives'>
2aacef
+      <xi:include href="systemd.service.xml" xpointer="oom-policy" />
2aacef
+
2aacef
       <varlistentry>
2aacef
         <term><varname>RuntimeMaxSec=</varname></term>
2aacef
 
2aacef
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
2aacef
index cae520ceab..1c9e59f722 100644
2aacef
--- a/man/systemd.service.xml
2aacef
+++ b/man/systemd.service.xml
2aacef
@@ -1120,7 +1120,7 @@
2aacef
         above.</para></listitem>
2aacef
       </varlistentry>
2aacef
 
2aacef
-      <varlistentry>
2aacef
+      <varlistentry id='oom-policy'>
2aacef
         <term><varname>OOMPolicy=</varname></term>
2aacef
 
2aacef
         <listitem><para>Configure the out-of-memory (OOM) killing policy for the kernel and the userspace OOM
2aacef
@@ -1133,18 +1133,17 @@
2aacef
         terminate services earlier, before the kernel would have to act.</para>
2aacef
 
2aacef
         <para>This setting takes one of <constant>continue</constant>, <constant>stop</constant> or
2aacef
-        <constant>kill</constant>. If set to <constant>continue</constant> and a process of the service is
2aacef
-        killed by the OOM killer, this is logged but the service continues running. If set to
2aacef
-        <constant>stop</constant> the event is logged but the service is terminated cleanly by the service
2aacef
-        manager. If set to <constant>kill</constant> and one of the service's processes is killed by the OOM
2aacef
-        killer the kernel is instructed to kill all remaining processes of the service too, by setting the
2aacef
+        <constant>kill</constant>. If set to <constant>continue</constant> and a process in the unit is
2aacef
+        killed by the OOM killer, this is logged but the unit continues running. If set to
2aacef
+        <constant>stop</constant> the event is logged but the unit is terminated cleanly by the service
2aacef
+        manager. If set to <constant>kill</constant> and one of the unit's processes is killed by the OOM
2aacef
+        killer the kernel is instructed to kill all remaining processes of the unit too, by setting the
2aacef
         <filename>memory.oom.group</filename> attribute to <constant>1</constant>; also see 
2aacef
-        url="https://docs.kernel.org/admin-guide/cgroup-v2.html">kernel documentation</ulink>.
2aacef
-        </para>
2aacef
+        url="https://docs.kernel.org/admin-guide/cgroup-v2.html">kernel documentation</ulink>.</para>
2aacef
 
2aacef
         <para>Defaults to the setting <varname>DefaultOOMPolicy=</varname> in
2aacef
         <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2aacef
-        is set to, except for services where <varname>Delegate=</varname> is turned on, where it defaults to
2aacef
+        is set to, except for units where <varname>Delegate=</varname> is turned on, where it defaults to
2aacef
         <constant>continue</constant>.</para>
2aacef
 
2aacef
         <para>Use the <varname>OOMScoreAdjust=</varname> setting to configure whether processes of the unit
2aacef
@@ -1154,10 +1153,9 @@
2aacef
         details.</para>
2aacef
 
2aacef
         <para>This setting also applies to <command>systemd-oomd</command>. Similarly to the kernel OOM
2aacef
-        kills, this setting determines the state of the service after <command>systemd-oomd</command> kills a
2aacef
-        cgroup associated with the service.</para></listitem>
2aacef
+        kills, this setting determines the state of the unit after <command>systemd-oomd</command> kills a
2aacef
+        cgroup associated with it.</para></listitem>
2aacef
       </varlistentry>
2aacef
-
2aacef
     </variablelist>
2aacef
 
2aacef
     <para id='shared-unit-options'>Check
2aacef
diff --git a/src/core/load-fragment-gperf.gperf.in b/src/core/load-fragment-gperf.gperf.in
2aacef
index 7675b7bb2e..81a5971339 100644
2aacef
--- a/src/core/load-fragment-gperf.gperf.in
2aacef
+++ b/src/core/load-fragment-gperf.gperf.in
2aacef
@@ -555,6 +555,7 @@ Path.TriggerLimitBurst,                  config_parse_unsigned,
2aacef
 Scope.RuntimeMaxSec,                     config_parse_sec,                            0,                                  offsetof(Scope, runtime_max_usec)
2aacef
 Scope.RuntimeRandomizedExtraSec,         config_parse_sec,                            0,                                  offsetof(Scope, runtime_rand_extra_usec)
2aacef
 Scope.TimeoutStopSec,                    config_parse_sec,                            0,                                  offsetof(Scope, timeout_stop_usec)
2aacef
+Scope.OOMPolicy,                         config_parse_oom_policy,                     0,                                  offsetof(Scope, oom_policy)
2aacef
 {# The [Install] section is ignored here #}
2aacef
 Install.Alias,                           NULL,                                        0,                                  0
2aacef
 Install.WantedBy,                        NULL,                                        0,                                  0