forked from Minki/linux
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>
This commit is contained in:
parent
268433b8e5
commit
33278f7f0a
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user