PM / Hibernate: Fix preallocating of memory
authorRafael J. Wysocki <rjw@sisk.pl>
Thu, 25 Feb 2010 21:32:37 +0000 (22:32 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 15 Mar 2010 15:49:46 +0000 (08:49 -0700)
commit7ec291833eb21e96fc62f58ce14076bf01d14e97
tree083b3dbc6223360a834f397c05fe7d754e073b92
parentb206354c4dcd2b50858c3ff0fd06d2c1588e66ba
PM / Hibernate: Fix preallocating of memory

commit a9c9b4429df437982d2fbfab1f4b46b01329e9ed upstream.

The hibernate memory preallocation code allocates memory to push some
user space data out of physical RAM, so that the hibernation image is
not too large.  It allocates more memory than necessary for creating
the image, so it has to release some pages to make room for
allocations made while suspending devices and disabling nonboot CPUs,
or the system will hang due to the lack of free pages to allocate
from.  Unfortunately, the function used for freeing these pages,
free_unnecessary_pages(), contains a bug that prevents it from doing
the job on all systems without highmem.

Fix this problem, which is a regression from the 2.6.30 kernel, by
using the right condition for the termination of the loop in
free_unnecessary_pages().

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-and-tested-by: Alan Jenkins <sourcejedi.lkml@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/power/snapshot.c