[-mm][PATCH 8/10] fix shmem page migration incorrectness on memcgroup

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: KOSAKI Motohiro
Date: Wednesday, June 25, 2008 - 3:09 am

=
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

mem_cgroup_uncharge() against old page is done after radix-tree-replacement.
And there were special handling to ingore swap-cache page. But, shmem can
be swap-cache and file-cache at the same time. Chekcing PageSwapCache() is
not correct here. Check PageAnon() instead.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>

---
 mm/migrate.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Index: b/mm/migrate.c
===================================================================
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -332,7 +332,13 @@ static int migrate_page_move_mapping(str
 	__inc_zone_page_state(newpage, NR_FILE_PAGES);
 
 	spin_unlock_irq(&mapping->tree_lock);
-	if (!PageSwapCache(newpage))
+
+	/*
+	 * The page is removed from radix-tree implicitly.
+	 * We uncharge it here but swap cache of anonymous page should be
+	 * uncharged by mem_cgroup_ucharge_page().
+	 */
+	if (!PageAnon(newpage))
 		mem_cgroup_uncharge_cache_page(page);
 
 	return 0;
@@ -381,7 +387,8 @@ static void migrate_page_copy(struct pag
 		/*
 		 * SwapCache is removed implicitly. Uncharge against swapcache
 		 * should be called after ClearPageSwapCache() because
-		 * mem_cgroup_uncharge_page checks the flag.
+		 * mem_cgroup_uncharge_page checks the flag. shmem's swap cache
+		 * is uncharged before here.
 		 */
 		mem_cgroup_uncharge_page(page);
 	}


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[-mm][PATCH 2/10] fix printk in show_free_areas(), KOSAKI Motohiro, (Wed Jun 25, 3:02 am)
[-mm][PATCH 7/10] prevent incorrect oom under split_lru, KOSAKI Motohiro, (Wed Jun 25, 3:07 am)
[-mm][PATCH 8/10] fix shmem page migration incorrectness o ..., KOSAKI Motohiro, (Wed Jun 25, 3:09 am)
[-mm][PATCH 9/10] memcg: fix mem_cgroup_end_migration() race, KOSAKI Motohiro, (Wed Jun 25, 3:10 am)
Re: [-mm][PATCH 9/10] memcg: fix mem_cgroup_end_migration ..., Daisuke Nishimura, (Wed Jun 25, 3:53 am)
Re: [-mm][PATCH 0/10] memory related bugfix set for 2.6.2 ..., Lee Schermerhorn, (Wed Jun 25, 8:09 am)
Re: [-mm][PATCH 8/10] fix shmem page migration incorrectne ..., KAMEZAWA Hiroyuki, (Fri Jun 27, 1:52 am)
Re: [-mm][PATCH 8/10] fix shmem page migration incorrectne ..., Daisuke Nishimura, (Fri Jun 27, 2:29 am)