Let's say a user has two services with ManagedOOMMemoryPressure=kill, perhaps a web server under system.slice and a batch job under user.slice. Both exceed their pressure limits. On the previous timer tick, oomd has already queued the web server's candidate for killing, but the prekill hook has not yet responded, so the kill is still pending. In the code, monitor_memory_pressure_contexts_handler() iterates over all pressure targets that have exceeded their limits. When it reaches the web server target and calls oomd_cgroup_kill_mark(), which returns 0 because that cgroup is already queued. The code treats this the same as a successful new kill: it resets the 15 second delay timer and returns from the function, exiting the loop. This loop is handled by SET_FOREACH and the iteration order is hash-dependent. As such, if the web server target happens coincidentally to be visited first, oomd never evaluates the batch job target at all. The effect is twofold: 1. oomd stalls for 15 seconds despite not having initiated any new kill. That can unnecessarily delay further action to stem increases in memory pressure. The delay exists to let stale pressure counters settle after a kill, but no kill has happened here. 2. It non-deterministically skips pressure targets that may have unqueued candidates, dangerously allowing memory pressure to persist for longer than it should. Fix this by skipping cgroups that are already queued so the loop proceeds to try other pressure targets. We should only delay when a new kill mark is actually created.
System and Service Manager
Details
Most documentation is available on systemd's web site.
Assorted, older, general information about systemd can be found in the systemd Wiki.
Information about build requirements is provided in the README file.
Consult our NEWS file for information about what's new in the most recent systemd versions.
Please see the Code Map for information about this repository's layout and content.
Please see the Hacking guide for information on how to hack on systemd and test your modifications.
Please see our Contribution Guidelines for more information about filing GitHub Issues and posting GitHub Pull Requests.
When preparing patches for systemd, please follow our Coding Style Guidelines.
If you are looking for support, please contact our mailing list, join our IRC channel #systemd on libera.chat or Matrix channel
Stable branches with backported patches are available in the stable repo.
We have a security bug bounty program sponsored by the Sovereign Tech Fund hosted on YesWeHack
Repositories with distribution packages built from git main are available on OBS, and also repositories with packages built from the latest stable release
