فهرست منبع

[PATCH] swsusp: fix nr_copy_pages

The following patch moves the recalculation of nr_copy_pages so that the right
number is used in the calculation of the size of memory and swap needed.

It prevents swsusp from attempting to suspend if there is not enough memory
and/or swap (which is unlikely anyway).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Pavel Machek 20 سال پیش
والد
کامیت
c61978b303
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      kernel/power/swsusp.c

+ 3 - 3
kernel/power/swsusp.c

@@ -781,18 +781,18 @@ static int swsusp_alloc(void)
 {
 {
 	int error;
 	int error;
 
 
+	pagedir_nosave = NULL;
+	nr_copy_pages = calc_nr(nr_copy_pages);
+
 	pr_debug("suspend: (pages needed: %d + %d free: %d)\n",
 	pr_debug("suspend: (pages needed: %d + %d free: %d)\n",
 		 nr_copy_pages, PAGES_FOR_IO, nr_free_pages());
 		 nr_copy_pages, PAGES_FOR_IO, nr_free_pages());
 
 
-	pagedir_nosave = NULL;
 	if (!enough_free_mem())
 	if (!enough_free_mem())
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	if (!enough_swap())
 	if (!enough_swap())
 		return -ENOSPC;
 		return -ENOSPC;
 
 
-	nr_copy_pages = calc_nr(nr_copy_pages);
-
 	if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) {
 	if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) {
 		printk(KERN_ERR "suspend: Allocating pagedir failed.\n");
 		printk(KERN_ERR "suspend: Allocating pagedir failed.\n");
 		return -ENOMEM;
 		return -ENOMEM;