]>
Commit | Line | Data |
---|---|---|
cf3e5788 AZ |
1 | <?xml version='1.0'?> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> | |
5 | ||
6 | <refentry id="systemd-oomd.service" conditional='ENABLE_OOMD'> | |
7 | ||
8 | <refentryinfo> | |
9 | <title>systemd-oomd.service</title> | |
10 | <productname>systemd</productname> | |
11 | </refentryinfo> | |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>systemd-oomd.service</refentrytitle> | |
15 | <manvolnum>8</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>systemd-oomd.service</refname> | |
20 | <refname>systemd-oomd</refname> | |
21 | <refpurpose>A userspace out-of-memory (OOM) killer</refpurpose> | |
22 | </refnamediv> | |
23 | ||
24 | <refsynopsisdiv> | |
25 | <para><filename>systemd-oomd.service</filename></para> | |
26 | <para><filename>/usr/lib/systemd/systemd-oomd</filename></para> | |
27 | </refsynopsisdiv> | |
28 | ||
29 | <refsect1> | |
30 | <title>Description</title> | |
31 | ||
32 | <para><command>systemd-oomd</command> is a system service that uses cgroups-v2 and pressure stall information (PSI) | |
33 | to monitor and take action on processes before an OOM occurs in kernel space.</para> | |
34 | ||
35 | <para>You can enable monitoring and actions on units by setting <varname>ManagedOOMSwap=</varname> and/or | |
36 | <varname>ManagedOOMMemoryPressure=</varname> to the appropriate value. <command>systemd-oomd</command> will | |
37 | periodically poll enabled units' cgroup data to detect when corrective action needs to occur. When an action needs | |
38 | to happen, it will only be performed on the descendant cgroups of the enabled units. More precisely, only cgroups with | |
39 | <filename>memory.oom.group</filename> set to <constant>1</constant> and leaf cgroup nodes are eligible candidates. | |
40 | Action will be taken recursively on all of the processes under the chosen candidate.</para> | |
41 | ||
42 | <para>See | |
43 | <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
44 | for more information about the configuration of this service.</para> | |
45 | </refsect1> | |
46 | ||
47 | <refsect1> | |
48 | <title>Setup Information</title> | |
49 | ||
50 | <para>The system must be running systemd with a full unified cgroup hierarchy for the expected cgroups-v2 features. | |
51 | Furthermore, resource accounting must be turned on for all units monitored by <command>systemd-oomd</command>. | |
52 | The easiest way to turn on resource accounting is by ensuring the values for <varname>DefaultCPUAccounting</varname>, | |
53 | <varname>DefaultIOAccounting</varname>, <varname>DefaultMemoryAccounting</varname>, and | |
54 | <varname>DefaultTasksAccounting</varname> are set to <constant>true</constant> in | |
55 | <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> | |
56 | ||
57 | <para>You will need a kernel compiled with PSI support. This is available in Linux 4.20 and above.</para> | |
58 | ||
59 | <para>The system must also have swap enabled for <command>systemd-oomd</command> to function correctly. With swap | |
60 | enabled, the system spends enough time swapping pages to let <command>systemd-oomd</command> react. | |
61 | Without swap, the system enters a livelocked state much more quickly and may prevent <command>systemd-oomd</command> | |
62 | from responding in a reasonable amount of time. See | |
63 | <ulink url="https://chrisdown.name/2018/01/02/in-defence-of-swap.html">"In defence of swap: common misconceptions"</ulink> | |
64 | for more details on swap.</para> | |
65 | ||
66 | <para>Be aware that if you intend to enable monitoring and actions on <filename>user.slice</filename>, | |
67 | <filename>user-$UID.slice</filename>, or their ancestor cgroups, it is highly recommended that your programs be | |
68 | managed by the systemd user manager to prevent running too many processes under the same session scope (and thus | |
69 | avoid a situation where memory intensive tasks trigger <command>systemd-oomd</command> to kill everything under the | |
70 | cgroup). If you're using a desktop environment like GNOME, it already spawns many session components with the | |
71 | systemd user manager.</para> | |
72 | </refsect1> | |
73 | ||
74 | <refsect1> | |
75 | <title>Usage Recommendations</title> | |
76 | ||
77 | <para><varname>ManagedOOMSwap=</varname> works with the system-wide swap values, so setting it on the root slice | |
78 | <filename>-.slice</filename>, and allowing all descendant cgroups to be eligible candidates may make the most | |
79 | sense.</para> | |
80 | ||
81 | <para><varname>ManagedOOMMemoryPressure=</varname> tends to work better on the cgroups below the root slice | |
82 | <filename>-.slice</filename>. For units which tend to have processes that are less latency sensitive (e.g. | |
83 | <filename>system.slice</filename>), a higher limit like the default of 60% may be acceptable, as those processes | |
84 | can usually ride out slowdowns caused by lack of memory without serious consequences. However, something like | |
85 | <filename>user@$UID.service</filename> may prefer a much lower value like 40%.</para> | |
86 | </refsect1> | |
87 | ||
88 | <refsect1> | |
89 | <title>See Also</title> | |
90 | <para> | |
91 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
92 | <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
93 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
94 | <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
95 | <citerefentry><refentrytitle>oomctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
96 | </para> | |
97 | </refsect1> | |
98 | </refentry> |