Lines Matching refs:page

83  * The calls to set_direct_map_*() should not fail because remapping a page
88 static inline void hibernate_map_page(struct page *page)
91 int ret = set_direct_map_default_noflush(page);
94 pr_warn_once("Failed to remap page\n");
96 debug_pagealloc_map_pages(page, 1);
100 static inline void hibernate_unmap_page(struct page *page)
103 unsigned long addr = (unsigned long)page_address(page);
104 int ret = set_direct_map_invalid_noflush(page);
107 pr_warn_once("Failed to remap page\n");
111 debug_pagealloc_unmap_pages(page, 1);
115 static int swsusp_page_is_free(struct page *);
116 static void swsusp_set_page_forbidden(struct page *);
117 static void swsusp_unset_page_forbidden(struct page *);
148 * directly to their "original" page frames.
168 /* Pointer to an auxiliary buffer (1 page) */
179 * get_image_page - Allocate a page for a hibernation image.
188 * Each allocated image page is marked as PageNosave and PageNosaveFree so that
198 /* The page is unsafe, mark it for swsusp_free() */
227 static struct page *alloc_image_page(gfp_t gfp_mask)
229 struct page *page;
231 page = alloc_page(gfp_mask);
232 if (page) {
233 swsusp_set_page_forbidden(page);
234 swsusp_set_page_free(page);
236 return page;
248 * free_image_page - Free a page allocated for hibernation image.
249 * @addr: Address of the page to free.
250 * @clear_nosave_free: If set, clear the PageNosaveFree bit for the page.
252 * The page to free should have been allocated by get_image_page() (page flags
257 struct page *page;
261 page = virt_to_page(addr);
263 swsusp_unset_page_forbidden(page);
265 swsusp_unset_page_free(page);
267 __free_page(page);
286 * the current page. The allocated objects cannot be freed individually.
296 of the current page */
355 * struct bm_block contains a pointer to the memory page in which
396 unsigned long start_pfn; /* Zone start page frame */
397 unsigned long end_pfn; /* Zone end page frame + 1 */
745 * Walk the radix tree to find the page containing the bit that represents @pfn
952 * This structure represents a range of page frames the contents of which
994 * Register a range of page frames the contents of which should not be saved
1029 * Set bits in this map correspond to the page frames the contents of which
1034 /* Set bits in this map correspond to free page frames. */
1038 * Each page frame allocated for creating the image is marked by setting the
1042 void swsusp_set_page_free(struct page *page)
1045 memory_bm_set_bit(free_pages_map, page_to_pfn(page));
1048 static int swsusp_page_is_free(struct page *page)
1051 memory_bm_test_bit(free_pages_map, page_to_pfn(page)) : 0;
1054 void swsusp_unset_page_free(struct page *page)
1057 memory_bm_clear_bit(free_pages_map, page_to_pfn(page));
1060 static void swsusp_set_page_forbidden(struct page *page)
1063 memory_bm_set_bit(forbidden_pages_map, page_to_pfn(page));
1066 int swsusp_page_is_forbidden(struct page *page)
1069 memory_bm_test_bit(forbidden_pages_map, page_to_pfn(page)) : 0;
1072 static void swsusp_unset_page_forbidden(struct page *page)
1075 memory_bm_clear_bit(forbidden_pages_map, page_to_pfn(page));
1082 * Set the bits in @bm that correspond to the page frames the contents of which
1114 * create_basic_memory_bitmaps - Create bitmaps to hold basic page information.
1116 * Create bitmaps needed for marking page frames that should not be saved and
1117 * free page frames. The forbidden_pages_map and free_pages_map pointers are
1190 static void clear_or_poison_free_page(struct page *page)
1193 __kernel_poison_pages(page, 1);
1195 clear_highpage(page);
1253 struct page *page;
1263 page = pfn_to_page(pfn);
1270 if (page_zone(page) != zone)
1273 if (!swsusp_page_is_forbidden(page))
1274 swsusp_unset_page_free(page);
1278 list_for_each_entry(page,
1282 pfn = page_to_pfn(page);
1314 * saveable_highmem_page - Check if a highmem page is saveable.
1316 * Determine whether a highmem page should be included in a hibernation image.
1318 * We should save the page if it isn't Nosave or NosaveFree, or Reserved,
1321 static struct page *saveable_highmem_page(struct zone *zone, unsigned long pfn)
1323 struct page *page;
1328 page = pfn_to_online_page(pfn);
1329 if (!page || page_zone(page) != zone)
1332 BUG_ON(!PageHighMem(page));
1334 if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page))
1337 if (PageReserved(page) || PageOffline(page))
1340 if (page_is_guard(page))
1343 return page;
1376 * saveable_page - Check if the given page is saveable.
1378 * Determine whether a non-highmem page should be included in a hibernation
1381 * We should save the page if it isn't Nosave, and is not in the range
1385 static struct page *saveable_page(struct zone *zone, unsigned long pfn)
1387 struct page *page;
1392 page = pfn_to_online_page(pfn);
1393 if (!page || page_zone(page) != zone)
1396 BUG_ON(PageHighMem(page));
1398 if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page))
1401 if (PageOffline(page))
1404 if (PageReserved(page)
1405 && (!kernel_page_present(page) || pfn_is_nosave(pfn)))
1408 if (page_is_guard(page))
1411 return page;
1438 * task structs. Returns true if the page was filled with only zeros,
1454 * safe_copy_page - Copy a page in a safe way.
1456 * Check if the page we are going to copy is marked as present in the kernel
1457 * page tables. This always is the case if CONFIG_DEBUG_PAGEALLOC or
1459 * always returns 'true'. Returns true if the page was entirely composed of
1462 static bool safe_copy_page(void *dst, struct page *s_page)
1477 static inline struct page *page_is_saveable(struct zone *zone, unsigned long pfn)
1485 struct page *s_page, *d_page;
1500 * The page pointed to by src may contain some kernel
1525 * If a page was entirely filled with zeros it will be marked in the zero_bm.
1555 /* Use this copy_pfn for a page that is not full of zeros */
1572 * Numbers of normal and highmem page frames allocated for hibernation image
1582 * Memory bitmap used during hibernation for marking allocated page frames that
1626 struct page *page = pfn_to_page(fr_pfn);
1630 hibernate_restore_unprotect_page(page_address(page));
1631 __free_page(page);
1652 * @nr_pages: Number of page frames to allocate.
1655 * Return value: Number of page frames actually allocated
1662 struct page *page;
1664 page = alloc_image_page(mask);
1665 if (!page)
1667 memory_bm_set_bit(&copy_bm, page_to_pfn(page));
1668 if (PageHighMem(page))
1762 struct page *page = pfn_to_page(pfn);
1764 if (PageHighMem(page)) {
1776 swsusp_unset_page_forbidden(page);
1777 swsusp_unset_page_free(page);
1778 __free_page(page);
1815 * To create a hibernation image it is necessary to make a copy of every page
1816 * frame in use. We also need a number of page frames to be free during
1822 * total number of available page frames and allocate at least
1824 * ([page frames total] - PAGES_FOR_IO - [metadata pages]) / 2
1872 * Compute the total number of page frames we can use (count) and the
1899 * current number of saveable pages in memory, allocate page frames for
1924 * large number of page frames to allocate and make it free some memory.
1976 * We only need as many page frames for the image as there are saveable
2064 struct page *page;
2066 page = alloc_image_page(__GFP_HIGHMEM|__GFP_KSWAPD_RECLAIM);
2067 memory_bm_set_bit(bm, page_to_pfn(page));
2103 struct page *page;
2105 page = alloc_image_page(GFP_ATOMIC);
2106 if (!page)
2108 memory_bm_set_bit(copy_bm, page_to_pfn(page));
2212 * pointed to by @buf (1 page at a time). Pages which were filled with only
2231 * snapshot_read_next - Get the address to read the next image page from.
2270 struct page *page;
2272 page = pfn_to_page(memory_bm_next_pfn(&copy_bm));
2273 if (PageHighMem(page)) {
2277 * highmem page (we may not be called again).
2281 kaddr = kmap_atomic(page);
2286 handle->buffer = page_address(page);
2366 * For each element of the array pointed to by @buf (1 page at a time), set the
2367 * corresponding bit in @bm. If the page was originally populated with only
2403 * should be restored atomically during the resume from disk, because the page
2407 struct page *copy_page; /* data is here now */
2408 struct page *orig_page; /* data was here before the suspend */
2416 * written directly to their "original" page frames.
2478 struct page *page;
2480 page = alloc_page(__GFP_HIGHMEM);
2481 if (!swsusp_page_is_free(page)) {
2482 /* The page is "safe", set its bit the bitmap */
2483 memory_bm_set_bit(bm, page_to_pfn(page));
2486 /* Mark the page as allocated */
2487 swsusp_set_page_forbidden(page);
2488 swsusp_set_page_free(page);
2495 static struct page *last_highmem_page;
2498 * get_highmem_page_buffer - Prepare a buffer to store a highmem image page.
2500 * For a given highmem image page get a buffer that suspend_write_next() should
2503 * If the page is to be saved to its "original" page frame or a copy of
2504 * the page is to be made in the highmem, @buffer is returned. Otherwise,
2505 * the copy of the page is to be made in normal memory, so the address of
2509 * the page's contents to @buffer, so they will have to be copied to the
2512 * @buffer is returned, @last_highmem_page is set to the page to which
2515 static void *get_highmem_page_buffer(struct page *page,
2521 if (swsusp_page_is_forbidden(page) && swsusp_page_is_free(page)) {
2523 * We have allocated the "original" page frame and we can
2524 * use it directly to store the loaded page.
2526 last_highmem_page = page;
2530 * The "original" page frame has not been allocated and we have to
2531 * use a "safe" page frame to store the loaded page.
2538 pbe->orig_page = page;
2540 struct page *tmp;
2542 /* Copy of the page will be stored in high memory */
2549 /* Copy of the page will be stored in normal memory */
2561 * copy_last_highmem_page - Copy most the most recent highmem image page.
2598 static inline void *get_highmem_page_buffer(struct page *page,
2704 /* The page is "safe", add it to the list */
2708 /* Mark the page as allocated */
2721 * get_buffer - Get the address to store the next image data page.
2729 struct page *page;
2735 page = pfn_to_page(pfn);
2736 if (PageHighMem(page))
2737 return get_highmem_page_buffer(page, ca);
2739 if (swsusp_page_is_forbidden(page) && swsusp_page_is_free(page))
2741 * We have allocated the "original" page frame and we can
2742 * use it directly to store the loaded page.
2744 return page_address(page);
2747 * The "original" page frame has not been allocated and we have to
2748 * use a "safe" page frame to store the loaded page.
2755 pbe->orig_address = page_address(page);
2765 * snapshot_write_next - Get the address to store the next image page.
2861 * page in the image happens to be a highmem page and its contents should be
2886 /* Assumes that @buf is ready and points to a "safe" page */
2887 static inline void swap_two_pages_data(struct page *p1, struct page *p2,
2904 * For each highmem page that was in use before hibernation and is included in