Suspend to disk fails: image_size too small

Bug #88377 reported by Robbie Groenewoudt
40
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Medium
Unassigned
linux-source-2.6.20 (Ubuntu)
Won't Fix
Undecided
Ben Collins

Bug Description

Suspend to disk failed on my Dell Inspiron 1501 with 512mb memory. The error was:

[ 244.536000] swsusp: critical section:
[ 244.536000] swsusp: Need to copy 58721 pages
[ 244.536000] swsusp: Normal pages needed: 58721 + 1024 + 14, available pages: 55565
[ 244.536000] swsusp: Not enough free memory

However the following fix from http://ubuntuforums.org/showthread.php?t=19995 helped me:

echo 2048248 > /sys/power/image_size

It seems that the standard image_size is not big enough.

Revision history for this message
Cristian Aravena Romero (caravena) wrote :

Thanks for taking the time to report this bug. Unfortunately we can't fix it, because your description didn't include enough information.

Please include the information requested from https://wiki.ubuntu.com/DebuggingACPI as separate attachments.

Changed in acpi-support:
assignee: nobody → caravena
status: Unconfirmed → Needs Info
Revision history for this message
Robbie Groenewoudt (dutchmega) wrote :

Distribution: Feisty with latest updates (some problem at Edgy)
BIOS: Up to date (2.1.0)
uname -a: 2.6.20-9-generic

kern.log coming

Revision history for this message
Robbie Groenewoudt (dutchmega) wrote :

Attached sudo lspci -vvn

Revision history for this message
Robbie Groenewoudt (dutchmega) wrote :

Attached sudo dmidecode

Revision history for this message
Peter Whittaker (pwwnow) wrote :

Robbie, could you please also update the report with information about your swap partition (size, etc.). You could add the output of the command

cat /proc/swaps

to the report. (Basically, we are making sure that the swap partition is greater than physical memory.) Thanks!

Revision history for this message
Robbie Groenewoudt (dutchmega) wrote :

cat /proc/swaps
Filename Type Size Used Priority
/dev/sda1 partition 1020116 32 -1

It's bigger :)

Revision history for this message
Cristian Aravena Romero (caravena) wrote :

Robbie,

* Ask the user to try to hibernate/suspend and then restart the system and attach /var/log/kern.log.0

Revision history for this message
Robbie Groenewoudt (dutchmega) wrote :

Attached kern.log

Changed in linux-source-2.6.20:
assignee: caravena → ubuntu-kernel-team
status: Needs Info → Confirmed
Revision history for this message
brokencrystal.com (admin-brokencrystal) wrote :

 I have an Inspiron 1501 and here is some info from mine... (File Attached)

Revision history for this message
Ben Collins (ben-collins) wrote :

Default image_size is larger than the number you showed. What is the default size ("cat /sys/power/image_zie")?

Changed in linux-source-2.6.20:
assignee: ubuntu-kernel-team → ben-collins
status: Confirmed → Needs Info
Revision history for this message
Robbie Groenewoudt (dutchmega) wrote :

At my system: 524288000

Revision history for this message
Ben Collins (ben-collins) wrote :

Ok, if the default is 524288000, then how can lowering it to 2048248 make it work? :)

Sounds like this isn't really the fix. Can you reliably use this trick to make it work and if it isn't done, make it not work?

Revision history for this message
Robbie Groenewoudt (dutchmega) wrote :

That is weird, now you mention it... It was smaller the last time.. Maybe due some change in Feisty.

I'll grab a 6.10 livecd in a few hours and do some tests

Revision history for this message
Ben Collins (ben-collins) wrote :

We haven't done any changes to this size. It's the stock default. Perhaps something local to your system adjusted this value?

Revision history for this message
Thomas Amthor (thomas-amthor-gmail) wrote :

I'm using ubuntu 7.04 on a ThinkPad T60, 512MB RAM and 2GB swap.
I see the same phenomenon regarding image_size:

/sys/power/image_size defaults to 524288000.
With this configuration, suspend to disk fails and I get the error
[ 5177.396000] swsusp: critical section:
[ 5177.396000] swsusp: Need to copy 65424 pages
[ 5177.396000] swsusp: Normal pages needed: 65424 + 1024 + 14, available pages: 65358
[ 5177.396000] swsusp: Not enough free memory

