aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/memcontrol.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 52840adae62a..9a99cfaf0a19 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1591,7 +1591,8 @@ bool mem_cgroup_handle_oom(struct mem_cgroup *mem, gfp_t mask)
1591 * small, we check MEM_CGROUP_ON_MOVE percpu value and detect there are 1591 * small, we check MEM_CGROUP_ON_MOVE percpu value and detect there are
1592 * possibility of race condition. If there is, we take a lock. 1592 * possibility of race condition. If there is, we take a lock.
1593 */ 1593 */
1594void mem_cgroup_update_file_mapped(struct page *page, int val) 1594
1595static void mem_cgroup_update_file_stat(struct page *page, int idx, int val)
1595{ 1596{
1596 struct mem_cgroup *mem; 1597 struct mem_cgroup *mem;
1597 struct page_cgroup *pc = lookup_page_cgroup(page); 1598 struct page_cgroup *pc = lookup_page_cgroup(page);
@@ -1613,13 +1614,18 @@ void mem_cgroup_update_file_mapped(struct page *page, int val)
1613 if (!mem || !PageCgroupUsed(pc)) 1614 if (!mem || !PageCgroupUsed(pc))
1614 goto out; 1615 goto out;
1615 } 1616 }
1616 if (val > 0) { 1617
1617 this_cpu_inc(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); 1618 this_cpu_add(mem->stat->count[idx], val);
1618 SetPageCgroupFileMapped(pc); 1619
1619 } else { 1620 switch (idx) {
1620 this_cpu_dec(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); 1621 case MEM_CGROUP_STAT_FILE_MAPPED:
1621 if (!page_mapped(page)) /* for race between dec->inc counter */ 1622 if (val > 0)
1623 SetPageCgroupFileMapped(pc);
1624 else if (!page_mapped(page))
1622 ClearPageCgroupFileMapped(pc); 1625 ClearPageCgroupFileMapped(pc);
1626 break;
1627 default:
1628 BUG();
1623 } 1629 }
1624 1630
1625out: 1631out:
@@ -1629,6 +1635,11 @@ out:
1629 return; 1635 return;
1630} 1636}
1631 1637
1638void mem_cgroup_update_file_mapped(struct page *page, int val)
1639{
1640 mem_cgroup_update_file_stat(page, MEM_CGROUP_STAT_FILE_MAPPED, val);
1641}
1642
1632/* 1643/*
1633 * size of first charge trial. "32" comes from vmscan.c's magic value. 1644 * size of first charge trial. "32" comes from vmscan.c's magic value.
1634 * TODO: maybe necessary to use big numbers in big irons. 1645 * TODO: maybe necessary to use big numbers in big irons.