Patchwork [1/2] PM / Hibernate: Improve comments in hibernate_preallocate_memory()

login
register
mail settings
Submitter Manoj Iyer
Date March 18, 2011, 4:25 p.m.
Message ID <1300465546-4137-2-git-send-email-manoj.iyer@canonical.com>
Download mbox | patch
Permalink /patch/87551/
State New
Headers show

Comments

Manoj Iyer - March 18, 2011, 4:25 p.m.
From: Rafael J. Wysocki <rjw@sisk.pl>

One comment in hibernate_preallocate_memory() is wrong, so fix it and
add one more comment to clarify the meaning of the fixed one.

BugLink: http://launchpad.net/bugs/737208

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
(cherry picked from commit 266f1a25eff5ff98c498d7754a419aacfd88f71c)

Signed-off-by: Manoj Iyer <manoj.iyer@canonical.com>
---
 kernel/power/snapshot.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Stefan Bader - March 21, 2011, 10:34 a.m.
On 03/18/2011 05:25 PM, Manoj Iyer wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
> 
> One comment in hibernate_preallocate_memory() is wrong, so fix it and
> add one more comment to clarify the meaning of the fixed one.
> 
> BugLink: http://launchpad.net/bugs/737208
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> (cherry picked from commit 266f1a25eff5ff98c498d7754a419aacfd88f71c)
> 
> Signed-off-by: Manoj Iyer <manoj.iyer@canonical.com>
> ---
>  kernel/power/snapshot.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
> index 7fa52b5..703a057 100644
> --- a/kernel/power/snapshot.c
> +++ b/kernel/power/snapshot.c
> @@ -1318,12 +1318,14 @@ int hibernate_preallocate_memory(void)
>  
>  	/* Compute the maximum number of saveable pages to leave in memory. */
>  	max_size = (count - (size + PAGES_FOR_IO)) / 2 - 2 * SPARE_PAGES;
> +	/* Compute the desired number of image pages specified by image_size. */
>  	size = DIV_ROUND_UP(image_size, PAGE_SIZE);
>  	if (size > max_size)
>  		size = max_size;
>  	/*
> -	 * If the maximum is not less than the current number of saveable pages
> -	 * in memory, allocate page frames for the image and we're done.
> +	 * If the desired number of image pages is at least as large as the
> +	 * current number of saveable pages in memory, allocate page frames for
> +	 * the image and we're done.
>  	 */
>  	if (size >= saveable) {
>  		pages = preallocate_image_highmem(save_highmem);

Cannot do any harm, so

Acked-by: Stefan Bader <stefan.bader@canonical.com>

Patch

diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 7fa52b5..703a057 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1318,12 +1318,14 @@  int hibernate_preallocate_memory(void)
 
 	/* Compute the maximum number of saveable pages to leave in memory. */
 	max_size = (count - (size + PAGES_FOR_IO)) / 2 - 2 * SPARE_PAGES;
+	/* Compute the desired number of image pages specified by image_size. */
 	size = DIV_ROUND_UP(image_size, PAGE_SIZE);
 	if (size > max_size)
 		size = max_size;
 	/*
-	 * If the maximum is not less than the current number of saveable pages
-	 * in memory, allocate page frames for the image and we're done.
+	 * If the desired number of image pages is at least as large as the
+	 * current number of saveable pages in memory, allocate page frames for
+	 * the image and we're done.
 	 */
 	if (size >= saveable) {
 		pages = preallocate_image_highmem(save_highmem);