https://www.kernel.org/doc/gorman/html/understand/understand...
The kernel's OOM killer can be annoying and complicated sometimes, but I do like it since I can easily change /proc/${PID}/oom_score_adj to prevent it from killing something important.
EDIT: Per the docs:
systemd-oomd is a system service that uses cgroups-v2 and pressure stall information (PSI) to monitor and take corrective action before an OOM occurs in the kernel space.
https://www.freedesktop.org/software/systemd/man/systemd-oom...I'd be really interested in a more thorough explanation about the justification for it. This makes it seem like a bad thing that this is happening in the kernel, but memory management is the kernel's job and there would be less overhead than in userspace. Personally I think OOMScoreAdjust that systemd I think has provided a long time is the best approach for this, since it's not duplicating functionality and gives you a more user-friendly way to maintain the oom score without messing around with /proc.
Another fun fact, it also seems to kill based on what it determines to be excessive swap usage.
https://askubuntu.com/a/1423840
Facebook also wrote its own oom daemon, that systemd's was forked from:
Whether this systemd implementation is any better is, of course, another question entirely.
That's why some orgs implemented their own solutions to avoid OOMKiller having to enter the picture, like Facebook's user-space oomd [1] or Android's LMKD [2]
It looks like systemd-oomd is related to (based on? from the same people as?) Facebook's oomd https://github.com/facebookincubator/oomd , whose documentation gives a bunch of reasons as to why you would prefer a userspace oomd that takes in PSI data and can be configured to proactively kill misbehaving processes instead of just letting the kernel OOM killer handle it. The major reason is time to recovery: a misbehaving process can cause a system to be so far under pressure that the kernel OOM killer will take a long time to flush things out, but a userspace component can respond in advance with more configurable rules (and more flexibility, since the kernel doesn't believe you're at capacity yet).
That's what's causing the lock ups.
Sounds to me this would be difficult to fix without breaking backward compatibility.
In the mean time, you can probably improve your quality of life quite a bit by using something like: https://github.com/facebookincubator/oomd
If you want to turn off overcommit and have the system power off when it runs out of memory, the kernel allows that.
Whatever knob they add will certainly be configurable, and ubuntu desktop can configure it one way while ubuntu server configures it the other, if it turns out people would prefer that.
In practice, people running servers seem to want oom killers to kick in before the server barfs. One example of this is facebook's oomd [1]. I assure you, they're running that on their servers, not their web-browser-machines.
https://github.com/facebookincubator/oomd
There was also more minimal proof-of-concept example posted by Endless OS guys:
https://gist.github.com/dsd/a8988bf0b81a6163475988120fe8d9cd