diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2010-08-09 20:20:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-09 23:45:04 -0400 |
commit | d2997b1042ec150616c1963b5e5e919ffd0b0ebf (patch) | |
tree | c970746ad3d5c3e0ccbd1695d07144dbe4534ec4 /include/linux/swap.h | |
parent | 966cca029f739716fbcc8068b8c6dfe381f86fc3 (diff) |
hibernation: freeze swap at hibernation
When taking a memory snapshot in hibernate_snapshot(), all (directly
called) memory allocations use GFP_ATOMIC. Hence swap misusage during
hibernation never occurs.
But from a pessimistic point of view, there is no guarantee that no page
allcation has __GFP_WAIT. It is better to have a global indication "we
enter hibernation, don't use swap!".
This patch tries to freeze new-swap-allocation during hibernation. (All
user processes are frozenm so swapin is not a concern).
This way, no updates will happen to swap_map[] between
hibernate_snapshot() and save_image(). Swap is thawed when swsusp_free()
is called. We can be assured that swap corruption will not occur.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Hugh Dickins <hughd@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Ondrej Zary <linux@rainbow-software.org>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/swap.h')
-rw-r--r-- | include/linux/swap.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index ff4acea9bbdb..91c9d3fc8513 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -316,7 +316,6 @@ extern long nr_swap_pages; | |||
316 | extern long total_swap_pages; | 316 | extern long total_swap_pages; |
317 | extern void si_swapinfo(struct sysinfo *); | 317 | extern void si_swapinfo(struct sysinfo *); |
318 | extern swp_entry_t get_swap_page(void); | 318 | extern swp_entry_t get_swap_page(void); |
319 | extern swp_entry_t get_swap_page_of_type(int); | ||
320 | extern int valid_swaphandles(swp_entry_t, unsigned long *); | 319 | extern int valid_swaphandles(swp_entry_t, unsigned long *); |
321 | extern int add_swap_count_continuation(swp_entry_t, gfp_t); | 320 | extern int add_swap_count_continuation(swp_entry_t, gfp_t); |
322 | extern void swap_shmem_alloc(swp_entry_t); | 321 | extern void swap_shmem_alloc(swp_entry_t); |
@@ -333,6 +332,13 @@ extern int reuse_swap_page(struct page *); | |||
333 | extern int try_to_free_swap(struct page *); | 332 | extern int try_to_free_swap(struct page *); |
334 | struct backing_dev_info; | 333 | struct backing_dev_info; |
335 | 334 | ||
335 | #ifdef CONFIG_HIBERNATION | ||
336 | void hibernation_freeze_swap(void); | ||
337 | void hibernation_thaw_swap(void); | ||
338 | swp_entry_t get_swap_for_hibernation(int type); | ||
339 | void swap_free_for_hibernation(swp_entry_t val); | ||
340 | #endif | ||
341 | |||
336 | /* linux/mm/thrash.c */ | 342 | /* linux/mm/thrash.c */ |
337 | extern struct mm_struct *swap_token_mm; | 343 | extern struct mm_struct *swap_token_mm; |
338 | extern void grab_swap_token(struct mm_struct *); | 344 | extern void grab_swap_token(struct mm_struct *); |