aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 0093bc36c5fc..d5ff3ce13029 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -89,6 +89,7 @@ static const char * const mem_cgroup_stat_names[] = {
89 "rss", 89 "rss",
90 "rss_huge", 90 "rss_huge",
91 "mapped_file", 91 "mapped_file",
92 "writeback",
92 "swap", 93 "swap",
93}; 94};
94 95
@@ -3654,6 +3655,20 @@ void mem_cgroup_split_huge_fixup(struct page *head)
3654} 3655}
3655#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 3656#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
3656 3657
3658static inline
3659void mem_cgroup_move_account_page_stat(struct mem_cgroup *from,
3660 struct mem_cgroup *to,
3661 unsigned int nr_pages,
3662 enum mem_cgroup_stat_index idx)
3663{
3664 /* Update stat data for mem_cgroup */
3665 preempt_disable();
3666 WARN_ON_ONCE(from->stat->count[idx] < nr_pages);
3667 __this_cpu_add(from->stat->count[idx], -nr_pages);
3668 __this_cpu_add(to->stat->count[idx], nr_pages);
3669 preempt_enable();
3670}
3671
3657/** 3672/**
3658 * mem_cgroup_move_account - move account of the page 3673 * mem_cgroup_move_account - move account of the page
3659 * @page: the page 3674 * @page: the page
@@ -3699,13 +3714,14 @@ static int mem_cgroup_move_account(struct page *page,
3699 3714
3700 move_lock_mem_cgroup(from, &flags); 3715 move_lock_mem_cgroup(from, &flags);
3701 3716
3702 if (!anon && page_mapped(page)) { 3717 if (!anon && page_mapped(page))
3703 /* Update mapped_file data for mem_cgroup */ 3718 mem_cgroup_move_account_page_stat(from, to, nr_pages,
3704 preempt_disable(); 3719 MEM_CGROUP_STAT_FILE_MAPPED);
3705 __this_cpu_dec(from->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); 3720
3706 __this_cpu_inc(to->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); 3721 if (PageWriteback(page))
3707 preempt_enable(); 3722 mem_cgroup_move_account_page_stat(from, to, nr_pages,
3708 } 3723 MEM_CGROUP_STAT_WRITEBACK);
3724
3709 mem_cgroup_charge_statistics(from, page, anon, -nr_pages); 3725 mem_cgroup_charge_statistics(from, page, anon, -nr_pages);
3710 3726
3711 /* caller should have done css_get */ 3727 /* caller should have done css_get */