diff options
author | Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> | 2011-01-13 18:47:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 20:32:51 -0500 |
commit | 50de1dd967d4ba3b8a90ebe7a4f5feca24191317 (patch) | |
tree | ed2aa4352ae3c2887a90ef6279588a7048397d1b /mm | |
parent | 17295c88a160c6eea3fcf46cec9d08a0fcb02db9 (diff) |
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 <nishimura@mxp.nes.nec.co.jp>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 5 | ||||
-rw-r--r-- | mm/migrate.c | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6424ba0fce83..8ab841031436 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2896,7 +2896,7 @@ int mem_cgroup_prepare_migration(struct page *page, | |||
2896 | 2896 | ||
2897 | /* remove redundant charge if migration failed*/ | 2897 | /* remove redundant charge if migration failed*/ |
2898 | void mem_cgroup_end_migration(struct mem_cgroup *mem, | 2898 | void mem_cgroup_end_migration(struct mem_cgroup *mem, |
2899 | struct page *oldpage, struct page *newpage) | 2899 | struct page *oldpage, struct page *newpage, bool migration_ok) |
2900 | { | 2900 | { |
2901 | struct page *used, *unused; | 2901 | struct page *used, *unused; |
2902 | struct page_cgroup *pc; | 2902 | struct page_cgroup *pc; |
@@ -2905,8 +2905,7 @@ void mem_cgroup_end_migration(struct mem_cgroup *mem, | |||
2905 | return; | 2905 | return; |
2906 | /* blocks rmdir() */ | 2906 | /* blocks rmdir() */ |
2907 | cgroup_exclude_rmdir(&mem->css); | 2907 | cgroup_exclude_rmdir(&mem->css); |
2908 | /* at migration success, oldpage->mapping is NULL. */ | 2908 | if (!migration_ok) { |
2909 | if (oldpage->mapping) { | ||
2910 | used = oldpage; | 2909 | used = oldpage; |
2911 | unused = newpage; | 2910 | unused = newpage; |
2912 | } else { | 2911 | } else { |
diff --git a/mm/migrate.c b/mm/migrate.c index 5b7d1fd29621..46fe8cc13d67 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -768,7 +768,7 @@ skip_unmap: | |||
768 | 768 | ||
769 | uncharge: | 769 | uncharge: |
770 | if (!charge) | 770 | if (!charge) |
771 | mem_cgroup_end_migration(mem, page, newpage); | 771 | mem_cgroup_end_migration(mem, page, newpage, rc == 0); |
772 | unlock: | 772 | unlock: |
773 | unlock_page(page); | 773 | unlock_page(page); |
774 | 774 | ||