]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PM: hibernate: Rework message printing in swsusp_save()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 9 Oct 2025 19:34:16 +0000 (21:34 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 20 Oct 2025 18:43:09 +0000 (20:43 +0200)
The messages printed by swsusp_save() are basically only useful for
debug, so printing them every time a hibernation image is created at
the "info" log level is not particularly useful.  Also printing a
message on a failing memory allocation is redundant.

Use pm_deferred_pr_dbg() for printing those messages so they will only
be printed when requested and the "deferred" variant is used because
this code runs in a deeply atomic context (one CPU with interrupts
off, no functional devices).  Also drop the useless message printed
when memory allocations fails.

While at it, extend one of the messages in question so it is less
cryptic.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ rjw: Dropped a useless colon at the end of one of the messages ]
Link: https://patch.msgid.link/10750389.nUPlyArG6x@rafael.j.wysocki
kernel/power/snapshot.c

index 645f42e404789286ffa751f083e97e52a4e4cf7e..0a946932d5c17d3d7102f012c24ff24669003bb8 100644 (file)
@@ -2110,22 +2110,20 @@ asmlinkage __visible int swsusp_save(void)
 {
        unsigned int nr_pages, nr_highmem;
 
-       pr_info("Creating image:\n");
+       pm_deferred_pr_dbg("Creating image\n");
 
        drain_local_pages(NULL);
        nr_pages = count_data_pages();
        nr_highmem = count_highmem_pages();
-       pr_info("Need to copy %u pages\n", nr_pages + nr_highmem);
+       pm_deferred_pr_dbg("Need to copy %u pages\n", nr_pages + nr_highmem);
 
        if (!enough_free_mem(nr_pages, nr_highmem)) {
-               pr_err("Not enough free memory\n");
+               pm_deferred_pr_dbg("Not enough free memory for image creation\n");
                return -ENOMEM;
        }
 
-       if (swsusp_alloc(&copy_bm, nr_pages, nr_highmem)) {
-               pr_err("Memory allocation failed\n");
+       if (swsusp_alloc(&copy_bm, nr_pages, nr_highmem))
                return -ENOMEM;
-       }
 
        /*
         * During allocating of suspend pagedir, new cold pages may appear.
@@ -2144,7 +2142,8 @@ asmlinkage __visible int swsusp_save(void)
        nr_zero_pages = nr_pages - nr_copy_pages;
        nr_meta_pages = DIV_ROUND_UP(nr_pages * sizeof(long), PAGE_SIZE);
 
-       pr_info("Image created (%d pages copied, %d zero pages)\n", nr_copy_pages, nr_zero_pages);
+       pm_deferred_pr_dbg("Image created (%d pages copied, %d zero pages)\n",
+                          nr_copy_pages, nr_zero_pages);
 
        return 0;
 }