提交 56057e1a 编写于 作者: M Michal Schmidt 提交者: Linus Torvalds

[PATCH] swsusp: simpler calculation of number of pages in PBE list

The function calc_nr uses an iterative algorithm to calculate the number of
pages needed for the image and the pagedir.  Exactly the same result can be
obtained with a one-line expression.

Note that this was even proved correct ;-).
Signed-off-by: NMichal Schmidt <xschmi00@stud.feec.vutbr.cz>
Signed-off-by: NPavel Machek <pavel@suse.cz>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 46dacba5
......@@ -737,18 +737,7 @@ static void copy_data_pages(void)
static int calc_nr(int nr_copy)
{
int extra = 0;
int mod = !!(nr_copy % PBES_PER_PAGE);
int diff = (nr_copy / PBES_PER_PAGE) + mod;
do {
extra += diff;
nr_copy += diff;
mod = !!(nr_copy % PBES_PER_PAGE);
diff = (nr_copy / PBES_PER_PAGE) + mod - extra;
} while (diff > 0);
return nr_copy;
return nr_copy + (nr_copy+PBES_PER_PAGE-2)/(PBES_PER_PAGE-1);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册