4 ms·
From TFA: "The Linux Kernel will move memory pages which are hardly ever used into swap space to ensure that even more cachable space is made available in-memor
by wrycoder 7y ago
From TFA: "The Linux Kernel will move memory pages which are hardly ever used into swap space to ensure that even more cachable space is made available in-memory for more frequently used memory pages (a page is a piece of memory). Swap usage becomes a performance problem when the Kernel is pressured to continuously move memory pages in and out of memory and swap space."
- mason55 7y agoI still don't get how that answers the question. If I have enough RAM for both the "hardly ever used" pages and the "more frequently used" pages then what good is the swap doing me? The only way that makes sense is if there is some cache the kernel has which is faster than RAM. BUT the kernel cannot move things between this cache and RAM, it can only treat the cache + RAM as a single blob, so to free up space in the cache the kernel has to move pages to disk. So by having some swap space the kernel can move hardly ever used pages to disk which is the only way to free up space in this cache. It's possible that what I just described really exists, I don't know that much about the internals of how the kernel manages memory. But if that is what's happening then THAT is the detail that would have been useful in this post.
- wrycoder 7y agoIt does work that way. I had a small, very lightly loaded VPS that had no swap. Occasionally, it would not start all its services on boot, in particular the db, due to OOM. Adding a small amount of swap allowed it to boot cleanly. The swap was not subsequently used. The alternative was to upgrade the server RAM at double the monthly cost.