When changing image_size to 2048248 (my swap size in kB), suspend to disk works without problems:
[ 5550.252000] swsusp: critical section:
[ 5550.252000] swsusp: Need to copy 18854 pages
[ 5550.252000] swsusp: Normal pages needed: 18854 + 1024 + 14, available pages: 111928

The complete kern.log is attached.

Revision history for this message
Chris (poser) wrote :

Hi all,

I'm right there with ya'.

Thinkpad t41p running Feisty (2.6.20-15-generic)
  - /sys/power/image_size: 524288000
  - /proc/swaps: /dev/sda2 partition 4096564 0 -1
  - /var/log/kern.log:
...
May 9 14:48:17 chibacityblues kernel: [ 586.616000] swsusp: critical section:
May 9 14:48:17 chibacityblues kernel: [ 586.616000] swsusp: Need to copy 137650 pages
May 9 14:48:17 chibacityblues kernel: [ 586.616000] swsusp: Normal pages needed: 137550 + 1024 + 24, available pages: 124232
May 9 14:48:17 chibacityblues kernel: [ 586.616000] swsusp: Not enough free memory
May 9 14:48:17 chibacityblues kernel: [ 586.616000] Error -12 suspending
...

I'm about to reset my /sys/power/image_size to 2048248 (or possibly 4096496) and see what happens....

Thanks!
-Chris

(Obligatory attachments to follow)

Revision history for this message
Chris (poser) wrote :
Revision history for this message
Chris (poser) wrote :
Revision history for this message
Chris (poser) wrote :
Revision history for this message
Chris (poser) wrote :
Revision history for this message
Chris (poser) wrote :

Yep,

The suggested workaround, 'echo 2048248 > /sys/power/image_size', did the trick. Hibernate/resume works. I still have some Atheros nonsense to work through (and I have yet to hibernate twice in a row without rebooting...) but it smells like progress.

May 9 16:22:56 chibacityblues kernel: [ 329.212000] pci 0000:00:1e.0: LATE freeze
May 9 16:22:56 chibacityblues kernel: [ 329.212000] pci 0000:00:01.0: LATE freeze
May 9 16:22:56 chibacityblues kernel: [ 329.212000] agpgart-intel 0000:00:00.0: LATE freeze
May 9 16:22:56 chibacityblues kernel: [ 329.212000] swsusp: critical section:
May 9 16:22:56 chibacityblues kernel: [ 329.212000] swsusp: Need to copy 31439 pages
May 9 16:22:56 chibacityblues kernel: [ 329.212000] swsusp: Normal pages needed: 29955 + 1024 + 24, available pages: 199419
May 9 16:22:56 chibacityblues kernel: [ 389.212000] agpgart-intel 0000:00:00.0: EARLY resume
May 9 16:22:56 chibacityblues kernel: [ 389.212000] pci 0000:00:01.0: EARLY resume
May 9 16:22:57 chibacityblues kernel: [ 389.212000] uhci_hcd 0000:00:1d.0: EARLY resume

Incidentally, if this image_size value is meant to be in KB, how come the default is so high (equivalent to approximately 500 GB...). More importantly (for my purposes), should I actually have a 4 GB default image size (because I have a 4GB swap partition) or a 1GB default image size (because I have 1 GB of RAM)?

Also, given that this default image_size value does not persist through a reboot, what is the best way to make it stick? Should I just add the echo command to pre-hibernate scripts?

Thanks a lot,
-Chris

Revision history for this message
Chris (poser) wrote :

OK,

I switched to 1GB, and I can now hibernate/resume repeatedly. I also found useful information on my post-resume NetworkManager bug at...

http://<email address hidden>/msg06138.html

-Chris

Revision history for this message
Sébastien Valette (sebastien-valette) wrote :

I can confirm that on my machine, lowering down the image_size to the exact swap size solved my similar hibernation issue.

Revision history for this message
Jeroen de Ridder (j-deridder) wrote :

I can confirm this worked like a charm on my Feisty machine.

Importantly, hibernate used to work after my recent fresh install. The only thing I can think of that I changed is that I installed the ATI proprietary fglrx drivers (compiled from source (Method 2) using: http://wiki.cchtml.com/index.php/Ubuntu_Feisty_Installation_Guide), but of course it may be unrelated. Does someone know if installing this could have caused this?

What would be the correct value? 1) equal to swap, 2) equal to 2xRAM, 3) something else?

