if (mem_cgroup_disabled())
return NULL;
- if (PageSwapCache(page))
- return NULL;
+ VM_BUG_ON(PageSwapCache(page));
if (PageTransHuge(page)) {
nr_pages <<= compound_order(page);
if (page_mapped(page))
return;
VM_BUG_ON(page->mapping && !PageAnon(page));
+ if (PageSwapCache(page))
+ return;
__mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_ANON, false);
}
{
VM_BUG_ON(page_mapped(page));
VM_BUG_ON(page->mapping);
+ if (PageSwapCache(page))
+ return;
__mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE, false);
}
if (!swapout) /* this was a swap cache but the swap is unused ! */
ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
+ if (PageSwapCache(page))
+ return;
memcg = __mem_cgroup_uncharge_common(page, ctype, false);
/*
unused = oldpage;
}
anon = PageAnon(used);
- __mem_cgroup_uncharge_common(unused,
- anon ? MEM_CGROUP_CHARGE_TYPE_ANON
- : MEM_CGROUP_CHARGE_TYPE_CACHE,
- true);
+ if (!PageSwapCache(unused))
+ __mem_cgroup_uncharge_common(unused,
+ anon ? MEM_CGROUP_CHARGE_TYPE_ANON
+ : MEM_CGROUP_CHARGE_TYPE_CACHE,
+ true);
css_put(&memcg->css);
/*
* We disallowed uncharge of pages under migration because mapcount