PM: hibernate: Add more logging on hibernation failure
Hibernation fails when the kernel cannot allocate enough memory to copy all pages of RAM in use. Ensure that the failure reason is clearly logged, and clearly attributable to the hibernation module. Signed-off-by: Luigi Semenzato <semenzato@google.com> [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
809ed78a83
commit
7a7b99bf80
@@ -8,7 +8,7 @@
|
||||
* Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "PM: " fmt
|
||||
#define pr_fmt(fmt) "PM: hibernation: " fmt
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/module.h>
|
||||
@@ -1703,16 +1703,20 @@ int hibernate_preallocate_memory(void)
|
||||
ktime_t start, stop;
|
||||
int error;
|
||||
|
||||
pr_info("Preallocating image memory... ");
|
||||
pr_info("Preallocating image memory\n");
|
||||
start = ktime_get();
|
||||
|
||||
error = memory_bm_create(&orig_bm, GFP_IMAGE, PG_ANY);
|
||||
if (error)
|
||||
if (error) {
|
||||
pr_err("Cannot allocate original bitmap\n");
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
error = memory_bm_create(©_bm, GFP_IMAGE, PG_ANY);
|
||||
if (error)
|
||||
if (error) {
|
||||
pr_err("Cannot allocate copy bitmap\n");
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
alloc_normal = 0;
|
||||
alloc_highmem = 0;
|
||||
@@ -1802,8 +1806,11 @@ int hibernate_preallocate_memory(void)
|
||||
alloc -= pages;
|
||||
pages += pages_highmem;
|
||||
pages_highmem = preallocate_image_highmem(alloc);
|
||||
if (pages_highmem < alloc)
|
||||
if (pages_highmem < alloc) {
|
||||
pr_err("Image allocation is %lu pages short\n",
|
||||
alloc - pages_highmem);
|
||||
goto err_out;
|
||||
}
|
||||
pages += pages_highmem;
|
||||
/*
|
||||
* size is the desired number of saveable pages to leave in
|
||||
@@ -1834,13 +1841,12 @@ int hibernate_preallocate_memory(void)
|
||||
|
||||
out:
|
||||
stop = ktime_get();
|
||||
pr_cont("done (allocated %lu pages)\n", pages);
|
||||
pr_info("Allocated %lu pages for shapshot\n", pages);
|
||||
swsusp_show_speed(start, stop, pages, "Allocated");
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
pr_cont("\n");
|
||||
swsusp_free();
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -1974,7 +1980,7 @@ asmlinkage __visible int swsusp_save(void)
|
||||
{
|
||||
unsigned int nr_pages, nr_highmem;
|
||||
|
||||
pr_info("Creating hibernation image:\n");
|
||||
pr_info("Creating image:\n");
|
||||
|
||||
drain_local_pages(NULL);
|
||||
nr_pages = count_data_pages();
|
||||
@@ -2008,7 +2014,7 @@ asmlinkage __visible int swsusp_save(void)
|
||||
nr_copy_pages = nr_pages;
|
||||
nr_meta_pages = DIV_ROUND_UP(nr_pages * sizeof(long), PAGE_SIZE);
|
||||
|
||||
pr_info("Hibernation image created (%d pages copied)\n", nr_pages);
|
||||
pr_info("Image created (%d pages copied)\n", nr_pages);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user