nohang(8)

✨ nohang(8) ✨

okay bestie, gather round, because we're about to talk about the Linux System Administrator's Manual entry for nohang and honestly? she's iconic.


πŸ’– NAME πŸ’–

nohang β€” a sophisticated low memory handler. yes. sophisticated. she has layers. πŸŽ€


🌸 SYNOPSIS 🌸

nohang [OPTION]...

that's it. that's the whole summoning ritual. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so nohang is a highly configurable daemon for Linux, and what she does is correctly prevent out of memory (OOM) and keep your system's responsiveness alive when memory gets low. like, she's not out here panicking when things get tight β€” she's the friend who stays calm and fixes everything while everyone else is screaming. main character energy fr. πŸ‘‘


🫢 REQUIREMENTS 🫢

for basic usage (the bare minimum, the essentials, the vibe check):

  • Linux (>= 3.14, because that's when MemAvailable showed up in /proc/meminfo)
  • Python (>= 3.3)

to respond to PSI metrics (optional, but make it fancy):

  • Linux (>= 4.20) with CONFIG_PSI=y

to show GUI notifications (optional, the aesthetic tier):

  • a notification server (most desktop environments use their own implementations)
  • libnotify (on Arch Linux, Fedora, openSUSE) or libnotify-bin (on Debian GNU/Linux, Ubuntu)
  • sudo if nohang was started with UID=0

⭐ COMMAND-LINE OPTIONS ⭐

okay this is the part where you actually learn the buttons, pay attention bestie:

  • -h, --help β€” show this help message and dip. πŸšͺ
  • -v, --version β€” show the version of the installed package and exit
  • -m, --memload β€” consume memory until 40 MiB (MemAvailable + SwapFree) remain free, then terminate the process. yes she will eat your RAM on purpose, that's the point, it's a test πŸ’€
  • -c CONFIG, --config CONFIG β€” path to the config file. this should only be used with one of the following options: --monitor, --tasks, --check
  • --check β€” check and show the configuration, then exit. this should only be used with the -c/--config CONFIG option
  • --monitor β€” start monitoring. this should only be used with the -c/--config CONFIG option
  • --tasks β€” show tasks state and exit. this should only be used with the -c/--config CONFIG option

πŸŽ€ FILES πŸŽ€

  • :SYSCONFDIR:/nohang/nohang.conf β€” path to the vanilla nohang configuration file
  • :SYSCONFDIR:/nohang/nohang-desktop.conf β€” path to the configuration file with settings optimized for desktop usage
  • :DATADIR:/nohang/nohang.conf β€” path to the file with default nohang.conf values
  • :DATADIR:/nohang/nohang-desktop.conf β€” path to the file with default nohang-desktop.conf values
  • /var/log/nohang/nohang.log β€” optional log file that stores entries if separate_log=True in the config
  • /etc/logrotate.d/nohang β€” logrotate config file that controls rotation in /var/log/nohang/

🌈 nohang.conf vs nohang-desktop.conf 🌈

it's giving sibling rivalry, but make it config files:

  • nohang.conf gives you vanilla default settings β€” no PSI checking enabled, no badness correction, and no GUI notifications enabled. minimal. clean. raw. πŸƒ
  • nohang-desktop.conf gives you default settings optimized for desktop usage. she's dressed up, she's ready to go out. ✨

πŸ’€ PROBLEMS πŸ’€

ngl bestie, these next problems can happen with out-of-tree kernels and modules. read carefully.
  • The ZFS ARC cache is memory-reclaimable, like the Linux buffer cache. However, in contrast to the buffer cache, it currently does not count toward MemAvailable [1]. See also [2] and [3].
  • Linux kernels without CONFIG_CGROUP_CPUACCT=y (linux-ck, for example) provide incorrect PSI metrics, see this thread [4].

πŸ’… HOW TO CONFIGURE πŸ’…

you configure the program by editing the config file. the configuration includes the following sections:

  • Memory levels to respond to as an OOM threat
  • Response on PSI memory metrics
  • The frequency of checking the level of available memory (and CPU usage)
  • The prevention of killing innocent victims 😭 (protect the innocent!!)
  • Impact on the badness of processes via matching their names, cmdlines and UIDs with regular expressions
  • The execution of a specific command or sending any signal instead of sending the SIGTERM signal
  • GUI notifications:
    • notifications of corrective actions taken
    • low memory warnings
  • Verbosity
  • Misc

Just read the description of the parameters and edit the values. Then restart the daemon to apply the changes. no cap, the restart is not optional. πŸ”


πŸ” CHECK CONFIG πŸ”

check the config for errors, like so:

$ nohang --check --config /path/to/config

πŸ§ͺ HOW TO TEST πŸ§ͺ

The safest way is to run nohang --memload. This causes memory consumption, and the process will exit before OOM occurs. πŸ›Ÿ

Another way is to run tail /dev/zero. This causes fast memory consumption and causes OOM at the end. πŸ’€

If testing occurs while nohang is running, these processes should be terminated before OOM occurs.

πŸ“œ LOGGING πŸ“œ

To view the latest entries in the log (for systemd users):

$ sudo journalctl -eu nohang.service

or

$ sudo journalctl -eu nohang-desktop.service

You can also enable separate_log in the config to log into /var/log/nohang/nohang.log. πŸ“


🚨 SIGNALS 🚨

Sending SIGTERM, SIGINT, SIGQUIT or SIGHUP signals to the nohang process causes it to display corrective action stats and exit. so basically, she'll show you the receipts on her way out. πŸ’…


πŸ™ˆ REPORTING BUGS πŸ™ˆ

Please ask any questions and report bugs at https://github.com/hakavlad/nohang/issues. don't be shy, they don't bite 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Written by Alexey Avramov <hakavlad@gmail.com>.


🏠 HOMEPAGE 🏠

Homepage is https://github.com/hakavlad/nohang.


πŸ¦‹ SEE ALSO πŸ¦‹

oom-sort(1), psi-top(1), psi2log(1)


πŸ“Ž NOTES πŸ“Ž

  1. https://github.com/openzfs/zfs/issues/10255
  2. https://github.com/rfjakob/earlyoom/pull/191#issuecomment-622314296
  3. https://github.com/hakavlad/nohang/issues/89
  4. https://github.com/hakavlad/nohang/issues/25#issuecomment-521390412

and that's the whole page bestie!! 🌸 this one lives in the Linux System Administrator's Manual as nohang(8), and she's been serving since... well, the footer doesn't say a date, so let's just say she's timeless. ✨ mwah, go protect your RAM. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from