aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/memcontrol.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7bb14fdc780c..81b0ae8183d0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -994,13 +994,24 @@ nomem:
994static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page) 994static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)
995{ 995{
996 struct mem_cgroup *mem; 996 struct mem_cgroup *mem;
997 struct page_cgroup *pc;
997 swp_entry_t ent; 998 swp_entry_t ent;
998 999
1000 VM_BUG_ON(!PageLocked(page));
1001
999 if (!PageSwapCache(page)) 1002 if (!PageSwapCache(page))
1000 return NULL; 1003 return NULL;
1001 1004
1002 ent.val = page_private(page); 1005 pc = lookup_page_cgroup(page);
1003 mem = lookup_swap_cgroup(ent); 1006 /*
1007 * Used bit of swapcache is solid under page lock.
1008 */
1009 if (PageCgroupUsed(pc))
1010 mem = pc->mem_cgroup;
1011 else {
1012 ent.val = page_private(page);
1013 mem = lookup_swap_cgroup(ent);
1014 }
1004 if (!mem) 1015 if (!mem)
1005 return NULL; 1016 return NULL;
1006 if (!css_tryget(&mem->css)) 1017 if (!css_tryget(&mem->css))