From 100d37d4f3111a97f51e37b51eea9243cb037b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 13 Dec 2022 15:25:55 +0100 Subject: [PATCH 1/2] man: rework description of OOMPolicy= a bit One had to read to the very end of the long description to notice that the setting is actually primarily intended for oomd. So let's mention oomd right at the beginning. --- man/systemd.service.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/man/systemd.service.xml b/man/systemd.service.xml index 8d8dd77689..cae520ceab 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -1123,17 +1123,18 @@ OOMPolicy= - Configure the out-of-memory (OOM) kernel killer policy. Note that the userspace OOM + Configure the out-of-memory (OOM) killing policy for the kernel and the userspace OOM killer - systemd-oomd.service8 - is a more flexible solution that aims to prevent out-of-memory situations for the userspace, not just - the kernel. + systemd-oomd.service8. + 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 systemd-oomd.service 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. - 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 continue, stop or + This setting takes one of continue, stop or kill. If set to continue 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 + killed by the OOM killer, this is logged but the service continues running. If set to stop the event is logged but the service is terminated cleanly by the service manager. If set to kill 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 From d5a1657d5a78e9a101fa91e60921bed54ec162b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 13 Dec 2022 15:26:58 +0100 Subject: [PATCH 2/2] core,man: add missing integration of OOMPolicy= in scopes Fixup for 5fa098357e0ea9f05b00ed5b04a36ef9f64037db. --- man/systemd.scope.xml | 2 ++ man/systemd.service.xml | 22 ++++++++++------------ src/core/load-fragment-gperf.gperf.in | 1 + 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/man/systemd.scope.xml b/man/systemd.scope.xml index 17d2700069..95969bf097 100644 --- a/man/systemd.scope.xml +++ b/man/systemd.scope.xml @@ -105,6 +105,8 @@ of scope units are the following: + + RuntimeMaxSec= diff --git a/man/systemd.service.xml b/man/systemd.service.xml index cae520ceab..1c9e59f722 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -1120,7 +1120,7 @@ above. - + OOMPolicy= Configure the out-of-memory (OOM) killing policy for the kernel and the userspace OOM @@ -1133,18 +1133,17 @@ terminate services earlier, before the kernel would have to act. This setting takes one of continue, stop or - kill. If set to continue and a process of the service is - killed by the OOM killer, this is logged but the service continues running. If set to - stop the event is logged but the service is terminated cleanly by the service - manager. If set to kill 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 + kill. If set to continue and a process in the unit is + killed by the OOM killer, this is logged but the unit continues running. If set to + stop the event is logged but the unit is terminated cleanly by the service + manager. If set to kill 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 memory.oom.group attribute to 1; also see kernel documentation. - + url="https://docs.kernel.org/admin-guide/cgroup-v2.html">kernel documentation. Defaults to the setting DefaultOOMPolicy= in systemd-system.conf5 - is set to, except for services where Delegate= is turned on, where it defaults to + is set to, except for units where Delegate= is turned on, where it defaults to continue. Use the OOMScoreAdjust= setting to configure whether processes of the unit @@ -1154,10 +1153,9 @@ details. This setting also applies to systemd-oomd. Similarly to the kernel OOM - kills, this setting determines the state of the service after systemd-oomd kills a - cgroup associated with the service. + kills, this setting determines the state of the unit after systemd-oomd kills a + cgroup associated with it. - Check diff --git a/src/core/load-fragment-gperf.gperf.in b/src/core/load-fragment-gperf.gperf.in index bba6666a52..b315dd0afa 100644 --- a/src/core/load-fragment-gperf.gperf.in +++ b/src/core/load-fragment-gperf.gperf.in @@ -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