I have been quite happy with suspend-to-disk. But getting more and more RAM, this is not really working as well as it used to.

Suspending TO disk works fine: It takes a minute or 2, which is what I would expect given my disks performance.

The problem is waking up after the suspend: the disk takes forever to seek, and it reads only a single page resulting in a page-in rate of less than 1 MB/s.

Is there some way I can ask the kernel to read the next, say, 10 MB and opportunistically swap that in - instead of just reading a single page?

If just a single page of the 10 MB would be needed soon, then it would not be wasted. And even if most of the 10 MB were not needed, then the pages will still be clean and can simply be reclaimed as free pages - the swapped copy is untouched.


This takes up 6.5G RAM, uses that memory actively and uses a full core at 100%:

perl -e 'while(1){for(1..25000000){$t{$_}++}}'

Before suspend to disk:

             total       used       free     shared    buffers     cached
Mem:       8074280    7876864     197416      93460     169524     625912
-/+ buffers/cache:    7081428     992852
Swap:      8282108          8    8282100

The suspend to disk takes: 7m10s

The disk's raw performance is 50 MB/s.

Resuming from disk to when the display is up and running takes: 0m32s

But before the system reacts to key presses, it has to swap in for an additional: 2m02s

At this time the memory usage looks like this:

             total       used       free     shared    buffers     cached
Mem:       8074280    2846392    5227888      74232       8312     157588
-/+ buffers/cache:    2680492    5393788
Swap:      8282108    5103264    3178844

Note that the full 6.5G that the perl program uses is not swapped in. It needs 4-5 GB more.

vmstat 1 reports that the system is swapping in at a rate of 600 KB/s:

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 0  2 3506124 1525652  27732 274036  632    0   632     0  228  740  6  1 50 44  0

iostats reports the disk is at 100% I/O utilization (probably due to seeking all the time).

The perl program uses around 0.3% CPU, because every time it does anything, it causes a page fault.

It continues to swap in for another: 1h15m12s

And then finally the perl program is completely swapped in and can run at 100% again.

So what I would like instead is that the swapping in takes much shorter. And one of the ways it could be done is by increasing the 600 K/s by swapping in 10 MB at a time instead of just a single page frame.

But maybe there are other tuning parameters, that will make the swapin happen faster.

(swapoff -a would be an option in my case - it swaps in at 10 MB/s, but it will not work, if there is more than 8 GB swapped out, and is thus not a general solution).

  • 1
    Elaborate more? What commands, how are you measuring this? Suspend to disk (hibernate) should write / read without undue number of seeks, are we talking about the same thing? More and more RAM should not matter either, it depends what's actually used not including caches (after sync; echo 3 > /proc/sys/vm/drop_caches). – frostschutz Oct 12 '16 at 0:01
  • It is the waking up after hibernation that is the problem - not the going to sleep. – Ole Tange Oct 12 '16 at 6:47
  • linux/Documentation/power/swsusp.txt describes the hibernation and wake up process. This is supposed to be written and read as a snapshot image in one go, not individual paging (and you can't use the system at all before it's done). Maybe you're doing something else, thus I ask you to elaborate more... – frostschutz Oct 12 '16 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.