Okay, why does `swapoff` exist on Linux? It's completely useless as far as I can tell. It's been running for 24h to swap in like 1.5GB of used swap or so, on a largely idle server with >32GB free RAM. How can it be *this* hilariously inefficient?
Conversation
Replying to
Pretty much the entire swap infrastructure on Linux is laughably bad.
Like, what, are they reading a page at a time and waiting for it to finish getting read before paging in something else?
1
1
It's far worse than that. It would be far faster if it could just read in the pages one at a time, which is basically what happens if they're all in the swap cache. If the page isn't in swap cache, it has to figure out where it's being used to handle it.
Quote Tweet
Replying to @marcan42
It iterates through the swapped pages one by one and in the worst case it has to walk through the page tables for every process to look for the uses of the page. It would often be far more efficient to walk through the page tables a single time, but it doesn't know how to do it.


