1SYSTEMD-OOMD.SERVICE(8) systemd-oomd.service SYSTEMD-OOMD.SERVICE(8)
2
3
4
6 systemd-oomd.service, systemd-oomd - A userspace out-of-memory (OOM)
7 killer
8
10 systemd-oomd.service
11
12 /usr/lib/systemd/systemd-oomd
13
15 systemd-oomd is a system service that uses cgroups-v2 and pressure
16 stall information (PSI) to monitor and take corrective action before an
17 OOM occurs in the kernel space.
18
19 You can enable monitoring and actions on units by setting
20 ManagedOOMSwap= and ManagedOOMMemoryPressure= in the unit
21 configuration, see systemd.resource-control(5). systemd-oomd retrieves
22 information about such units from systemd when it starts and watches
23 for subsequent changes.
24
25 Cgroups of units with ManagedOOMSwap= or ManagedOOMMemoryPressure= set
26 to kill will be monitored. systemd-oomd periodically polls PSI
27 statistics for the system and those cgroups to decide when to take
28 action. If the configured limits are exceeded, systemd-oomd will select
29 a cgroup to terminate, and send SIGKILL to all processes in it. Note
30 that only descendant cgroups are eligible candidates for killing; the
31 unit with its property set to kill is not a candidate (unless one of
32 its ancestors set their property to kill). Also only leaf cgroups and
33 cgroups with memory.oom.group set to 1 are eligible candidates; see
34 OOMPolicy= in systemd.service(5).
35
36 oomctl(1) can be used to list monitored cgroups and pressure
37 information.
38
39 See oomd.conf(5) for more information about the configuration of this
40 service.
41
43 The system must be running systemd with a full unified cgroup hierarchy
44 for the expected cgroups-v2 features. Furthermore, memory accounting
45 must be turned on for all units monitored by systemd-oomd. The easiest
46 way to turn on memory accounting is by ensuring the value for
47 DefaultMemoryAccounting= is set to true in systemd-system.conf(5).
48
49 The kernel must be compiled with PSI support. This is available in
50 Linux 4.20 and above.
51
52 It is highly recommended for the system to have swap enabled for
53 systemd-oomd to function optimally. With swap enabled, the system
54 spends enough time swapping pages to let systemd-oomd react. Without
55 swap, the system enters a livelocked state much more quickly and may
56 prevent systemd-oomd from responding in a reasonable amount of time.
57 See "In defence of swap: common misconceptions"[1] for more details on
58 swap. Any swap-based actions on systems without swap will be ignored.
59 While systemd-oomd can perform pressure-based actions on such a system,
60 the pressure increases will be more abrupt and may require more tuning
61 to get the desired thresholds and behavior.
62
63 Be aware that if you intend to enable monitoring and actions on
64 user.slice, user-$UID.slice, or their ancestor cgroups, it is highly
65 recommended that your programs be managed by the systemd user manager
66 to prevent running too many processes under the same session scope (and
67 thus avoid a situation where memory intensive tasks trigger
68 systemd-oomd to kill everything under the cgroup). If you're using a
69 desktop environment like GNOME or KDE, it already spawns many session
70 components with the systemd user manager.
71
73 ManagedOOMSwap= works with the system-wide swap values, so setting it
74 on the root slice -.slice, and allowing all descendant cgroups to be
75 eligible candidates may make the most sense.
76
77 ManagedOOMMemoryPressure= tends to work better on the cgroups below the
78 root slice. For units which tend to have processes that are less
79 latency sensitive (e.g. system.slice), a higher limit like the default
80 of 60% may be acceptable, as those processes can usually ride out
81 slowdowns caused by lack of memory without serious consequences.
82 However, something like user@$UID.service may prefer a much lower value
83 like 40%.
84
86 systemd(1), systemd-system.conf(5), systemd.resource-control(5),
87 oomd.conf(5), oomctl(1)
88
90 1. "In defence of swap: common misconceptions"
91 https://chrisdown.name/2018/01/02/in-defence-of-swap.html
92
93
94
95systemd 251 SYSTEMD-OOMD.SERVICE(8)