2

For over a year now, I have a problem with shutdown. Here are the conditions that need to be met:

  • Swap is enabled
  • Swap is used: I have 8GB and when I start using above 4~5GB, I start seeing stuff in swap. Usually happens when I run virtual machines or big games.

In these cases, when I shutdown the PC, I see the following:

  • Most of the shutdown takes place
  • Do nothing for minutes, even 10 minutes or more
  • Finally shutdown

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.


Edit:

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:

Part 2

Part 1


Edit:

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.

Shahbaz
  • 788
  • Just FYI, a few months ago I did a clean install of 16.04 in my new shiny SSD and I don't have this problem anymore. Not sure if the problem went away because of using a new kernel, or because of clean reinstall. – Shahbaz Dec 13 '16 at 19:05

0 Answers0