Lines Matching defs:page
92 static int swsusp_page_is_free(struct page *);
93 static void swsusp_set_page_forbidden(struct page *);
94 static void swsusp_unset_page_forbidden(struct page *);
125 * directly to their "original" page frames.
145 /* Pointer to an auxiliary buffer (1 page) */
156 * get_image_page - Allocate a page for a hibernation image.
165 * Each allocated image page is marked as PageNosave and PageNosaveFree so that
175 /* The page is unsafe, mark it for swsusp_free() */
205 static struct page *alloc_image_page(gfp_t gfp_mask)
207 struct page *page;
209 page = alloc_page(gfp_mask);
210 if (page) {
211 swsusp_set_page_forbidden(page);
212 swsusp_set_page_free(page);
214 return page;
226 * free_image_page - Free a page allocated for hibernation image.
227 * @addr: Address of the page to free.
228 * @clear_nosave_free: If set, clear the PageNosaveFree bit for the page.
230 * The page to free should have been allocated by get_image_page() (page flags
235 struct page *page;
239 page = virt_to_page(addr);
241 swsusp_unset_page_forbidden(page);
243 swsusp_unset_page_free(page);
246 __free_page(page);
264 * the current page. The allocated objects cannot be freed individually.
274 of the current page */
332 * struct bm_block contains a pointer to the memory page in which
373 unsigned long start_pfn; /* Zone start page frame */
374 unsigned long end_pfn; /* Zone end page frame + 1 */
714 * Walk the radix tree to find the page containing the bit that represents @pfn
912 * This structure represents a range of page frames the contents of which
951 * Register a range of page frames the contents of which should not be saved
987 * Set bits in this map correspond to the page frames the contents of which
992 /* Set bits in this map correspond to free page frames. */
996 * Each page frame allocated for creating the image is marked by setting the
1000 void swsusp_set_page_free(struct page *page)
1003 memory_bm_set_bit(free_pages_map, page_to_pfn(page));
1007 static int swsusp_page_is_free(struct page *page)
1009 return free_pages_map ? memory_bm_test_bit(free_pages_map, page_to_pfn(page)) : 0;
1012 void swsusp_unset_page_free(struct page *page)
1015 memory_bm_clear_bit(free_pages_map, page_to_pfn(page));
1019 static void swsusp_set_page_forbidden(struct page *page)
1022 memory_bm_set_bit(forbidden_pages_map, page_to_pfn(page));
1026 int swsusp_page_is_forbidden(struct page *page)
1028 return forbidden_pages_map ? memory_bm_test_bit(forbidden_pages_map, page_to_pfn(page)) : 0;
1031 static void swsusp_unset_page_forbidden(struct page *page)
1034 memory_bm_clear_bit(forbidden_pages_map, page_to_pfn(page));
1042 * Set the bits in @bm that correspond to the page frames the contents of which
1075 * create_basic_memory_bitmaps - Create bitmaps to hold basic page information.
1077 * Create bitmaps needed for marking page frames that should not be saved and
1078 * free page frames. The forbidden_pages_map and free_pages_map pointers are
1157 static void clear_or_poison_free_page(struct page *page)
1160 _kernel_poison_pages(page, 1);
1162 clear_highpage(page);
1229 * saveable_highmem_page - Check if a highmem page is saveable.
1231 * Determine whether a highmem page should be included in a hibernation image.
1233 * We should save the page if it isn't Nosave or NosaveFree, or Reserved,
1236 static struct page *saveable_highmem_page(struct zone *zone, unsigned long pfn)
1238 struct page *page;
1244 page = pfn_to_online_page(pfn);
1245 if (!page || page_zone(page) != zone) {
1249 BUG_ON(!PageHighMem(page));
1251 if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page)) {
1255 if (PageReserved(page) || PageOffline(page)) {
1259 if (page_is_guard(page)) {
1263 return page;
1300 * saveable_page - Check if the given page is saveable.
1302 * Determine whether a non-highmem page should be included in a hibernation
1305 * We should save the page if it isn't Nosave, and is not in the range
1309 static struct page *saveable_page(struct zone *zone, unsigned long pfn)
1311 struct page *page;
1317 page = pfn_to_online_page(pfn);
1318 if (!page || page_zone(page) != zone) {
1322 BUG_ON(PageHighMem(page));
1324 if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page)) {
1328 if (PageOffline(page)) {
1332 if (PageReserved(page) && (!kernel_page_present(page) || pfn_is_nosave(pfn))) {
1336 if (page_is_guard(page)) {
1340 return page;
1383 * safe_copy_page - Copy a page in a safe way.
1385 * Check if the page we are going to copy is marked as present in the kernel
1386 * page tables. This always is the case if CONFIG_DEBUG_PAGEALLOC or
1390 static void safe_copy_page(void *dst, struct page *s_page)
1402 static inline struct page *page_is_saveable(struct zone *zone, unsigned long pfn)
1409 struct page *s_page, *d_page;
1423 * The page pointed to by src may contain some kernel
1477 * Numbers of normal and highmem page frames allocated for hibernation image
1487 * Memory bitmap used during hibernation for marking allocated page frames that
1531 struct page *page = pfn_to_page(fr_pfn);
1535 hibernate_restore_unprotect_page(page_address(page));
1536 __free_page(page);
1558 * @nr_pages: Number of page frames to allocate.
1561 * Return value: Number of page frames actually allocated
1568 struct page *page;
1570 page = alloc_image_page(mask);
1571 if (!page) {
1574 memory_bm_set_bit(©_bm, page_to_pfn(page));
1575 if (PageHighMem(page)) {
1669 struct page *page = pfn_to_page(pfn);
1671 if (PageHighMem(page)) {
1685 swsusp_unset_page_forbidden(page);
1686 swsusp_unset_page_free(page);
1687 __free_page(page);
1722 * To create a hibernation image it is necessary to make a copy of every page
1723 * frame in use. We also need a number of page frames to be free during
1729 * total number of available page frames and allocate at least
1731 * ([page frames total] + PAGES_FOR_IO + [metadata pages]) / 2
1772 * Compute the total number of page frames we can use (count) and the
1801 * current number of saveable pages in memory, allocate page frames for
1828 * large number of page frames to allocate and make it free some memory.
1880 * We only need as many page frames for the image as there are saveable
1967 struct page *page;
1969 page = alloc_image_page(__GFP_HIGHMEM | __GFP_KSWAPD_RECLAIM);
1970 memory_bm_set_bit(bm, page_to_pfn(page));
2011 struct page *page;
2013 page = alloc_image_page(GFP_ATOMIC);
2014 if (!page) {
2017 memory_bm_set_bit(copy_bm_ex, page_to_pfn(page));
2122 * pointed to by @buf (1 page at a time).
2137 * snapshot_read_next - Get the address to read the next image page from.
2179 struct page *page;
2181 page = pfn_to_page(memory_bm_next_pfn(©_bm));
2182 if (PageHighMem(page)) {
2186 * highmem page (we may not be called again).
2190 kaddr = kmap_atomic(page);
2195 handle->buffer = page_address(page);
2274 * For each element of the array pointed to by @buf (1 page at a time), set the
2299 * should be restored atomically during the resume from disk, because the page
2303 struct page *copy_page; /* data is here now */
2304 struct page *orig_page; /* data was here before the suspend */
2312 * written directly to their "original" page frames.
2377 struct page *page;
2379 page = alloc_page(__GFP_HIGHMEM);
2380 if (!swsusp_page_is_free(page)) {
2381 /* The page is "safe", set its bit the bitmap */
2382 memory_bm_set_bit(bm, page_to_pfn(page));
2385 /* Mark the page as allocated */
2386 swsusp_set_page_forbidden(page);
2387 swsusp_set_page_free(page);
2394 static struct page *last_highmem_page;
2397 * get_highmem_page_buffer - Prepare a buffer to store a highmem image page.
2399 * For a given highmem image page get a buffer that suspend_write_next() should
2402 * If the page is to be saved to its "original" page frame or a copy of
2403 * the page is to be made in the highmem, @buffer is returned. Otherwise,
2404 * the copy of the page is to be made in normal memory, so the address of
2408 * the page's contents to @buffer, so they will have to be copied to the
2411 * @buffer is returned, @last_highmem_page is set to the page to which
2414 static void *get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
2419 if (swsusp_page_is_forbidden(page) && swsusp_page_is_free(page)) {
2421 * We have allocated the "original" page frame and we can
2422 * use it directly to store the loaded page.
2424 last_highmem_page = page;
2428 * The "original" page frame has not been allocated and we have to
2429 * use a "safe" page frame to store the loaded page.
2436 pbe->orig_page = page;
2438 struct page *tmp;
2440 /* Copy of the page will be stored in high memory */
2447 /* Copy of the page will be stored in normal memory */
2458 * copy_last_highmem_page - Copy most the most recent highmem image page.
2502 static inline void *get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
2592 /* The page is "safe", add it to the list */
2596 /* Mark the page as allocated */
2609 * get_buffer - Get the address to store the next image data page.
2617 struct page *page;
2623 page = pfn_to_page(pfn);
2624 if (PageHighMem(page)) {
2625 return get_highmem_page_buffer(page, ca);
2628 if (swsusp_page_is_forbidden(page) && swsusp_page_is_free(page)) {
2630 * We have allocated the "original" page frame and we can
2631 * use it directly to store the loaded page.
2633 return page_address(page);
2637 * The "original" page frame has not been allocated and we have to
2638 * use a "safe" page frame to store the loaded page.
2645 pbe->orig_address = page_address(page);
2654 * snapshot_write_next - Get the address to store the next image page.
2746 * page in the image happens to be a highmem page and its contents should be
2767 /* Assumes that @buf is ready and points to a "safe" page */
2768 static inline void swap_two_pages_data(struct page *p1, struct page *p2, void *buf)
2784 * For each highmem page that was in use before hibernation and is included in