From 7665e1796f915dedbf8e014f0a78f4f576d609bb Mon Sep 17 00:00:00 2001 From: Anita Zhang Date: Tue, 23 Aug 2022 11:59:16 -0700 Subject: [PATCH] Update systemd-oomd defaults to friendlier values - Remove swap policy. Default amount of swap (8GB?) is a lot lower than what we use internally with the swap policy. Which frequently leads to GNOME getting killed (e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1941170, and other BZs not linked here). Internally we use 0.5x-1x size of physical memory for swap via swapfiles (this will be documented in systemd upstream). In simple cases of using more memory than is available (but without memory pressure), the Kernel OOM killer can handle killing the offending process. - Expand the memory pressure policy to system.slice, user-.slice, and all user owned slices. Support for ManagedOOM*= on user services was added in https://github.com/systemd/systemd/pull/20690 which allows us to be more fine grained on the pressure monitoring at the user level. In addition to the system.slice and user-.slice PSI monitoring this should result in a better systemd-oomd experience for desktop systems. --- ...rvice-defaults.conf => 10-oomd-per-slice-defaults.conf | 2 +- 10-oomd-root-slice-defaults.conf | 2 -- systemd.spec | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) rename 10-oomd-user-service-defaults.conf => 10-oomd-per-slice-defaults.conf (86%) delete mode 100644 10-oomd-root-slice-defaults.conf diff --git a/10-oomd-user-service-defaults.conf b/10-oomd-per-slice-defaults.conf similarity index 86% rename from 10-oomd-user-service-defaults.conf rename to 10-oomd-per-slice-defaults.conf index 94d5c87..fbf6f00 100644 --- a/10-oomd-user-service-defaults.conf +++ b/10-oomd-per-slice-defaults.conf @@ -1,3 +1,3 @@ -[Service] +[Slice] ManagedOOMMemoryPressure=kill ManagedOOMMemoryPressureLimit=50% diff --git a/10-oomd-root-slice-defaults.conf b/10-oomd-root-slice-defaults.conf deleted file mode 100644 index 49958e8..0000000 --- a/10-oomd-root-slice-defaults.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Slice] -ManagedOOMSwap=kill diff --git a/systemd.spec b/systemd.spec index 46a8403..2a798a3 100644 --- a/systemd.spec +++ b/systemd.spec @@ -70,8 +70,7 @@ Source12: systemd-user Source13: libsystemd-shared.abignore Source14: 10-oomd-defaults.conf -Source15: 10-oomd-root-slice-defaults.conf -Source16: 10-oomd-user-service-defaults.conf +Source15: 10-oomd-per-slice-defaults.conf Source21: macros.sysusers Source22: sysusers.attr @@ -664,8 +663,9 @@ install -D -t %{buildroot}/usr/lib/systemd/ %{SOURCE3} # systemd-oomd default configuration install -Dm0644 -t %{buildroot}%{_prefix}/lib/systemd/oomd.conf.d/ %{SOURCE14} -install -Dm0644 -t %{buildroot}%{system_unit_dir}/-.slice.d/ %{SOURCE15} -install -Dm0644 -t %{buildroot}%{system_unit_dir}/user@.service.d/ %{SOURCE16} +install -Dm0644 -t %{buildroot}%{system_unit_dir}/user-.slice.d/ %{SOURCE15} +install -Dm0644 -t %{buildroot}%{system_unit_dir}/system.slice.d/ %{SOURCE15} +install -Dm0644 -t %{buildroot}%{user_unit_dir}/slice.d/ %{SOURCE15} sed -i 's|#!/usr/bin/env python3|#!%{__python3}|' %{buildroot}/usr/lib/systemd/tests/run-unit-tests.py