systemd-oomd issues on desktop

Lukas Märdian slyon at
Tue Jun 14 08:53:54 UTC 2022

Am 14.06.22 um 01:22 schrieb Nick Rosbrook:
> On Mon, Jun 13, 2022 at 8:19 AM Lukas Märdian <slyon at> wrote:
>> I wonder if we could use a more selective approach, though, using
>> "OOMScoreAdjust=" in the systemd.exec environment (i.e. Gnome-Shell
>> launcher in Ubuntu's context, as sd-oomd is currently only enabled on
>> Ubuntu Desktop) [2], to reduce the probability of certain "important"
>> apps being killed first, e.g. by maintaining an allow-list of such apps.
> IIUC, OOMScoreAdjust only influences the behavior of the kernel OOM
> killer, not systemd-oomd. In any case, I do agree that a "selective
> approach" might improve the current situation (this is what I tried to
> convey in option (2)).

Indeed. I misread the man page "This setting also applies to 
systemd-oomd" => This only applies to "OOMPolicy=" and only as of v251 
so it won't help us here. [1]

> The ManagedOOMPreference[1] option exists, but this property is
> ignored if the unit's cgroup is not owned by root. The rationale for
> the limitation is described in a link that Michel shared [2]. In
> short, this option is reserved for "critical services" and should be
> used sparingly. But, as Steve said earlier, it is likely that the
> browser is the most important process to many desktop users. Maybe
> this limitation on setting ManagedOOMPreference could be removed, or
> eased to at least allow setting `ManagedOOMPreference=avoid` on
> non-root owned cgroups? For this to be effective, there would need to
> be other viable kill candidates (i.e. cgroups with greater than 5%
> swap usage) when the SwapUsedLimit is met.

Yes, I feel like allowing a "ManagedOOMPreference=avoid" for critical UI 
applications, would be a sensible change to make. This should allow 
starting applications like this (possibly integrated with the 
gnome-shell launcher for allow-listed applications):

$ systemd-run --user -p ManagedOOMPreference=avoid firefox

Should we setup a PPA to apply this modification for testing it against 
the "Do not enable swap kill at all" (option 3) approach and ask the 
affected users [2] to test both methods for the best outcome?

Testing option (3) should be as easy as adding a new file in /etc to 
override the "ManagedOOMSwap=" setting, using the current systemd build 
available in Ubuntu Jammy:

$ cat /etc/systemd/system/-.slice.d/10-oomd-root-slice-defaults.conf



-- Lukas

> Thanks,
> Nick
> [1]
> [2]


More information about the ubuntu-devel mailing list