Skip to content

Commit a9c9b44

Browse files
committed
PM / Hibernate: Fix preallocating of memory
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> Cc: stable@kernel.org
1 parent f8bb0db commit a9c9b44

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/power/snapshot.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ static void free_unnecessary_pages(void)
11811181

11821182
memory_bm_position_reset(&copy_bm);
11831183

1184-
while (to_free_normal > 0 && to_free_highmem > 0) {
1184+
while (to_free_normal > 0 || to_free_highmem > 0) {
11851185
unsigned long pfn = memory_bm_next_pfn(&copy_bm);
11861186
struct page *page = pfn_to_page(pfn);
11871187

0 commit comments

Comments
 (0)