1nohang(8) Linux System Administrator's Manual nohang(8)
2
3
4
6 nohang - A sophisticated low memory handler
7
9 nohang [OPTION]...
10
12 nohang is a highly configurable daemon for Linux which is able to cor‐
13 rectly prevent out of memory (OOM) and keep system responsiveness in
14 low memory conditions.
15
17 For basic usage:
18 · Linux (>= 3.14, since MemAvailable appeared in /proc/meminfo)
19
20 · Python (>= 3.3)
21
22 To respond to PSI metrics (optional):
23 · Linux (>= 4.20) with CONFIG_PSI=y
24
25 To show GUI notifications (optional):
26 · notification server (most of desktop environments use their own im‐
27 plementations)
28
29 · libnotify (Arch Linux, Fedora, openSUSE) or libnotify-bin (Debian
30 GNU/Linux, Ubuntu)
31
32 · sudo if nohang started with UID=0.
33
35 -h, --help
36 show this help message and exit
37
38 -v, --version
39 show version of installed package and exit
40
41 -m, --memload
42 consume memory until 40 MiB (MemAvailable + SwapFree) remain free, and
43 terminate the process
44
45 -c CONFIG, --config CONFIG
46 path to the config file. This should only be used with one of the fol‐
47 lowing options: --monitor, --tasks, --check
48
49 --check
50 check and show the configuration and exit. This should only be used
51 with -c/--config CONFIG option
52
53 --monitor
54 start monitoring. This should only be used with -c/--config CONFIG op‐
55 tion
56
57 --tasks
58 show tasks state and exit. This should only be used with -c/--config
59 CONFIG option
60
62 /etc/nohang/nohang.conf
63 path to vanilla nohang configuration file
64
65 /etc/nohang/nohang-desktop.conf
66 path to configuration file with settings optimized for desktop usage
67
68 /usr/share/nohang/nohang.conf
69 path to file with default nohang.conf values
70
71 /usr/share/nohang/nohang-desktop.conf
72 path to file with default nohang-desktop.conf values
73
74 /var/log/nohang/nohang.log
75 optional log file that stores entries if separate_log=True in the con‐
76 fig
77
78 /etc/logrotate.d/nohang
79 logrotate config file that controls rotation in /var/log/nohang/
80
82 · nohang.conf provides vanilla default settings without PSI checking
83 enabled, without any badness correction and without GUI notifications
84 enabled.
85
86 · nohang-desktop.conf provides default settings optimized for desktop
87 usage.
88
90 The next problems can occur with out-of-tree kernels and modules:
91
92 · The ZFS ARC cache is memory-reclaimable, like the Linux buffer cache.
93 However, in contrast to the buffer cache, it currently does not count
94 to MemAvailable [1]. See also [2] and [3].
95
96 · Linux kernels without CONFIG_CGROUP_CPUACCT=y (linux-ck, for example)
97 provide incorrect PSI metrics, see this thread [4].
98
100 The program can be configured by editing the config file. The configu‐
101 ration includes the following sections:
102
103 · Memory levels to respond to as an OOM threat
104
105 · Response on PSI memory metrics
106
107 · The frequency of checking the level of available memory (and CPU us‐
108 age)
109
110 · The prevention of killing innocent victims
111
112 · Impact on the badness of processes via matching their names, cmdlines
113 and UIDs with regular expressions
114
115 · The execution of a specific command or sending any signal instead of
116 sending the SIGTERM signal
117
118 · GUI notifications:
119
120 · notifications of corrective actions taken
121
122 · low memory warnings
123
124 · Verbosity
125
126 · Misc
127
128 Just read the description of the parameters and edit the values.
129 Restart the daemon to apply the changes.
130
132 Check the config for errors:
133
134 $ nohang --check --config /path/to/config
135
137 The safest way is to run nohang --memload. This causes memory consump‐
138 tion, and the process will exits before OOM occurs. Another way is to
139 run tail /dev/zero. This causes fast memory comsumption and causes OOM
140 at the end. If testing occurs while nohang is running, these processes
141 should be terminated before OOM occurs.
142
144 To view the latest entries in the log (for systemd users):
145
146 $ sudo journalctl -eu nohang.service
147
148 or
149
150 $ sudo journalctl -eu nohang-desktop.service
151
152 You can also enable separate_log in the config to logging in
153 /var/log/nohang/nohang.log.
154
156 Sending SIGTERM, SIGINT, SIGQUIT or SIGHUP signals to the nohang
157 process causes it displays corrective action stats and exits.
158
160 Please ask any questions and report bugs at
161 <https://github.com/hakavlad/nohang/issues>.
162
164 Written by Alexey Avramov <hakavlad@gmail.com>.
165
167 Homepage is <https://github.com/hakavlad/nohang>.
168
170 oom-sort(1), psi-top(1), psi2log(1)
171
173 1. https://github.com/openzfs/zfs/issues/10255
174
175 2. https://github.com/rfjakob/earlyoom/pull/191#issuecomment-622314296
176
177 3. https://github.com/hakavlad/nohang/issues/89
178
179 4. https://github.com/hakavlad/nohang/issues/25#issuecomment-521390412
180
181
182
183 nohang(8)