Ubuntu Developers Have An Idea For Handling The Over-Eager Systemd OOMD App Killing
Written by Michael Larabel in Ubuntu on 23 June 2022 at 07:06 PM EDT. 56 Comments
UBUNTU --
With the recent release of Ubuntu 22.04 LTS it is shipping systemd-oomd by default on their desktop for trying to better handle low-memory / out-of-memory situations. However, in real-world use systemd-oomd is too easily killing user-space applications like Firefox and Chrome when approaching memory pressure. This is a poor Ubuntu 22.04 user experience but the developers now have an idea for their approach to addressing this solution.

Systemd-oomd on Ubuntu 22.04 LTS is too easily killing user applications like web browsers and other memory intense but user-critical applications. This killing of applications under memory pressure is often being done without the user aware of what's happening or any notice.

They've discussed altering their systemd-oomd tunables, even changing the swap size of Ubuntu by default as a possibility, and other changes. Based on the latest mailing list messages and activity by Canonical engineers, they are wanting an upstream change to systemd and then modifications to key desktop components so they can properly communicate that OOM killing of them should be avoided.

Systemd has a "ManagedOOMPreference" setting already that service files can use where one of the supported values is "avoid" if the out-of-memory preference is to try to avoid killing the unit's cgroup when systemd-oomd is figuring out how to reduce memory consumption. The avoided services will only be killed if no other viable candidates for killing are available (or there is also "omit" where in no case would OOMD kill that unit's cgroup). But the problem right now is the ManagedOOMPreference is only honored for cgroups owned by root, which isn't the case in the desktop realm.

Canonical's Nick Rosbrook has opened a preliminary pull request to upstream systemd that would allow ManagedOOMPreference to work for all cgroups, just not the root-owned ones. Systemd upstream isn't opposed to it and there was even a similar idea last year that hadn't been merged for allowing user control over this preference.


So it looks like this change may go forward upstream and Ubuntu 22.04 LTS could then back-port the change. User service files could then set ManagedOOMPreference to omit or avoid, as desired. However, this wouldn't do good for applications launched by the GNOME Shell or Snapd. So further work would be needed integrating the ManagedOOMPreference handling into GNOME Shell for passing the preference to selected applications when launched. There is also a matter of figuring out all of which services/applications to set for the ManagedOOMPreference=avoid behavior.

At least from the ubuntu-devel thread this appears to be their preferred path forward for taming Ubuntu's systemd-oomd to not kill prominent user-space/desktop applications. It will still take some time though for the change to be upstreamed and for that better desktop integration to occur.
Related News
About The Author
Author picture

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week