aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorHugh Dickins <hughd@google.com>2012-01-12 20:19:52 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-12 23:13:09 -0500
commit12d27107867fc7216e8faaff0b894b0f162dcf75 (patch)
tree8f35d39f7e5d0b0f0ba10a3475e9fa4a2581e509 /mm/memcontrol.c
parent0cee34fd72c582b4f8ad8ce00645b75fb4168199 (diff)
memcg: fix split_huge_page_refcounts()
This patch started off as a cleanup: __split_huge_page_refcounts() has to cope with two scenarios, when the hugepage being split is already on LRU, and when it is not; but why does it have to split that accounting across three different sites? Consolidate it in lru_add_page_tail(), handling evictable and unevictable alike, and use standard add_page_to_lru_list() when accounting is needed (when the head is not yet on LRU). But a recent regression in -next, I guess the removal of PageCgroupAcctLRU test from mem_cgroup_split_huge_fixup(), makes this now a necessary fix: under load, the MEM_CGROUP_ZSTAT count was wrapping to a huge number, messing up reclaim calculations and causing a freeze at rmdir of cgroup. Add a VM_BUG_ON to mem_cgroup_lru_del_list() when we're about to wrap that count - this has not been the only such incident. Document that lru_add_page_tail() is for Transparent HugePages by #ifdef around it. Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> 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.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 609c49f492e6..9f2f64697409 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1071,6 +1071,7 @@ void mem_cgroup_lru_del_list(struct page *page, enum lru_list lru)
1071 VM_BUG_ON(!memcg); 1071 VM_BUG_ON(!memcg);
1072 mz = page_cgroup_zoneinfo(memcg, page); 1072 mz = page_cgroup_zoneinfo(memcg, page);
1073 /* huge page split is done under lru_lock. so, we have no races. */ 1073 /* huge page split is done under lru_lock. so, we have no races. */
1074 VM_BUG_ON(MEM_CGROUP_ZSTAT(mz, lru) < (1 << compound_order(page)));
1074 MEM_CGROUP_ZSTAT(mz, lru) -= 1 << compound_order(page); 1075 MEM_CGROUP_ZSTAT(mz, lru) -= 1 << compound_order(page);
1075} 1076}
1076 1077
@@ -2465,9 +2466,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg,
2465void mem_cgroup_split_huge_fixup(struct page *head) 2466void mem_cgroup_split_huge_fixup(struct page *head)
2466{ 2467{
2467 struct page_cgroup *head_pc = lookup_page_cgroup(head); 2468 struct page_cgroup *head_pc = lookup_page_cgroup(head);
2468 struct mem_cgroup_per_zone *mz;
2469 struct page_cgroup *pc; 2469 struct page_cgroup *pc;
2470 enum lru_list lru;
2471 int i; 2470 int i;
2472 2471
2473 if (mem_cgroup_disabled()) 2472 if (mem_cgroup_disabled())
@@ -2478,15 +2477,8 @@ void mem_cgroup_split_huge_fixup(struct page *head)
2478 smp_wmb();/* see __commit_charge() */ 2477 smp_wmb();/* see __commit_charge() */
2479 pc->flags = head_pc->flags & ~PCGF_NOCOPY_AT_SPLIT; 2478 pc->flags = head_pc->flags & ~PCGF_NOCOPY_AT_SPLIT;
2480 } 2479 }
2481 /*
2482 * Tail pages will be added to LRU.
2483 * We hold lru_lock,then,reduce counter directly.
2484 */
2485 lru = page_lru(head);
2486 mz = page_cgroup_zoneinfo(head_pc->mem_cgroup, head);
2487 MEM_CGROUP_ZSTAT(mz, lru) -= HPAGE_PMD_NR - 1;
2488} 2480}
2489#endif 2481#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
2490 2482
2491/** 2483/**
2492 * mem_cgroup_move_account - move account of the page 2484 * mem_cgroup_move_account - move account of the page