Systemd OOMD Will Now Honor "ManagedOOMPreference" For All cgroups
Ubuntu 22.04 LTS already made a change so systemd-oomd is killing less user applications while now they have managed to get a change upstreamed into systemd for improving the "ManagedOOMPreference" control with this preference being for deprioritizing or omitting a unit's cgroup as a candidate for systemd-oomd when under memory/swap pressure..
Going back to June there were Ubuntu developers looking at systemd's ManagedOOMPreference for indicating services that should be avoided for killing when facing the OOMD hammer. However, the big limitation is that ManagedOOMPreference was only honored for cgroups owned by root -- and thus not desktop user services. It's ultimately that change that in the past few days has been upstreamed for systemd.
Nick Rosbrook of Canonical wrote in that systemd pull request:
The motivation behind these patches is to allow desktop environments to have some control over which applications are targeted (or avoided) by systemd-oomd when it needs to act on candidate cgroups. In the current state, the ManagedOOMPreference property is ignored for any cgroups which are not owned by root. This is unfortunate for desktop environments where applications are launched as descendants of [email protected].
In practice, when systemd-oomd needs to act on desktop systems, user applications such as browsers are killed first. For desktop users, it is very likely that their browser (or some other desktop application) is their most critical program, and it may make sense to de-prioritize the browser's cgroup as a kill candidate. For this reason, I think it is important that systemd-oomd honors ManagedOOMPreference on cgroups which are not owned by root.
As of last week, the change is now merged in upstream systemd for allowing ManagedOOMPreference on all cgroups.