Revision history for this message
Chris (poser) wrote :

Hi all,

Things now seem to work equally well with image_size set to either RAM size or swap size. For a while there, I was having trouble with a second resume-from-hibernate when I had set image_size equal to swap size, but I think I may have been using an incorrect value that was too large. Anyway, I'm guessing the "correct" value is RAM size or slightly higher.

I'm also guessing that the "units" (megabytes vs kilobytes vs. bytes) associated with image_size will suddenly change again at some point. Google revealed some tragically unhelpful diffs that correspond to a documentation "update" reflecting a change from megabytes to bytes...neither of which appears to be correct for this kernel.

-Chris

Revision history for this message
Alexander Hunziker (alex-hunziker) wrote :

Hi,

I have a T60 as well and reducing the image size solved the problem for me as well. Can somebody please post how to set the correct image size permanently, i.e. that it is still correct after rebooting the machine?

Thanks,
Alex

Revision history for this message
Alexander Hunziker (alex-hunziker) wrote :

OK, I created a new script in /etc/acpi/suspend.d/95-set-image-size.sh with the content:

#/bin/bash

echo 1048576 > /sys/power/image_size

That works fine. The script gets called by /etc/acpi/prepare.sh which in turn is executed from within /etc/acpi/hibernate.sh. It's also run when going into suspend to RAM mode but that doesn't hurt. I think creating a new file is better than altering an existing one for this way it won't be overwritten by updates.

Anyway, where is the RAM content being written on the disk? On the swap partition? Then what if your RAM is full and the swap partition contains data as well? Or is a file used for hibernation? Questions over questions...

Revision history for this message
lophiomys (lophiomys) wrote :

I can confirm this bug on a Thinkpad T42p 2373-KYG
on Kubuntu 7.04 Feisty Fawn, uname -r: 2.6.20-16-386; with ATI driver 8.38.7 (installed via Envy)

Reducing the image_size does make supend-to-disk work.

But after resuming form supsend-to-disk, the sound is gone and it seems to me
that the available RAM is not used any more: I mean the systems starts swapping earlier
compared to RAM/Swap usage after a fresh reboot.

---
some log info:

from kern.log:
[ 6462.836000] agpgart-intel 0000:00:00.0: LATE freeze
[ 6462.836000] swsusp: critical section:
[ 6462.836000] swsusp: Need to copy 132408 pages
[ 6462.836000] swsusp: Normal pages needed: 122609 + 1024 + 24, available pages: 106765
[ 6462.836000] swsusp: Not enough free memory
[ 6462.836000] Error -12 suspending
[ 6462.836000] agpgart-intel 0000:00:00.0: EARLY resume
- - - - -
# cat /sys/power/image_size
524288000
# swapon -s
Filename Type Size Used Priority
/dev/sda8 partition 3004112 0 -1
# free
             total used free shared buffers cached
Mem: 1035364 471764 563600 0 38076 278160
-/+ buffers/cache: 155528 879836
Swap: 3004112 0 3004112
- - - - -

Revision history for this message
Alexander Hunziker (alex-hunziker) wrote :

On Gutsy and 2 kernels later this still persists.

Revision history for this message
Yan Li (yanli) wrote :

I met same problem on Hardy kernel (2.6.24-5-generic), and I went to the source for a real answer. Read "kernel/Documentation/power/swsusp.txt". It said:
===============
If you want to limit the suspend image size to N bytes, do

echo N > /sys/power/image_size

before suspend (it is limited to 500 MB by default).
===============

I'm not a kernel expert, but it seems clear to me that if the size of all programs running on my machine exceeds 500M, which is quite often, the suspend fails. And since the image is stored in swap, you should just set it to the size of your swap. Deal.

I only read the one of 2.6.24, other versions may vary on this.

And what's more, it seems to me that it's safe to set the image_size to the size of swap _by default on all machines_ (as to my understanding of swsusp.txt)... just my $.02...

Revision history for this message
Yan Li (yanli) wrote :

A quick correct to what I said above:
Use swap size as "/sys/power/image_size" may not be a good decision in some cases. If you just want to make your suspend work, try:
"echo 0 > /sys/power/image_size"

