diff options
author | Namhyung Kim <namhyung@gmail.com> | 2011-05-26 19:25:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-26 20:12:35 -0400 |
commit | 33278f7f0a9e5a9b29f59e07b7e3182d27769ac2 (patch) | |
tree | 8de853c293856cc227d703ffaa0e12410efa1fcd /mm/page_cgroup.c | |
parent | 268433b8e54486b12478e94ba18587bcc7de4d57 (diff) |
memcg: fix off-by-one when calculating swap cgroup map length
It allocated one more page than necessary if @max_pages was a multiple of
SC_PER_PAGE.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_cgroup.c')
-rw-r--r-- | mm/page_cgroup.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index 4eb05302e2e1..5524e8bd7437 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c | |||
@@ -475,7 +475,7 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) | |||
475 | if (!do_swap_account) | 475 | if (!do_swap_account) |
476 | return 0; | 476 | return 0; |
477 | 477 | ||
478 | length = ((max_pages/SC_PER_PAGE) + 1); | 478 | length = DIV_ROUND_UP(max_pages, SC_PER_PAGE); |
479 | array_size = length * sizeof(void *); | 479 | array_size = length * sizeof(void *); |
480 | 480 | ||
481 | array = vmalloc(array_size); | 481 | array = vmalloc(array_size); |