diff options
Diffstat (limited to 'kernel/power/snapshot.c')
-rw-r--r-- | kernel/power/snapshot.c | 93 |
1 files changed, 42 insertions, 51 deletions
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 94b6fe6c9ae3..1fe0ddb6fd0d 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -186,8 +186,8 @@ static inline void free_image_page(void *addr, int clear_nosave_free) | |||
186 | __free_page(page); | 186 | __free_page(page); |
187 | } | 187 | } |
188 | 188 | ||
189 | static inline void | 189 | static inline void free_list_of_pages(struct linked_page *list, |
190 | free_list_of_pages(struct linked_page *list, int clear_page_nosave) | 190 | int clear_page_nosave) |
191 | { | 191 | { |
192 | while (list) { | 192 | while (list) { |
193 | struct linked_page *lp = list->next; | 193 | struct linked_page *lp = list->next; |
@@ -219,8 +219,8 @@ struct chain_allocator { | |||
219 | int safe_needed; /* if set, only "safe" pages are allocated */ | 219 | int safe_needed; /* if set, only "safe" pages are allocated */ |
220 | }; | 220 | }; |
221 | 221 | ||
222 | static void | 222 | static void chain_init(struct chain_allocator *ca, gfp_t gfp_mask, |
223 | chain_init(struct chain_allocator *ca, gfp_t gfp_mask, int safe_needed) | 223 | int safe_needed) |
224 | { | 224 | { |
225 | ca->chain = NULL; | 225 | ca->chain = NULL; |
226 | ca->used_space = LINKED_PAGE_DATA_SIZE; | 226 | ca->used_space = LINKED_PAGE_DATA_SIZE; |
@@ -452,10 +452,11 @@ static void free_zone_bm_rtree(struct mem_zone_bm_rtree *zone, | |||
452 | * This function also allocated and builds the radix tree for the | 452 | * This function also allocated and builds the radix tree for the |
453 | * zone. | 453 | * zone. |
454 | */ | 454 | */ |
455 | static struct mem_zone_bm_rtree * | 455 | static struct mem_zone_bm_rtree *create_zone_bm_rtree(gfp_t gfp_mask, |
456 | create_zone_bm_rtree(gfp_t gfp_mask, int safe_needed, | 456 | int safe_needed, |
457 | struct chain_allocator *ca, | 457 | struct chain_allocator *ca, |
458 | unsigned long start, unsigned long end) | 458 | unsigned long start, |
459 | unsigned long end) | ||
459 | { | 460 | { |
460 | struct mem_zone_bm_rtree *zone; | 461 | struct mem_zone_bm_rtree *zone; |
461 | unsigned int i, nr_blocks; | 462 | unsigned int i, nr_blocks; |
@@ -595,8 +596,8 @@ static int create_mem_extents(struct list_head *list, gfp_t gfp_mask) | |||
595 | /** | 596 | /** |
596 | * memory_bm_create - allocate memory for a memory bitmap | 597 | * memory_bm_create - allocate memory for a memory bitmap |
597 | */ | 598 | */ |
598 | static int | 599 | static int memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, |
599 | memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed) | 600 | int safe_needed) |
600 | { | 601 | { |
601 | struct chain_allocator ca; | 602 | struct chain_allocator ca; |
602 | struct list_head mem_extents; | 603 | struct list_head mem_extents; |
@@ -894,9 +895,8 @@ static void memory_bm_recycle(struct memory_bitmap *bm) | |||
894 | * initialization code) | 895 | * initialization code) |
895 | */ | 896 | */ |
896 | 897 | ||
897 | void __init | 898 | void __init __register_nosave_region(unsigned long start_pfn, |
898 | __register_nosave_region(unsigned long start_pfn, unsigned long end_pfn, | 899 | unsigned long end_pfn, int use_kmalloc) |
899 | int use_kmalloc) | ||
900 | { | 900 | { |
901 | struct nosave_region *region; | 901 | struct nosave_region *region; |
902 | 902 | ||
@@ -1277,8 +1277,7 @@ static void safe_copy_page(void *dst, struct page *s_page) | |||
1277 | 1277 | ||
1278 | 1278 | ||
1279 | #ifdef CONFIG_HIGHMEM | 1279 | #ifdef CONFIG_HIGHMEM |
1280 | static inline struct page * | 1280 | static inline struct page *page_is_saveable(struct zone *zone, unsigned long pfn) |
1281 | page_is_saveable(struct zone *zone, unsigned long pfn) | ||
1282 | { | 1281 | { |
1283 | return is_highmem(zone) ? | 1282 | return is_highmem(zone) ? |
1284 | saveable_highmem_page(zone, pfn) : saveable_page(zone, pfn); | 1283 | saveable_highmem_page(zone, pfn) : saveable_page(zone, pfn); |
@@ -1321,8 +1320,8 @@ static inline void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn) | |||
1321 | } | 1320 | } |
1322 | #endif /* CONFIG_HIGHMEM */ | 1321 | #endif /* CONFIG_HIGHMEM */ |
1323 | 1322 | ||
1324 | static void | 1323 | static void copy_data_pages(struct memory_bitmap *copy_bm, |
1325 | copy_data_pages(struct memory_bitmap *copy_bm, struct memory_bitmap *orig_bm) | 1324 | struct memory_bitmap *orig_bm) |
1326 | { | 1325 | { |
1327 | struct zone *zone; | 1326 | struct zone *zone; |
1328 | unsigned long pfn; | 1327 | unsigned long pfn; |
@@ -1485,8 +1484,8 @@ static unsigned long __fraction(u64 x, u64 multiplier, u64 base) | |||
1485 | } | 1484 | } |
1486 | 1485 | ||
1487 | static unsigned long preallocate_highmem_fraction(unsigned long nr_pages, | 1486 | static unsigned long preallocate_highmem_fraction(unsigned long nr_pages, |
1488 | unsigned long highmem, | 1487 | unsigned long highmem, |
1489 | unsigned long total) | 1488 | unsigned long total) |
1490 | { | 1489 | { |
1491 | unsigned long alloc = __fraction(nr_pages, highmem, total); | 1490 | unsigned long alloc = __fraction(nr_pages, highmem, total); |
1492 | 1491 | ||
@@ -1499,8 +1498,8 @@ static inline unsigned long preallocate_image_highmem(unsigned long nr_pages) | |||
1499 | } | 1498 | } |
1500 | 1499 | ||
1501 | static inline unsigned long preallocate_highmem_fraction(unsigned long nr_pages, | 1500 | static inline unsigned long preallocate_highmem_fraction(unsigned long nr_pages, |
1502 | unsigned long highmem, | 1501 | unsigned long highmem, |
1503 | unsigned long total) | 1502 | unsigned long total) |
1504 | { | 1503 | { |
1505 | return 0; | 1504 | return 0; |
1506 | } | 1505 | } |
@@ -1780,8 +1779,7 @@ static unsigned int count_pages_for_highmem(unsigned int nr_highmem) | |||
1780 | return nr_highmem; | 1779 | return nr_highmem; |
1781 | } | 1780 | } |
1782 | #else | 1781 | #else |
1783 | static unsigned int | 1782 | static unsigned int count_pages_for_highmem(unsigned int nr_highmem) { return 0; } |
1784 | count_pages_for_highmem(unsigned int nr_highmem) { return 0; } | ||
1785 | #endif /* CONFIG_HIGHMEM */ | 1783 | #endif /* CONFIG_HIGHMEM */ |
1786 | 1784 | ||
1787 | /** | 1785 | /** |
@@ -1823,8 +1821,8 @@ static inline int get_highmem_buffer(int safe_needed) | |||
1823 | * highmem pages is lesser than that, allocate them all. | 1821 | * highmem pages is lesser than that, allocate them all. |
1824 | */ | 1822 | */ |
1825 | 1823 | ||
1826 | static inline unsigned int | 1824 | static inline unsigned int alloc_highmem_pages(struct memory_bitmap *bm, |
1827 | alloc_highmem_pages(struct memory_bitmap *bm, unsigned int nr_highmem) | 1825 | unsigned int nr_highmem) |
1828 | { | 1826 | { |
1829 | unsigned int to_alloc = count_free_highmem_pages(); | 1827 | unsigned int to_alloc = count_free_highmem_pages(); |
1830 | 1828 | ||
@@ -1843,8 +1841,8 @@ alloc_highmem_pages(struct memory_bitmap *bm, unsigned int nr_highmem) | |||
1843 | #else | 1841 | #else |
1844 | static inline int get_highmem_buffer(int safe_needed) { return 0; } | 1842 | static inline int get_highmem_buffer(int safe_needed) { return 0; } |
1845 | 1843 | ||
1846 | static inline unsigned int | 1844 | static inline unsigned int alloc_highmem_pages(struct memory_bitmap *bm, |
1847 | alloc_highmem_pages(struct memory_bitmap *bm, unsigned int n) { return 0; } | 1845 | unsigned int n) { return 0; } |
1848 | #endif /* CONFIG_HIGHMEM */ | 1846 | #endif /* CONFIG_HIGHMEM */ |
1849 | 1847 | ||
1850 | /** | 1848 | /** |
@@ -1859,9 +1857,9 @@ alloc_highmem_pages(struct memory_bitmap *bm, unsigned int n) { return 0; } | |||
1859 | * copy_data_pages() works. | 1857 | * copy_data_pages() works. |
1860 | */ | 1858 | */ |
1861 | 1859 | ||
1862 | static int | 1860 | static int swsusp_alloc(struct memory_bitmap *orig_bm, |
1863 | swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm, | 1861 | struct memory_bitmap *copy_bm, |
1864 | unsigned int nr_pages, unsigned int nr_highmem) | 1862 | unsigned int nr_pages, unsigned int nr_highmem) |
1865 | { | 1863 | { |
1866 | if (nr_highmem > 0) { | 1864 | if (nr_highmem > 0) { |
1867 | if (get_highmem_buffer(PG_ANY)) | 1865 | if (get_highmem_buffer(PG_ANY)) |
@@ -1978,8 +1976,7 @@ static int init_header(struct swsusp_info *info) | |||
1978 | * are stored in the array @buf[] (1 page at a time) | 1976 | * are stored in the array @buf[] (1 page at a time) |
1979 | */ | 1977 | */ |
1980 | 1978 | ||
1981 | static inline void | 1979 | static inline void pack_pfns(unsigned long *buf, struct memory_bitmap *bm) |
1982 | pack_pfns(unsigned long *buf, struct memory_bitmap *bm) | ||
1983 | { | 1980 | { |
1984 | int j; | 1981 | int j; |
1985 | 1982 | ||
@@ -2110,8 +2107,7 @@ static int check_header(struct swsusp_info *info) | |||
2110 | * load header - check the image header and copy data from it | 2107 | * load header - check the image header and copy data from it |
2111 | */ | 2108 | */ |
2112 | 2109 | ||
2113 | static int | 2110 | static int load_header(struct swsusp_info *info) |
2114 | load_header(struct swsusp_info *info) | ||
2115 | { | 2111 | { |
2116 | int error; | 2112 | int error; |
2117 | 2113 | ||
@@ -2204,8 +2200,8 @@ static unsigned int safe_highmem_pages; | |||
2204 | 2200 | ||
2205 | static struct memory_bitmap *safe_highmem_bm; | 2201 | static struct memory_bitmap *safe_highmem_bm; |
2206 | 2202 | ||
2207 | static int | 2203 | static int prepare_highmem_image(struct memory_bitmap *bm, |
2208 | prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p) | 2204 | unsigned int *nr_highmem_p) |
2209 | { | 2205 | { |
2210 | unsigned int to_alloc; | 2206 | unsigned int to_alloc; |
2211 | 2207 | ||
@@ -2259,8 +2255,8 @@ prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p) | |||
2259 | 2255 | ||
2260 | static struct page *last_highmem_page; | 2256 | static struct page *last_highmem_page; |
2261 | 2257 | ||
2262 | static void * | 2258 | static void *get_highmem_page_buffer(struct page *page, |
2263 | get_highmem_page_buffer(struct page *page, struct chain_allocator *ca) | 2259 | struct chain_allocator *ca) |
2264 | { | 2260 | { |
2265 | struct highmem_pbe *pbe; | 2261 | struct highmem_pbe *pbe; |
2266 | void *kaddr; | 2262 | void *kaddr; |
@@ -2333,17 +2329,13 @@ static inline void free_highmem_data(void) | |||
2333 | free_image_page(buffer, PG_UNSAFE_CLEAR); | 2329 | free_image_page(buffer, PG_UNSAFE_CLEAR); |
2334 | } | 2330 | } |
2335 | #else | 2331 | #else |
2336 | static unsigned int | 2332 | static unsigned int count_highmem_image_pages(struct memory_bitmap *bm) { return 0; } |
2337 | count_highmem_image_pages(struct memory_bitmap *bm) { return 0; } | ||
2338 | 2333 | ||
2339 | static inline int | 2334 | static inline int prepare_highmem_image(struct memory_bitmap *bm, |
2340 | prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p) | 2335 | unsigned int *nr_highmem_p) { return 0; } |
2341 | { | ||
2342 | return 0; | ||
2343 | } | ||
2344 | 2336 | ||
2345 | static inline void * | 2337 | static inline void *get_highmem_page_buffer(struct page *page, |
2346 | get_highmem_page_buffer(struct page *page, struct chain_allocator *ca) | 2338 | struct chain_allocator *ca) |
2347 | { | 2339 | { |
2348 | return ERR_PTR(-EINVAL); | 2340 | return ERR_PTR(-EINVAL); |
2349 | } | 2341 | } |
@@ -2369,8 +2361,7 @@ static inline void free_highmem_data(void) {} | |||
2369 | 2361 | ||
2370 | #define PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe)) | 2362 | #define PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe)) |
2371 | 2363 | ||
2372 | static int | 2364 | static int prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm) |
2373 | prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm) | ||
2374 | { | 2365 | { |
2375 | unsigned int nr_pages, nr_highmem; | 2366 | unsigned int nr_pages, nr_highmem; |
2376 | struct linked_page *lp; | 2367 | struct linked_page *lp; |
@@ -2593,8 +2584,8 @@ int snapshot_image_loaded(struct snapshot_handle *handle) | |||
2593 | 2584 | ||
2594 | #ifdef CONFIG_HIGHMEM | 2585 | #ifdef CONFIG_HIGHMEM |
2595 | /* Assumes that @buf is ready and points to a "safe" page */ | 2586 | /* Assumes that @buf is ready and points to a "safe" page */ |
2596 | static inline void | 2587 | static inline void swap_two_pages_data(struct page *p1, struct page *p2, |
2597 | swap_two_pages_data(struct page *p1, struct page *p2, void *buf) | 2588 | void *buf) |
2598 | { | 2589 | { |
2599 | void *kaddr1, *kaddr2; | 2590 | void *kaddr1, *kaddr2; |
2600 | 2591 | ||