memcg: fix memory migration of shmem swapcache

In the current implementation mem_cgroup_end_migration() decides whether
the page migration has succeeded or not by checking "oldpage->mapping".

But if we are tring to migrate a shmem swapcache, the page->mapping of it
is NULL from the begining, so the check would be invalid.  As a result,
mem_cgroup_end_migration() assumes the migration has succeeded even if
it's not, so "newpage" would be freed while it's not uncharged.

This patch fixes it by passing mem_cgroup_end_migration() the result of
the page migration.

Signed-off-by: Daisuke Nishimura <[email protected]>
Reviewed-by: Minchan Kim <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Balbir Singh <[email protected]>
Cc: Minchan Kim <[email protected]>
Reviewed-by: Johannes Weiner <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Daisuke Nishimura 2011-01-13 15:47:43 -08:00 • committed by Linus Torvalds
commit 50de1dd967
3 changed files with 5 additions and 7 deletions

View file

@ -768,7 +768,7 @@ skip_unmap:
uncharge:
if (!charge)
mem_cgroup_end_migration(mem, page, newpage);
mem_cgroup_end_migration(mem, page, newpage, rc == 0);
unlock:
unlock_page(page);