I am wondering, is there a syscall, or has this ever been discussed, to move memory pages from swap back to RAM, given there is enough free RAM? I am thinking of something like the infamous
swapoff -a swapon -a
but in a safer fashion (if there is not enough RAM, don't move back the remaining pages) and possible only when the computer is idle.
I see the question "How do I get the memory content back into RAM" quite often, so I'm wondering if others have also thought about a more intelligent solution?
Possible use cases: An application uses up all RAM, resulting in the memory of the other apps being swapped out. After that application is terminated, there would be enough space in RAM again for the remaining applications. The user experience would greatly improve if their memory resides on a fast device when it needs to be accessed (no laggy behaviour), so it would be beneficial if the unswapping took place during the computer's idle time already. Prominent examples are window managers, desktop environments, browsers or other memory intensive applications.