aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3468c38adde6..a83e0395444b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -189,6 +189,7 @@ enum charge_type {
189 MEM_CGROUP_CHARGE_TYPE_SHMEM, /* used by page migration of shmem */ 189 MEM_CGROUP_CHARGE_TYPE_SHMEM, /* used by page migration of shmem */
190 MEM_CGROUP_CHARGE_TYPE_FORCE, /* used by force_empty */ 190 MEM_CGROUP_CHARGE_TYPE_FORCE, /* used by force_empty */
191 MEM_CGROUP_CHARGE_TYPE_SWAPOUT, /* for accounting swapcache */ 191 MEM_CGROUP_CHARGE_TYPE_SWAPOUT, /* for accounting swapcache */
192 MEM_CGROUP_CHARGE_TYPE_DROP, /* a page was unused swap cache */
192 NR_CHARGE_TYPE, 193 NR_CHARGE_TYPE,
193}; 194};
194 195
@@ -1493,6 +1494,7 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
1493 1494
1494 switch (ctype) { 1495 switch (ctype) {
1495 case MEM_CGROUP_CHARGE_TYPE_MAPPED: 1496 case MEM_CGROUP_CHARGE_TYPE_MAPPED:
1497 case MEM_CGROUP_CHARGE_TYPE_DROP:
1496 if (page_mapped(page)) 1498 if (page_mapped(page))
1497 goto unlock_out; 1499 goto unlock_out;
1498 break; 1500 break;
@@ -1556,18 +1558,23 @@ void mem_cgroup_uncharge_cache_page(struct page *page)
1556 * called after __delete_from_swap_cache() and drop "page" account. 1558 * called after __delete_from_swap_cache() and drop "page" account.
1557 * memcg information is recorded to swap_cgroup of "ent" 1559 * memcg information is recorded to swap_cgroup of "ent"
1558 */ 1560 */
1559void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent) 1561void
1562mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
1560{ 1563{
1561 struct mem_cgroup *memcg; 1564 struct mem_cgroup *memcg;
1565 int ctype = MEM_CGROUP_CHARGE_TYPE_SWAPOUT;
1566
1567 if (!swapout) /* this was a swap cache but the swap is unused ! */
1568 ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
1569
1570 memcg = __mem_cgroup_uncharge_common(page, ctype);
1562 1571
1563 memcg = __mem_cgroup_uncharge_common(page,
1564 MEM_CGROUP_CHARGE_TYPE_SWAPOUT);
1565 /* record memcg information */ 1572 /* record memcg information */
1566 if (do_swap_account && memcg) { 1573 if (do_swap_account && swapout && memcg) {
1567 swap_cgroup_record(ent, css_id(&memcg->css)); 1574 swap_cgroup_record(ent, css_id(&memcg->css));
1568 mem_cgroup_get(memcg); 1575 mem_cgroup_get(memcg);
1569 } 1576 }
1570 if (memcg) 1577 if (swapout && memcg)
1571 css_put(&memcg->css); 1578 css_put(&memcg->css);
1572} 1579}
1573#endif 1580#endif