diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2014-12-10 18:43:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 20:41:07 -0500 |
commit | 7bdd143c37e591c254d0991ac398a53f3f9ef1af (patch) | |
tree | 0198540d14c53ee642729dcdf57f0faf94e8b2e2 /mm/memcontrol.c | |
parent | b9982f8d27f893de2e8e98a25c68bb838b5311a4 (diff) |
mm: memcontrol: uncharge pages on swapout
This series gets rid of the remaining page_cgroup flags, thus cutting the
memcg per-page overhead down to one pointer.
This patch (of 4):
mem_cgroup_swapout() is called with exclusive access to the page at the
end of the page's lifetime. Instead of clearing the PCG_MEMSW flag and
deferring the uncharge, just do it right away. This allows follow-up
patches to simplify the uncharge code.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Hugh Dickins <hughd@google.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Vladimir Davydov <vdavydov@parallels.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8c10d4ca9c3f..266a440c89f9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -5777,6 +5777,7 @@ static void __init enable_swap_cgroup(void) | |||
5777 | */ | 5777 | */ |
5778 | void mem_cgroup_swapout(struct page *page, swp_entry_t entry) | 5778 | void mem_cgroup_swapout(struct page *page, swp_entry_t entry) |
5779 | { | 5779 | { |
5780 | struct mem_cgroup *memcg; | ||
5780 | struct page_cgroup *pc; | 5781 | struct page_cgroup *pc; |
5781 | unsigned short oldid; | 5782 | unsigned short oldid; |
5782 | 5783 | ||
@@ -5793,13 +5794,22 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) | |||
5793 | return; | 5794 | return; |
5794 | 5795 | ||
5795 | VM_BUG_ON_PAGE(!(pc->flags & PCG_MEMSW), page); | 5796 | VM_BUG_ON_PAGE(!(pc->flags & PCG_MEMSW), page); |
5797 | memcg = pc->mem_cgroup; | ||
5796 | 5798 | ||
5797 | oldid = swap_cgroup_record(entry, mem_cgroup_id(pc->mem_cgroup)); | 5799 | oldid = swap_cgroup_record(entry, mem_cgroup_id(memcg)); |
5798 | VM_BUG_ON_PAGE(oldid, page); | 5800 | VM_BUG_ON_PAGE(oldid, page); |
5801 | mem_cgroup_swap_statistics(memcg, true); | ||
5802 | |||
5803 | pc->flags = 0; | ||
5799 | 5804 | ||
5800 | pc->flags &= ~PCG_MEMSW; | 5805 | if (!mem_cgroup_is_root(memcg)) |
5801 | css_get(&pc->mem_cgroup->css); | 5806 | page_counter_uncharge(&memcg->memory, 1); |
5802 | mem_cgroup_swap_statistics(pc->mem_cgroup, true); | 5807 | |
5808 | /* XXX: caller holds IRQ-safe mapping->tree_lock */ | ||
5809 | VM_BUG_ON(!irqs_disabled()); | ||
5810 | |||
5811 | mem_cgroup_charge_statistics(memcg, page, -1); | ||
5812 | memcg_check_events(memcg, page); | ||
5803 | } | 5813 | } |
5804 | 5814 | ||
5805 | /** | 5815 | /** |