Linux Power Management development
 help / color / mirror / Atom feed
From: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,  Pavel Machek <pavel@kernel.org>
Cc: "Brian Geffon" <bgeffon@google.com>,
	kernel@collabora.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Nícolas F. R. A. Prado" <nfraprado@collabora.com>
Subject: [PATCH 1/3] PM: hibernate: Print speed statistics of copy_data_pages()
Date: Mon, 18 May 2026 17:34:22 -0400	[thread overview]
Message-ID: <20260518-hibernation-decrease-time-in-copy-data-pages-v1-1-3998bdf90ee5@collabora.com> (raw)
In-Reply-To: <20260518-hibernation-decrease-time-in-copy-data-pages-v1-0-3998bdf90ee5@collabora.com>

copy_data_pages() can take a long (multi-second) time to finish, and
currently the only indication of that is the timestamp difference
between print messages right before and right after. The timestamp is
also immediately reset afterwards to the time before image creation,
making it even harder to spot this delay. And this function runs in a
critical section with a single CPU online and syscore suspended, so it
should be kept as quick as possible to keep the system responsive.

Call into swsusp_show_speed() to report the amount of data, time taken,
and copy speed of copy_data_pages() to make it easier to spot delays and
verify performance improvements. The current time is obtained through
sched_clock() instead of ktime_get() since timekeeping is suspended in
this region.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 kernel/power/snapshot.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index e249e5786fbc..4f452baf31dc 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -13,6 +13,7 @@
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/sched/clock.h>
 #include <linux/suspend.h>
 #include <linux/delay.h>
 #include <linux/bitops.h>
@@ -2109,6 +2110,7 @@ static int swsusp_alloc(struct memory_bitmap *copy_bm,
 asmlinkage __visible int swsusp_save(void)
 {
 	unsigned int nr_pages, nr_highmem;
+	ktime_t start, stop;
 
 	pr_info("Creating image:\n");
 
@@ -2132,7 +2134,10 @@ asmlinkage __visible int swsusp_save(void)
 	 * Kill them.
 	 */
 	drain_local_pages(NULL);
+	start = ns_to_ktime(sched_clock());
 	nr_copy_pages = copy_data_pages(&copy_bm, &orig_bm, &zero_bm);
+	stop = ns_to_ktime(sched_clock());
+	swsusp_show_speed(start, stop, nr_copy_pages, "Copied");
 
 	/*
 	 * End of critical section. From now on, we can write to memory,

-- 
2.53.0


  reply	other threads:[~2026-05-18 21:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 21:34 [PATCH 0/3] Shrink time spent in copy_data_pages() Nícolas F. R. A. Prado
2026-05-18 21:34 ` Nícolas F. R. A. Prado [this message]
2026-05-18 21:34 ` [PATCH 2/3] PM: hibernate: Add platform_enter hibernation test level Nícolas F. R. A. Prado
2026-05-18 21:34 ` [PATCH 3/3] PM: hibernate: Allow disabling zero page check in copy_data_pages() Nícolas F. R. A. Prado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260518-hibernation-decrease-time-in-copy-data-pages-v1-1-3998bdf90ee5@collabora.com \
    --to=nfraprado@collabora.com \
    --cc=bgeffon@google.com \
    --cc=kernel@collabora.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox