diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-05-06 17:50:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:12:59 -0400 |
commit | d1d241cc2c5feec057c370aa71637380b1b945d5 (patch) | |
tree | 69c07d4c7a8b52b9ee6efba1511f3b4f8f79e6bb /kernel/power/user.c | |
parent | 726162b5dad154a90dad51c0185b891312de5757 (diff) |
swsusp: use rbtree for tracking allocated swap
Make swsusp use extents instead of a bitmap to trace swap pages allocated
for saving the image (the tracking is only needed in case there's an error,
so that the allocated swap pages can be released).
This should allow us to reduce the memory usage, practically always, and
improve performance.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Nigel Cunningham <nigel@nigel.suspend2.net>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/power/user.c')
-rw-r--r-- | kernel/power/user.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c index 72dbfd01408e..ad4e10208cde 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -33,7 +33,6 @@ | |||
33 | static struct snapshot_data { | 33 | static struct snapshot_data { |
34 | struct snapshot_handle handle; | 34 | struct snapshot_handle handle; |
35 | int swap; | 35 | int swap; |
36 | struct bitmap_page *bitmap; | ||
37 | int mode; | 36 | int mode; |
38 | char frozen; | 37 | char frozen; |
39 | char ready; | 38 | char ready; |
@@ -69,7 +68,6 @@ static int snapshot_open(struct inode *inode, struct file *filp) | |||
69 | data->swap = -1; | 68 | data->swap = -1; |
70 | data->mode = O_WRONLY; | 69 | data->mode = O_WRONLY; |
71 | } | 70 | } |
72 | data->bitmap = NULL; | ||
73 | data->frozen = 0; | 71 | data->frozen = 0; |
74 | data->ready = 0; | 72 | data->ready = 0; |
75 | data->platform_suspend = 0; | 73 | data->platform_suspend = 0; |
@@ -84,8 +82,7 @@ static int snapshot_release(struct inode *inode, struct file *filp) | |||
84 | swsusp_free(); | 82 | swsusp_free(); |
85 | free_basic_memory_bitmaps(); | 83 | free_basic_memory_bitmaps(); |
86 | data = filp->private_data; | 84 | data = filp->private_data; |
87 | free_all_swap_pages(data->swap, data->bitmap); | 85 | free_all_swap_pages(data->swap); |
88 | free_bitmap(data->bitmap); | ||
89 | if (data->frozen) { | 86 | if (data->frozen) { |
90 | mutex_lock(&pm_mutex); | 87 | mutex_lock(&pm_mutex); |
91 | thaw_processes(); | 88 | thaw_processes(); |
@@ -300,14 +297,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, | |||
300 | error = -ENODEV; | 297 | error = -ENODEV; |
301 | break; | 298 | break; |
302 | } | 299 | } |
303 | if (!data->bitmap) { | 300 | offset = alloc_swapdev_block(data->swap); |
304 | data->bitmap = alloc_bitmap(count_swap_pages(data->swap, 0)); | ||
305 | if (!data->bitmap) { | ||
306 | error = -ENOMEM; | ||
307 | break; | ||
308 | } | ||
309 | } | ||
310 | offset = alloc_swapdev_block(data->swap, data->bitmap); | ||
311 | if (offset) { | 301 | if (offset) { |
312 | offset <<= PAGE_SHIFT; | 302 | offset <<= PAGE_SHIFT; |
313 | error = put_user(offset, (sector_t __user *)arg); | 303 | error = put_user(offset, (sector_t __user *)arg); |
@@ -321,13 +311,11 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, | |||
321 | error = -ENODEV; | 311 | error = -ENODEV; |
322 | break; | 312 | break; |
323 | } | 313 | } |
324 | free_all_swap_pages(data->swap, data->bitmap); | 314 | free_all_swap_pages(data->swap); |
325 | free_bitmap(data->bitmap); | ||
326 | data->bitmap = NULL; | ||
327 | break; | 315 | break; |
328 | 316 | ||
329 | case SNAPSHOT_SET_SWAP_FILE: | 317 | case SNAPSHOT_SET_SWAP_FILE: |
330 | if (!data->bitmap) { | 318 | if (!swsusp_swap_in_use()) { |
331 | /* | 319 | /* |
332 | * User space encodes device types as two-byte values, | 320 | * User space encodes device types as two-byte values, |
333 | * so we need to recode them | 321 | * so we need to recode them |
@@ -426,7 +414,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, | |||
426 | break; | 414 | break; |
427 | 415 | ||
428 | case SNAPSHOT_SET_SWAP_AREA: | 416 | case SNAPSHOT_SET_SWAP_AREA: |
429 | if (data->bitmap) { | 417 | if (swsusp_swap_in_use()) { |
430 | error = -EPERM; | 418 | error = -EPERM; |
431 | } else { | 419 | } else { |
432 | struct resume_swap_area swap_area; | 420 | struct resume_swap_area swap_area; |