Linux – Why does mouse and keyboard freeze when Linux swaps

linuxperformanceswap

I have noticed that under Linux, when there is heavy swapping, the mouse cursor freezes, and even CapsLock or Ctrl+Alt+F1 don't work. The system uses the deadline I/O scheduler but this should not matter at all since mouse and keyboard I/O should not compete with disk I/O. During the swapping the CPU is pretty idle, I can see it by the audible fan activity. I have read others complain about this as well. For comparison, even Windows XP does not freeze mouse and keyboard, and you can actually do something to kill the offending process. Under Linux you need to have ssh server, otherwise you can only sit and wait till the OOM killer kills the app.

Best Answer

In order to run a program, it must be in RAM. During thrashing, all programs get swapped out of RAM and then have to be swapped in again before they can run.

Additionally, for many (but not all) input events, there must be a round trip between your X11 server and your window manager, and the window manager may try to trigger additional events. And since you don't have any RAM, if the window manager writes to a pipe or socket, that has to block until the receiving process reads from it.

Related Question