WARNING: I have tested the following mainly without any swap (partitions/files) enabled (eg. either no swap, or no swap support in kernel)
Explanations as to why kswapd0 does constant disk reading before OOM-killer kills the offending process:
- see the answer and comment of https://askubuntu.com/a/432827/861003
- see the answer and David Schwartz comments of https://unix.stackexchange.com/a/24646/306023
An example of constant disk reading due to out of memory, that I've encountered compiling firefox inside a qube(VM):
starts here: https://groups.google.com/d/msg/qubes-users/aSPefKH223U/PYc4m25SCQAJ
(note that this happens even with vm.swappiness=0(seen in a comment below) even though it was 60 in that example)
Wanting to recompile a custom kernel without kswapd0 (don't know how yetnot possible without kswapd0): https://unix.stackexchange.com/q/463233/306023
But it seems, it SEEMS, so far that just vm.swappiness=0 does it! (according to my below comments/screens)
Potential mitigating effects:
1.
sudo sysctl vm.overcommit_memory=2 #was 0
sudo sysctl vm.overcommit_ratio=50 #was 50 by default (if set to 200 it brings back the disk thrashing)vm.watermark_scale_factor=1000seems to cause a delay during which you could stop the disk thrashing before it begins to fully freeze the system.
sudo sysctl vm.overcommit_memory=0 #was 0
sudo sysctl vm.overcommit_ratio=50 #was 50
sudo sysctl vm.vfs_cache_pressure=0 #was 100
#sudo sysctl vm.watermark_scale_factor=1 #was 10
sudo sysctl vm.watermark_scale_factor=1000 #was 10
sudo sysctl vm.oom_kill_allocating_task=0 #was 0Possibly irrelevant(in the above context only): vm.vfs_cache_pressure=0
- (I have not looked at or checked) https://github.com/rfjakob/earlyoom (thanks to gudok on StackOverflow)
- (I have not looked at or checked) https://github.com/hakavlad/nohang
- (I have not looked at or checked) https://github.com/facebookincubator/oomd
Solutions so far:
- IFF you're not using any swap(eg. kernel support for swap is disabled) then patching kernel so that
Active(file)pages are not evicted works for me: https://stackoverflow.com/q/52067753/10239615
mirror1, mirror2 noobish patch by me though, so the side-effects are unknown. But, no more disk thrashing and no more freezing the OS!

















This comment has been minimized.
constantoverride commentedAug 18, 2018
Here's a snapshot(screenshots) of things, with






vm.swappiness=60at the point when there was constant disk reading of over 220MiB/sec (according to dom0 xfce-panel'sDisk Performance Monitorplugin(not pictured)) that was caused by the specific AppVM which was compiling firefox and was thus frozen (the windows weren't updating):And the following is the first(or second/third? can't really be too sure) window update after the OOM-killer killed the offending






rustcprocess which was hogging the RAM: