Skip to content

Commit

Permalink
PM / hibernate: exclude freed pages from allocated pages printout
Browse files Browse the repository at this point in the history
hibernate_preallocate_memory() prints out that how many pages are
allocated, but it doesn't take into consideration the pages freed by
free_unnecessary_pages(). Therefore, it always shows the count more
than actually allocated.

Signed-off-by: Wonhong Kwon <wonhong.kwon@lge.com>
[ rjw: Subject ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Wonhong Kwon authored and Rafael J. Wysocki committed Feb 3, 2015
1 parent c9257f7 commit a64fc82
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/power/snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,9 +1472,9 @@ static inline unsigned long preallocate_highmem_fraction(unsigned long nr_pages,
/**
* free_unnecessary_pages - Release preallocated pages not needed for the image
*/
static void free_unnecessary_pages(void)
static unsigned long free_unnecessary_pages(void)
{
unsigned long save, to_free_normal, to_free_highmem;
unsigned long save, to_free_normal, to_free_highmem, free;

save = count_data_pages();
if (alloc_normal >= save) {
Expand All @@ -1495,6 +1495,7 @@ static void free_unnecessary_pages(void)
else
to_free_normal = 0;
}
free = to_free_normal + to_free_highmem;

memory_bm_position_reset(&copy_bm);

Expand All @@ -1518,6 +1519,8 @@ static void free_unnecessary_pages(void)
swsusp_unset_page_free(page);
__free_page(page);
}

return free;
}

/**
Expand Down Expand Up @@ -1707,7 +1710,7 @@ int hibernate_preallocate_memory(void)
* pages in memory, but we have allocated more. Release the excessive
* ones now.
*/
free_unnecessary_pages();
pages -= free_unnecessary_pages();

out:
stop = ktime_get();
Expand Down

0 comments on commit a64fc82

Please sign in to comment.