For those who is curious about the cause and reason please read on:
reading more "kernel/Documentation/power/swsusp.txt" I got known that that "/sys/power/image_size" was introduced since 2.6.16 kernel as a way to improve responsiveness after resuming. By saving more memory, which includes more "volatile" data such as cache, buffer, etc., to hibernation image you can get a more responsive system after resuming (no need to pull data out of HD bit by bit, you retained your old cache), the dark side is larger image, thus may lead to the "not enough free space" error reported here, which means the swsusp can't find a "contiguous" space in swap large enough to hold the image (if you have more than one swap par, swsusp can use one only.... :X )

Therefore the most conservative way is to set "/sys/power/image_size" to zero, or some very small size. In this way, most "volatile" memory (such as cache, buffer, etc.) would be freed during hibernation, and thus lead to smallest image.

This further explains why the reporter's "echo 2048248 > /sys/power/image_size" works for most people, because 2048248 is too small (just 2M) and requires fewer swap than the default 500M setting.

I'll read the code of swsusp later if I have more time. And hope some kernel guru could help us on this. :)

And I think to make most average people's hibernation work out-of-the-box, Ubuntu should set image_size to 0 by default. Those who wanna better performance (and more tech savvy) could just change it after installation by themselves.

Revision history for this message
Leann Ogasawara (leannogasawara) wrote :

Just adding a note that I'm reassigning the Ubuntu Hardy kernel source package from 'linux-source-2.6.24' to just 'linux'. Beginning with the Hardy release the package naming convention changed from linux-source-2.6.x to just linux. Sorry for any confusion.

Changed in linux:
assignee: nobody → ubuntu-kernel-team
importance: Undecided → Medium
status: New → Triaged
Changed in linux-source-2.6.20:
status: Incomplete → Won't Fix
Revision history for this message
Swâmi Petaramesh (swami-petaramesh) wrote :

I'm currently working with 3 laptops and here's a short report :

- Asus EeePC, 512 MB RAM, 700 MB swap, EeeXUbuntu 3 (equiv. Gutsy with a 2.6.24 kernel) : Suspend to disk works out of the box.

- Dell XPS M1330, 2 GB RAM, 4 GB swap, Ubuntu Hardy latest 2.6.24-17-generic kernel: Suspend to disk works out of the box.

- Acer Aspire 3104WLMi, 1 GB RAM, 2 GB swap, Ubuntu Hardy latest 2.6.24-17-generic kernel: Suspend to disk fails with "swsusp: Not enough free memory"

=> On this machine, the proposed workaround: "echo 2048248 > /sys/power/image_size" immediately solved the issue and allowed suspend to disk to work (thanks).

Any idea about how to figure out the optimal value for this machine ?

(As an addition, on all these 3 machines, suspend to disk works with swap on an encrypted LVM)

Revision history for this message
Seano (seanodea) wrote :

A Compaq Presario with 1G ram and a 2G swap running 8.04 works with an image size of 5000000. Much higher than that and it may work for the first hibernate but repeated hibernates without a reboot may run out of memory. 5000000 is a small reduction so should not affect performance on return from hibernation.

Of course you'll have to put it in an init script because a reboot will set it back to the original and I see from the status above that it aint going to get fixed properly. Details are here http://ubuntuforums.org/archive/index.php/t-199952.html ( original link at the top of the thread is incorrect ).

Revision history for this message
Leann Ogasawara (leannogasawara) wrote :

The Ubuntu Kernel Team is planning to move to the 2.6.27 kernel for the upcoming Intrepid Ibex 8.10 release. As a result, the kernel team would appreciate it if you could please test this newer 2.6.27 Ubuntu kernel. There are one of two ways you should be able to test:

1) If you are comfortable installing packages on your own, the linux-image-2.6.27-* package is currently available for you to install and test.

--or--

2) The upcoming Alpha5 for Intrepid Ibex 8.10 will contain this newer 2.6.27 Ubuntu kernel. Alpha5 is set to be released Thursday Sept 4. Please watch http://www.ubuntu.com/testing for Alpha5 to be announced. You should then be able to test via a LiveCD.

Please let us know immediately if this newer 2.6.27 kernel resolves the bug reported here or if the issue remains. More importantly, please open a new bug report for each new bug/regression introduced by the 2.6.27 kernel and tag the bug report with 'linux-2.6.27'. Also, please specifically note if the issue does or does not appear in the 2.6.26 kernel. Thanks again, we really appreicate your help and feedback.

