aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2012-07-31 19:45:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:48 -0400
commit7d188958bb64708577aa77e6b1ad68abbf0480f5 (patch)
tree34e954784a6adce1a03ab91dd38b66cc7fd060b4 /mm/memcontrol.c
parent0c59b89c81eab7fe7dcf08f2252ae22a6c081ce8 (diff)
mm: memcg: only check for PageSwapCache when uncharging anon
Only anon pages that are uncharged at the time of the last page table mapping vanishing may be in swapcache. When shmem pages, file pages, swap-freed anon pages, or just migrated pages are uncharged, they are known for sure to be not in swapcache. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: David Rientjes <rientjes@google.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Wanpeng Li <liwp.linux@gmail.com> Cc: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 87c2ec49b482..29bc4400378d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3093,8 +3093,6 @@ void mem_cgroup_uncharge_cache_page(struct page *page)
3093{ 3093{
3094 VM_BUG_ON(page_mapped(page)); 3094 VM_BUG_ON(page_mapped(page));
3095 VM_BUG_ON(page->mapping); 3095 VM_BUG_ON(page->mapping);
3096 if (PageSwapCache(page))
3097 return;
3098 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false); 3096 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false);
3099} 3097}
3100 3098
@@ -3159,8 +3157,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
3159 if (!swapout) /* this was a swap cache but the swap is unused ! */ 3157 if (!swapout) /* this was a swap cache but the swap is unused ! */
3160 ctype = MEM_CGROUP_CHARGE_TYPE_DROP; 3158 ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
3161 3159
3162 if (PageSwapCache(page))
3163 return;
3164 memcg = __mem_cgroup_uncharge_common(page, ctype, false); 3160 memcg = __mem_cgroup_uncharge_common(page, ctype, false);
3165 3161
3166 /* 3162 /*
@@ -3350,11 +3346,10 @@ void mem_cgroup_end_migration(struct mem_cgroup *memcg,
3350 unused = oldpage; 3346 unused = oldpage;
3351 } 3347 }
3352 anon = PageAnon(used); 3348 anon = PageAnon(used);
3353 if (!PageSwapCache(unused)) 3349 __mem_cgroup_uncharge_common(unused,
3354 __mem_cgroup_uncharge_common(unused, 3350 anon ? MEM_CGROUP_CHARGE_TYPE_ANON
3355 anon ? MEM_CGROUP_CHARGE_TYPE_ANON 3351 : MEM_CGROUP_CHARGE_TYPE_CACHE,
3356 : MEM_CGROUP_CHARGE_TYPE_CACHE, 3352 true);
3357 true);
3358 css_put(&memcg->css); 3353 css_put(&memcg->css);
3359 /* 3354 /*
3360 * We disallowed uncharge of pages under migration because mapcount 3355 * We disallowed uncharge of pages under migration because mapcount