What are the necessary kernel .config options changes for a kernel with disabled kswapd0 ? ie. what options to ensure exist inside kernel .config file such that it builds with kswapd0 disabled?

The aim of this is to avoid what the commenter to this answer says, to reproduce it here it says:

For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it. – Mikko Rantalainen Feb 15 at 13:08

(also found someone else explaining this here - see those comments mentioning 95%)

I've personally encountered this kind of constant disk reading (over 192MiB/sec) for minutes(before I stopped it by pausing the VM) well before OOM triggered to kill the memory-hogging process; I've also seen it happen on bare-metal but had no idea at the time why the disk thrashing was occurring prior to running out of memory (with no swap whatsoever).

Question inspired from the last line in this answer

  • This constant disk reading can easily be reproduced inside an AppVM (QubesOS) with like 4000MB max RAM while attempting to compile firefox inside it, screens here
    – user306023
    Aug 19, 2018 at 13:07
  • From what I can tell, kswapd0 cannot be disabled from .config options, not without patching the kernel. # CONFIG_SWAP is not set is not enough! [kswapd0] process still exists, and the disk thrashing is still reproducible also.
    – user306023
    Aug 28, 2018 at 20:48


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy