From 33278f7f0a9e5a9b29f59e07b7e3182d27769ac2 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 26 May 2011 16:25:30 -0700 Subject: [PATCH] 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 Acked-by: KAMEZAWA Hiroyuki Acked-by: Balbir Singh Cc: Daisuke Nishimura Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) if (!do_swap_account) return 0; - length = ((max_pages/SC_PER_PAGE) + 1); + length = DIV_ROUND_UP(max_pages, SC_PER_PAGE); array_size = length * sizeof(void *); array = vmalloc(array_size); -- GitLab