aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2012-07-31 19:45:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 21:42:48 -0400
commit0c59b89c81eab7fe7dcf08f2252ae22a6c081ce8 (patch)
treeb6b6510704282d59dd875fed59c999c93455c973 /mm/memcontrol.c
parent5d84c7766e8aacc6e3477bdf02fdb417163cf89b (diff)
mm: memcg: push down PageSwapCache check into uncharge entry functions
Not all uncharge paths need to check if the page is swapcache, some of them can know for sure. Push down the check into all callsites of uncharge_common() so that the patch that removes some of them is more obvious. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> 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> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> 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.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7eadcdad06f3..87c2ec49b482 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2987,8 +2987,7 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype,
2987 if (mem_cgroup_disabled()) 2987 if (mem_cgroup_disabled())
2988 return NULL; 2988 return NULL;
2989 2989
2990 if (PageSwapCache(page)) 2990 VM_BUG_ON(PageSwapCache(page));
2991 return NULL;
2992 2991
2993 if (PageTransHuge(page)) { 2992 if (PageTransHuge(page)) {
2994 nr_pages <<= compound_order(page); 2993 nr_pages <<= compound_order(page);
@@ -3085,6 +3084,8 @@ void mem_cgroup_uncharge_page(struct page *page)
3085 if (page_mapped(page)) 3084 if (page_mapped(page))
3086 return; 3085 return;
3087 VM_BUG_ON(page->mapping && !PageAnon(page)); 3086 VM_BUG_ON(page->mapping && !PageAnon(page));
3087 if (PageSwapCache(page))
3088 return;
3088 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_ANON, false); 3089 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_ANON, false);
3089} 3090}
3090 3091
@@ -3092,6 +3093,8 @@ void mem_cgroup_uncharge_cache_page(struct page *page)
3092{ 3093{
3093 VM_BUG_ON(page_mapped(page)); 3094 VM_BUG_ON(page_mapped(page));
3094 VM_BUG_ON(page->mapping); 3095 VM_BUG_ON(page->mapping);
3096 if (PageSwapCache(page))
3097 return;
3095 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false); 3098 __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false);
3096} 3099}
3097 3100
@@ -3156,6 +3159,8 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
3156 if (!swapout) /* this was a swap cache but the swap is unused ! */ 3159 if (!swapout) /* this was a swap cache but the swap is unused ! */
3157 ctype = MEM_CGROUP_CHARGE_TYPE_DROP; 3160 ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
3158 3161
3162 if (PageSwapCache(page))
3163 return;
3159 memcg = __mem_cgroup_uncharge_common(page, ctype, false); 3164 memcg = __mem_cgroup_uncharge_common(page, ctype, false);
3160 3165
3161 /* 3166 /*
@@ -3345,10 +3350,11 @@ void mem_cgroup_end_migration(struct mem_cgroup *memcg,
3345 unused = oldpage; 3350 unused = oldpage;
3346 } 3351 }
3347 anon = PageAnon(used); 3352 anon = PageAnon(used);
3348 __mem_cgroup_uncharge_common(unused, 3353 if (!PageSwapCache(unused))
3349 anon ? MEM_CGROUP_CHARGE_TYPE_ANON 3354 __mem_cgroup_uncharge_common(unused,
3350 : MEM_CGROUP_CHARGE_TYPE_CACHE, 3355 anon ? MEM_CGROUP_CHARGE_TYPE_ANON
3351 true); 3356 : MEM_CGROUP_CHARGE_TYPE_CACHE,
3357 true);
3352 css_put(&memcg->css); 3358 css_put(&memcg->css);
3353 /* 3359 /*
3354 * We disallowed uncharge of pages under migration because mapcount 3360 * We disallowed uncharge of pages under migration because mapcount