Commit 7bdd143c authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

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: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Hugh Dickins <hughd@google.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
Acked-by: default avatarVladimir Davydov <vdavydov@parallels.com>
Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b9982f8d
...@@ -5777,6 +5777,7 @@ static void __init enable_swap_cgroup(void) ...@@ -5777,6 +5777,7 @@ static void __init enable_swap_cgroup(void)
*/ */
void mem_cgroup_swapout(struct page *page, swp_entry_t entry) void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
{ {
struct mem_cgroup *memcg;
struct page_cgroup *pc; struct page_cgroup *pc;
unsigned short oldid; unsigned short oldid;
...@@ -5793,13 +5794,22 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) ...@@ -5793,13 +5794,22 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
return; return;
VM_BUG_ON_PAGE(!(pc->flags & PCG_MEMSW), page); VM_BUG_ON_PAGE(!(pc->flags & PCG_MEMSW), page);
memcg = pc->mem_cgroup;
oldid = swap_cgroup_record(entry, mem_cgroup_id(pc->mem_cgroup)); oldid = swap_cgroup_record(entry, mem_cgroup_id(memcg));
VM_BUG_ON_PAGE(oldid, page); VM_BUG_ON_PAGE(oldid, page);
mem_cgroup_swap_statistics(memcg, true);
pc->flags = 0;
pc->flags &= ~PCG_MEMSW; if (!mem_cgroup_is_root(memcg))
css_get(&pc->mem_cgroup->css); page_counter_uncharge(&memcg->memory, 1);
mem_cgroup_swap_statistics(pc->mem_cgroup, true);
/* XXX: caller holds IRQ-safe mapping->tree_lock */
VM_BUG_ON(!irqs_disabled());
mem_cgroup_charge_statistics(memcg, page, -1);
memcg_check_events(memcg, page);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment