aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/swap.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2006-09-26 02:32:55 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 11:49:02 -0400
commit940864ddabdb180e02041c4dcd46ba6f9eee732f (patch)
treecee174e45717dce64f7108a1c74182e691c1c8c2 /kernel/power/swap.c
parentb788db79896ef2a5817b9395ad63573b254a6d93 (diff)
[PATCH] swsusp: Use memory bitmaps during resume
Make swsusp use memory bitmaps to store its internal information during the resume phase of the suspend-resume cycle. If the pfns of saveable pages are saved during the suspend phase instead of the kernel virtual addresses of these pages, we can use them during the resume phase directly to set the corresponding bits in a memory bitmap. Then, this bitmap is used to mark the page frames corresponding to the pages that were saveable before the suspend (aka "unsafe" page frames). Next, we allocate as many page frames as needed to store the entire suspend image and make sure that there will be some extra free "safe" page frames for the list of PBEs constructed later. Subsequently, the image is loaded and, if possible, the data loaded from it are written into their "original" page frames (ie. the ones they had occupied before the suspend). The image data that cannot be written into their "original" page frames are loaded into "safe" page frames and their "original" kernel virtual addresses, as well as the addresses of the "safe" pages containing their copies, are stored in a list of PBEs. Finally, the list of PBEs is used to copy the remaining image data into their "original" page frames (this is done atomically, by the architecture-dependent parts of swsusp). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power/swap.c')
-rw-r--r--kernel/power/swap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 8309d20b256..9b2ee5344de 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -331,8 +331,7 @@ static int enough_swap(unsigned int nr_pages)
331 unsigned int free_swap = count_swap_pages(root_swap, 1); 331 unsigned int free_swap = count_swap_pages(root_swap, 1);
332 332
333 pr_debug("swsusp: free swap pages: %u\n", free_swap); 333 pr_debug("swsusp: free swap pages: %u\n", free_swap);
334 return free_swap > (nr_pages + PAGES_FOR_IO + 334 return free_swap > nr_pages + PAGES_FOR_IO;
335 (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
336} 335}
337 336
338/** 337/**
@@ -547,6 +546,7 @@ static int load_image(struct swap_map_handle *handle,
547 error = err2; 546 error = err2;
548 if (!error) { 547 if (!error) {
549 printk("\b\b\b\bdone\n"); 548 printk("\b\b\b\bdone\n");
549 snapshot_free_unused_memory(snapshot);
550 if (!snapshot_image_loaded(snapshot)) 550 if (!snapshot_image_loaded(snapshot))
551 error = -ENODATA; 551 error = -ENODATA;
552 } 552 }