34 hours ago
For over a year now, I have a problem with shutdown. Here are the conditions that need to be met:
In these cases, when I shutdown the PC, I see the following:
Of course, at this point I use Alt+SysRq to sync, mount read only and force shutdown.
With swap disabled, I don't have this problem, but I can run out of memory (which hangs Linux for a minute before OOM makes up its mind to kill someone, which is another problem).
Does anyone know what the problem could be? Or how I can debug it?
I tried taking the stack trace with Alt+SysRq, but during shutdown the resolution is low and with four cores, most of the trace is outside the screen, so I can't seem to figure out where it is stalling either.
P.S. I am not sure if I was affected by this in 14.04, but I'm fairly certain it happened before systemd as well as after it.
Silly me, I can scroll back and see the shutdown logs. If I print a stack trace when shutdown gets stuck, three cores are in cupidle_enter_state() or something like that, and the thread printing the stack trace has this trace:
I thought about doing a swapoff before shutdown, so that perhaps the problem goes away. This showed that the swap is turned off at a super-slow rate of 8MB/s. This may be why the shutdown was so slow in the first place, perhaps it was doing a swapoff. swapoff being slow seems to affect many people. I'll investigate more and write an answer if I can manage to get something conclusive.