Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 35686
b: refs/heads/master
c: cd560bb
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Linus Torvalds committed Sep 26, 2006
1 parent cd31ee0 commit 85b7835
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 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: f6143aa60ed71e58578bc92cc64d98158a694d99
refs/heads/master: cd560bb2f9e2cd451bb3942af43da19632ba4a8e
32 changes: 17 additions & 15 deletions trunk/kernel/power/snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ static void free_pagedir(struct pbe *pblist, int clear_nosave_free)
* fill_pb_page - Create a list of PBEs on a given memory page
*/

static inline void fill_pb_page(struct pbe *pbpage)
static inline void fill_pb_page(struct pbe *pbpage, unsigned int n)
{
struct pbe *p;

p = pbpage;
pbpage += PB_PAGE_SKIP;
pbpage += n - 1;
do
p->next = p + 1;
while (++p < pbpage);
Expand All @@ -330,24 +330,26 @@ static inline void fill_pb_page(struct pbe *pbpage)
/**
* create_pbe_list - Create a list of PBEs on top of a given chain
* of memory pages allocated with alloc_pagedir()
*
* This function assumes that pages allocated by alloc_image_page() will
* always be zeroed.
*/

static inline void create_pbe_list(struct pbe *pblist, unsigned int nr_pages)
{
struct pbe *pbpage, *p;
struct pbe *pbpage;
unsigned int num = PBES_PER_PAGE;

for_each_pb_page (pbpage, pblist) {
if (num >= nr_pages)
break;

fill_pb_page(pbpage);
fill_pb_page(pbpage, PBES_PER_PAGE);
num += PBES_PER_PAGE;
}
if (pbpage) {
for (num -= PBES_PER_PAGE - 1, p = pbpage; num < nr_pages; p++, num++)
p->next = p + 1;
p->next = NULL;
num -= PBES_PER_PAGE;
fill_pb_page(pbpage, nr_pages - num);
}
}

Expand All @@ -374,17 +376,17 @@ static struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask,
return NULL;

pblist = alloc_image_page(gfp_mask, safe_needed);
/* FIXME: rewrite this ugly loop */
for (pbe = pblist, num = PBES_PER_PAGE; pbe && num < nr_pages;
pbe = pbe->next, num += PBES_PER_PAGE) {
pbe = pblist;
for (num = PBES_PER_PAGE; num < nr_pages; num += PBES_PER_PAGE) {
if (!pbe) {
free_pagedir(pblist, 1);
return NULL;
}
pbe += PB_PAGE_SKIP;
pbe->next = alloc_image_page(gfp_mask, safe_needed);
pbe = pbe->next;
}
if (!pbe) { /* get_zeroed_page() failed */
free_pagedir(pblist, 1);
pblist = NULL;
} else
create_pbe_list(pblist, nr_pages);
create_pbe_list(pblist, nr_pages);
return pblist;
}

Expand Down

0 comments on commit 85b7835

Please sign in to comment.