linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nigel Cunningham <nigel@tuxonice.net>
To: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Linux PM <linux-pm@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	TuxOnIce-devel <tuxonice-devel@tuxonice.net>
Subject: [PATCH 01/22] Record & display i/o speed post resume.
Date: Sat, 25 Sep 2010 14:16:43 +1000	[thread overview]
Message-ID: <1285388224-10012-2-git-send-email-nigel@tuxonice.net> (raw)
In-Reply-To: <1285388224-10012-1-git-send-email-nigel@tuxonice.net>

Record the speed at which the image is written and read, and
display it to the user post-resume.

Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
---
 kernel/power/hibernate.c |   11 ++++++++++-
 kernel/power/power.h     |    4 +++-
 kernel/power/swap.c      |   14 +++++++++++---
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 8dc31e0..8cd0bbc 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -211,7 +211,7 @@ static void platform_recover(int platform_mode)
  *	@msg -		introductory message to print
  */
 
-void swsusp_show_speed(struct timeval *start, struct timeval *stop,
+int swsusp_show_speed(struct timeval *start, struct timeval *stop,
 			unsigned nr_pages, char *msg)
 {
 	s64 elapsed_centisecs64;
@@ -230,6 +230,7 @@ void swsusp_show_speed(struct timeval *start, struct timeval *stop,
 			msg, k,
 			centisecs / 100, centisecs % 100,
 			kps / 1000, (kps % 1000) / 10);
+	return kps / 1000;
 }
 
 /**
@@ -645,6 +646,14 @@ int hibernate(void)
 			power_down();
 	} else {
 		pr_debug("PM: Image restored successfully.\n");
+		if (write_speed)
+			pr_debug("PM: Image written at %u MB/s.\n",
+					(u8) write_speed);
+		write_speed = 0;
+		if (read_speed)
+			pr_debug("PM: Image read at %u MB/s.\n",
+					(u8) read_speed);
+		read_speed = 0;
 	}
 
  Thaw:
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 006270f..67b6896 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -49,6 +49,8 @@ static inline char *check_image_kernel(struct swsusp_info *info)
 extern int hibernation_snapshot(int platform_mode);
 extern int hibernation_restore(int platform_mode);
 extern int hibernation_platform_enter(void);
+
+extern char __nosavedata write_speed, read_speed;
 #endif
 
 extern int pfn_is_nosave(unsigned long);
@@ -153,7 +155,7 @@ extern int hib_wait_on_bio_chain(struct bio **bio_chain);
 
 struct timeval;
 /* kernel/power/swsusp.c */
-extern void swsusp_show_speed(struct timeval *, struct timeval *,
+extern int swsusp_show_speed(struct timeval *, struct timeval *,
 				unsigned int, char *);
 
 #ifdef CONFIG_SUSPEND
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index e6a5bdf..728f85b 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -64,7 +64,8 @@ struct swap_map_handle {
 };
 
 struct swsusp_header {
-	char reserved[PAGE_SIZE - 20 - sizeof(sector_t) - sizeof(int)];
+	char reserved[PAGE_SIZE - 21 - sizeof(sector_t) - sizeof(int)];
+	char write_speed;
 	sector_t image;
 	unsigned int flags;	/* Flags to pass to the "boot" kernel */
 	char	orig_sig[10];
@@ -180,6 +181,7 @@ int swsusp_swap_in_use(void)
 
 static unsigned short root_swap = 0xffff;
 struct block_device *hib_resume_bdev;
+char __nosavedata write_speed, read_speed;
 
 /*
  * Saving part
@@ -194,6 +196,7 @@ static int mark_swapfiles(struct swap_map_handle *handle, unsigned int flags)
 	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
 		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);
 		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);
+		swsusp_header->write_speed = write_speed;
 		swsusp_header->image = handle->first_sector;
 		swsusp_header->flags = flags;
 		error = hib_bio_write_page(swsusp_resume_block,
@@ -372,6 +375,7 @@ static int save_image(struct swap_map_handle *handle,
 	struct bio *bio;
 	struct timeval start;
 	struct timeval stop;
+	int mps;
 
 	printk(KERN_INFO "PM: Saving image data pages (%u pages) ...     ",
 		nr_to_write);
@@ -400,7 +404,8 @@ static int save_image(struct swap_map_handle *handle,
 		printk(KERN_CONT "\b\b\b\bdone\n");
 	else
 		printk(KERN_CONT "\n");
-	swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
+	mps = swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
+	write_speed = (mps < 256) ? (char) mps : 0;
 	return ret;
 }
 
@@ -550,6 +555,7 @@ static int load_image(struct swap_map_handle *handle,
 	struct bio *bio;
 	int err2;
 	unsigned nr_pages;
+	int mps;
 
 	printk(KERN_INFO "PM: Loading image data pages (%u pages) ...     ",
 		nr_to_read);
@@ -585,7 +591,8 @@ static int load_image(struct swap_map_handle *handle,
 			error = -ENODATA;
 	} else
 		printk("\n");
-	swsusp_show_speed(&start, &stop, nr_to_read, "Read");
+	mps = swsusp_show_speed(&start, &stop, nr_to_read, "Read");
+	read_speed = (mps < 256) ? mps : 0;
 	return error;
 }
 
@@ -641,6 +648,7 @@ int swsusp_check(void)
 			goto put;
 
 		if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
+			write_speed = swsusp_header->write_speed;
 			memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
 			/* Reset swap signature now */
 			error = hib_bio_write_page(swsusp_resume_block,
-- 
1.7.0.4


  reply	other threads:[~2010-09-25  4:17 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-25  4:16 Nigel's current for-rafael queue Nigel Cunningham
2010-09-25  4:16 ` Nigel Cunningham [this message]
2010-09-25  4:16 ` [PATCH 02/22] Hibernation: Swap iteration functions Nigel Cunningham
2010-09-25  4:16 ` [PATCH 03/22] Hibernation: Move root_swap declaration Nigel Cunningham
2010-09-25  4:16 ` [PATCH 04/22] Hibernation: Add mass swap allocation routine Nigel Cunningham
2010-09-25  4:16 ` [PATCH 05/22] Hibernation: Switch to preallocating swap Nigel Cunningham
2010-09-25 21:24   ` Rafael J. Wysocki
2010-09-25 21:32     ` Nigel Cunningham
2010-09-25 22:22       ` Rafael J. Wysocki
2010-09-25  4:16 ` [PATCH 06/22] Hiberation: Fix speed display Nigel Cunningham
2010-09-25  4:16 ` [PATCH 07/22] Hibernation: Generic extents support Nigel Cunningham
2010-09-25  4:16 ` [PATCH 08/22] Hibernation: Iterate over sectors not swap entries Nigel Cunningham
2010-09-25  4:16 ` [PATCH 09/22] Hibernation: Stop passing swap_map_handle struct Nigel Cunningham
2010-09-25  4:16 ` [PATCH 10/22] Hibernation: Stop passing bio_chain around Nigel Cunningham
2010-09-25  4:16 ` [PATCH 11/22] Hibernation: Move block i/o fns to block_io.c Nigel Cunningham
2010-09-25  4:16 ` [PATCH 12/22] Hibernation: Partial page I/O support Nigel Cunningham
2010-09-25  4:16 ` [PATCH 13/22] Hibernation: Extent save/load routines Nigel Cunningham
2010-09-25 22:12   ` Rafael J. Wysocki
2010-09-25  4:16 ` [PATCH 14/22] Hibernation: Store block extents at start of image Nigel Cunningham
2010-09-25  4:16 ` [PATCH 15/22] Hibernation: Use block extents for reading image Nigel Cunningham
2010-09-25  4:16 ` [PATCH 16/22] Remove first_sector from swap_map_handle Nigel Cunningham
2010-09-25  4:16 ` [PATCH 17/22] Hibernation: Replace bio chain Nigel Cunningham
2010-09-25  4:17 ` [PATCH 18/22] Hibernation: Remove swap_map_pages Nigel Cunningham
2010-09-25  4:17 ` [PATCH 19/22] Hibernation: Remove wait_on_bio_chain result Nigel Cunningham
2010-09-25  4:17 ` [PATCH 20/22] Hibernation: Prepare for handle.cur removal Nigel Cunningham
2010-09-25  4:17 ` [PATCH 21/22] Hibernation: Remove swap_map structure Nigel Cunningham
2010-09-25  4:17 ` [PATCH 22/22] Hibernation: Remove now-empty routines Nigel Cunningham
2010-09-25 15:04 ` [linux-pm] Nigel's current for-rafael queue Martin Steigerwald
2010-09-25 21:21   ` Nigel Cunningham
2010-09-25 22:19 ` Rafael J. Wysocki
2010-09-25 22:33   ` Nigel Cunningham
2010-09-25 22:36     ` Rafael J. Wysocki
2010-09-28 10:34 ` [TuxOnIce-devel] " Martin Steigerwald
2010-09-30  7:52   ` unable to handle paging request at resume (was: Re: [TuxOnIce-devel] Nigel's current for-rafael queue) Martin Steigerwald
2010-10-02 16:51     ` [linux-pm] " Martin Steigerwald
2010-09-28 19:45 ` [TuxOnIce-devel] Nigel's current for-rafael queue Martin Steigerwald
2010-09-28 21:25   ` Nigel Cunningham
2010-09-30  7:56     ` Martin Steigerwald

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=1285388224-10012-2-git-send-email-nigel@tuxonice.net \
    --to=nigel@tuxonice.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=rjw@sisk.pl \
    --cc=tuxonice-devel@tuxonice.net \
    /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;
as well as URLs for NNTP newsgroup(s).