Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 35685
b: refs/heads/master
c: f6143aa
h: refs/heads/master
i:
  35683: 60bf0f4
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Linus Torvalds committed Sep 26, 2006
1 parent be41222 commit cd31ee0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f623f0db8e6aa86a37be86167e4ff478821a9f4f
refs/heads/master: f6143aa60ed71e58578bc92cc64d98158a694d99
93 changes: 53 additions & 40 deletions trunk/kernel/power/snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,58 @@ static inline int save_highmem(void) {return 0;}
static inline int restore_highmem(void) {return 0;}
#endif

/**
* @safe_needed - on resume, for storing the PBE list and the image,
* we can only use memory pages that do not conflict with the pages
* used before suspend.
*
* The unsafe pages are marked with the PG_nosave_free flag
* and we count them using unsafe_pages
*/

static unsigned int unsafe_pages;

static void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
{
void *res;

res = (void *)get_zeroed_page(gfp_mask);
if (safe_needed)
while (res && PageNosaveFree(virt_to_page(res))) {
/* The page is unsafe, mark it for swsusp_free() */
SetPageNosave(virt_to_page(res));
unsafe_pages++;
res = (void *)get_zeroed_page(gfp_mask);
}
if (res) {
SetPageNosave(virt_to_page(res));
SetPageNosaveFree(virt_to_page(res));
}
return res;
}

unsigned long get_safe_page(gfp_t gfp_mask)
{
return (unsigned long)alloc_image_page(gfp_mask, 1);
}

/**
* free_image_page - free page represented by @addr, allocated with
* alloc_image_page (page flags set by it must be cleared)
*/

static inline void free_image_page(void *addr, int clear_nosave_free)
{
ClearPageNosave(virt_to_page(addr));
if (clear_nosave_free)
ClearPageNosaveFree(virt_to_page(addr));
free_page((unsigned long)addr);
}

/**
* pfn_is_nosave - check if given pfn is in the 'nosave' section
*/

static inline int pfn_is_nosave(unsigned long pfn)
{
unsigned long nosave_begin_pfn = __pa(&__nosave_begin) >> PAGE_SHIFT;
Expand Down Expand Up @@ -245,7 +297,6 @@ static void copy_data_pages(struct pbe *pblist)
BUG_ON(pbe);
}


/**
* free_pagedir - free pages allocated with alloc_pagedir()
*/
Expand All @@ -256,10 +307,7 @@ static void free_pagedir(struct pbe *pblist, int clear_nosave_free)

while (pblist) {
pbe = (pblist + PB_PAGE_SKIP)->next;
ClearPageNosave(virt_to_page(pblist));
if (clear_nosave_free)
ClearPageNosaveFree(virt_to_page(pblist));
free_page((unsigned long)pblist);
free_image_page(pblist, clear_nosave_free);
pblist = pbe;
}
}
Expand Down Expand Up @@ -303,41 +351,6 @@ static inline void create_pbe_list(struct pbe *pblist, unsigned int nr_pages)
}
}

static unsigned int unsafe_pages;

/**
* @safe_needed - on resume, for storing the PBE list and the image,
* we can only use memory pages that do not conflict with the pages
* used before suspend.
*
* The unsafe pages are marked with the PG_nosave_free flag
* and we count them using unsafe_pages
*/

static void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
{
void *res;

res = (void *)get_zeroed_page(gfp_mask);
if (safe_needed)
while (res && PageNosaveFree(virt_to_page(res))) {
/* The page is unsafe, mark it for swsusp_free() */
SetPageNosave(virt_to_page(res));
unsafe_pages++;
res = (void *)get_zeroed_page(gfp_mask);
}
if (res) {
SetPageNosave(virt_to_page(res));
SetPageNosaveFree(virt_to_page(res));
}
return res;
}

unsigned long get_safe_page(gfp_t gfp_mask)
{
return (unsigned long)alloc_image_page(gfp_mask, 1);
}

/**
* alloc_pagedir - Allocate the page directory.
*
Expand Down

0 comments on commit cd31ee0

Please sign in to comment.