Revision history for this message
Alexander Hunziker (alex-hunziker) wrote :

This bug persists for me with kernel 2.7.27-7. Hibernating hangs, unless I execute

echo 2048248 > /sys/power/image_size

before I hibernate.

Revision history for this message
Eric Davis (ercdvs) wrote :

Interesting. Hibernation was working for me until I added the latest ati flgrx drivers, and then I started to see the same errors as the original poster.

Removing the xorg-driver-fglrx 2.6.17-3 driver results in me once again being able to hibernate on my Dell 1705 laptop.

uname -a :
Linux uberlaptop 2.6.27-7-generic #1 SMP Fri Oct 17 22:24:21 UTC 2008 i686 GNU/Linux

Looking at my image sizes pre and post driver , it looks like the output of cat /sys/power/image_size stayed the same at 524288000

but cat /proc/swaps changed by default to
/dev/sda5 partition 2377580 0 -1

I did not copy the old default value, but it was higher by default (similar again to the original poster)

Revision history for this message
Will Bickerstaff (willbickerstaff) wrote :

Also have his bug, as long as /sys/power/image_size is below 50% of total RAM then I can hibernate, as soon as this is set to 50% or higher then no bananas. So, keeping in mind (Yan Li 2008-01-31:) the optimal setting for functioning hibernate should be just below 50% of total RAM

Revision history for this message
Launchpad Janitor (janitor) wrote : Kernel team bugs

Per a decision made by the Ubuntu Kernel Team, bugs will longer be assigned to the ubuntu-kernel-team in Launchpad as part of the bug triage process. The ubuntu-kernel-team is being unassigned from this bug report. Refer to https://wiki.ubuntu.com/KernelTeamBugPolicies for more information. Thanks.

Revision history for this message
Philipp Wendler (philw85) wrote :

I can confirm that hibernation does not work with 1GB of RAM and the default setting of /sys/power/image_size. Setting the latter to 0 helps. The kernel documentation states that the kernel will then use the smallest possible value. I see no negative effects in this.
As todays computer probably mostly have >= 1GB RAM, IMHO the default value of this setting should be changed. What is necessary to let this happen? I am willing to provide additional information (logs etc.) if necessary.

Revision history for this message
Jeremy Foshee (jeremyfoshee) wrote :

This bug report was marked as Triaged a while ago but has not had any updated comments for quite some time. Please let us know if this issue remains in the current Ubuntu release, http://www.ubuntu.com/getubuntu/download . If the issue remains, click on the current status under the Status column and change the status back to "New". Thanks.

[This is an automated message. Apologies if it has reached you inappropriately; please just reply to this message indicating so.]

tags: added: kj-triage
Changed in linux (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
Philipp Wendler (philw85) wrote :

I tried it again with my notebook running Karmic and it worked fine.

Revision history for this message
Jeremy Foshee (jeremyfoshee) wrote :

Philipp,
    Thank you for following up. I am marking this bug Fix Released.

Thanks!

~JFo

Changed in linux (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
lopthopman (lopthopman-ann0) wrote :

Hi Jeremy- this issue still exists in Maverick / 10.10 / 2.6.35-22. /sys/power/image_size is still 500*1024*1024.

By "Fix Released", does this actually mean "workaround available" ?

Revision history for this message
Jānis Kangarooo (kangarooo) wrote :

i also cant hibernate
i get
black screen
something error Not enough free memory
something -12

comp has 1GB ram so installation it made 985mb or something like that
in System monitor ram is showed 1001.5 MiB

i used live cd Gparted to swapoff then make system size -neede mb but it took -1 mb more so all left was 1025mb for swap
that didnt help
then i made 2050 (couse again on making smalled it took 1 mb more off then i put)
that still didnt help.

so now free -m
             total used free shared buffers cached
Mem: 1001 819 182 0 63 318
-/+ buffers/cache: 437 564
Swap: 2049 0 2049

should i change it back to 1024 or exactly 1001 and wait for upgrade or some of here mentioned fixes?

Revision history for this message
Jānis Kangarooo (kangarooo) wrote :

cat /sys/power/image_size
524288000

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.