Commit [671504]  Maximize  Restore  History

PM / Hibernate: Avoid hitting OOM during preallocation of memory

There is a problem in hibernate_preallocate_memory() that it calls
preallocate_image_memory() with an argument that may be greater than
the total number of available non-highmem memory pages. If that's
the case, the OOM condition is guaranteed to trigger, which in turn
can cause significant slowdown to occur during hibernation.

To avoid that, make preallocate_image_memory() adjust its argument
before calling preallocate_image_pages(), so that the total number of
saveable non-highem pages left is not less than the minimum size of
a hibernation image. Change hibernate_preallocate_memory() to try to
allocate from highmem if the number of pages allocated by
preallocate_image_memory() is too low.

Modify free_unnecessary_pages() to take all possible memory
allocation patterns into account.

Reported-by: KOSAKI Motohiro <>
Signed-off-by: Rafael J. Wysocki <>
Tested-by: M. Vefa Bicakci <>

Rafael J. Wysocki Rafael J. Wysocki 2010-09-11

changed kernel
changed kernel/power
changed kernel/power/snapshot.c
kernel/power/snapshot.c Diff Switch to side-by-side view