* [PATCH 0/3] 3 bugfixes for memory cgroup (2.6.38-rc2)
@ 2011-01-25 5:57 KAMEZAWA Hiroyuki
2011-01-25 6:00 ` [PATCH 1/3] memcg: fix account leak at failure of memsw acconting KAMEZAWA Hiroyuki
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2011-01-25 5:57 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-mm, nishimura, balbir, hannes, akpm
Hi, these are 3 bugfix patches for 2.6.38-rc2 +
mm-memcontrolc-fix-uninitialized-variable-use-in-mem_cgroup_move_parent.patch
in mm tree.
3 patches are independent from each other but [1/3] patch is for
2.6.36-stable, tree.
[1/3] fix account leak at failure of memsw acconting. (for 2.6.36 stable)
[2/3] check mem_cgroup_disabled() at split fixup (for recent 2.6.38-git)
[3/3] fix race at move_parent() (This depends on m-memcontrolc
fix-uninitialized-variable-use-in-mem_cgroup_move_parent.patch)
I'll send other fixes for THP/memcg but this is an early cut for obvious bugs.
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/3] memcg: fix account leak at failure of memsw acconting. 2011-01-25 5:57 [PATCH 0/3] 3 bugfixes for memory cgroup (2.6.38-rc2) KAMEZAWA Hiroyuki @ 2011-01-25 6:00 ` KAMEZAWA Hiroyuki 2011-01-25 7:07 ` Johannes Weiner 2011-01-25 8:31 ` Daisuke Nishimura 2011-01-25 6:01 ` [PATCH 2/3] memcg: bugfix check mem_cgroup_disabled() at split fixup KAMEZAWA Hiroyuki 2011-01-25 6:05 ` [PATCH 3/3] memcg: fix race at move_parent around compound_order() KAMEZAWA Hiroyuki 2 siblings, 2 replies; 8+ messages in thread From: KAMEZAWA Hiroyuki @ 2011-01-25 6:00 UTC (permalink / raw) To: KAMEZAWA Hiroyuki Cc: linux-kernel, linux-mm, nishimura, balbir, hannes, akpm, stable This is required for 2.6.36-stable and later. == Commit 4b53433468c87794b523e4683fbd4e8e8aca1f63 removes a cancel of charge at case: memory charge-> success. mem+swap charge-> failure. This leaks usage of memory. Fix it. This patch is required for stable tree since 2.6.36. CC: stable@kernel.org Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> --- mm/memcontrol.c | 1 + 1 file changed, 1 insertion(+) Index: linux-2.6.38-rc2/mm/memcontrol.c =================================================================== --- linux-2.6.38-rc2.orig/mm/memcontrol.c +++ linux-2.6.38-rc2/mm/memcontrol.c @@ -1832,6 +1832,7 @@ static int __mem_cgroup_do_charge(struct if (likely(!ret)) return CHARGE_OK; + res_counter_uncharge(&mem->res, csize); mem_over_limit = mem_cgroup_from_res_counter(fail_res, memsw); flags |= MEM_CGROUP_RECLAIM_NOSWAP; } else ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] memcg: fix account leak at failure of memsw acconting. 2011-01-25 6:00 ` [PATCH 1/3] memcg: fix account leak at failure of memsw acconting KAMEZAWA Hiroyuki @ 2011-01-25 7:07 ` Johannes Weiner 2011-01-25 8:31 ` Daisuke Nishimura 1 sibling, 0 replies; 8+ messages in thread From: Johannes Weiner @ 2011-01-25 7:07 UTC (permalink / raw) To: KAMEZAWA Hiroyuki; +Cc: linux-kernel, linux-mm, nishimura, balbir, akpm, stable On Tue, Jan 25, 2011 at 03:00:42PM +0900, KAMEZAWA Hiroyuki wrote: > This is required for 2.6.36-stable and later. > == > Commit 4b53433468c87794b523e4683fbd4e8e8aca1f63 removes > a cancel of charge at case: > memory charge-> success. > mem+swap charge-> failure. > > This leaks usage of memory. Fix it. > > This patch is required for stable tree since 2.6.36. > > CC: stable@kernel.org > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Johannes Weiner <hannes@cmpxchg.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] memcg: fix account leak at failure of memsw acconting. 2011-01-25 6:00 ` [PATCH 1/3] memcg: fix account leak at failure of memsw acconting KAMEZAWA Hiroyuki 2011-01-25 7:07 ` Johannes Weiner @ 2011-01-25 8:31 ` Daisuke Nishimura 1 sibling, 0 replies; 8+ messages in thread From: Daisuke Nishimura @ 2011-01-25 8:31 UTC (permalink / raw) To: KAMEZAWA Hiroyuki Cc: linux-kernel, linux-mm, balbir, hannes, akpm, stable, Daisuke Nishimura On Tue, 25 Jan 2011 15:00:42 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > This is required for 2.6.36-stable and later. > == > Commit 4b53433468c87794b523e4683fbd4e8e8aca1f63 removes > a cancel of charge at case: > memory charge-> success. > mem+swap charge-> failure. > > This leaks usage of memory. Fix it. > > This patch is required for stable tree since 2.6.36. > > CC: stable@kernel.org > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Nice catch. Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] memcg: bugfix check mem_cgroup_disabled() at split fixup 2011-01-25 5:57 [PATCH 0/3] 3 bugfixes for memory cgroup (2.6.38-rc2) KAMEZAWA Hiroyuki 2011-01-25 6:00 ` [PATCH 1/3] memcg: fix account leak at failure of memsw acconting KAMEZAWA Hiroyuki @ 2011-01-25 6:01 ` KAMEZAWA Hiroyuki 2011-01-25 6:05 ` [PATCH 3/3] memcg: fix race at move_parent around compound_order() KAMEZAWA Hiroyuki 2 siblings, 0 replies; 8+ messages in thread From: KAMEZAWA Hiroyuki @ 2011-01-25 6:01 UTC (permalink / raw) To: KAMEZAWA Hiroyuki; +Cc: linux-kernel, linux-mm, nishimura, balbir, hannes, akpm From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> mem_cgroup_disabled() should be checked at splitting. If diabled, no heavy work is necesary. Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Reviewed-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> --- mm/memcontrol.c | 2 ++ 1 file changed, 2 insertions(+) Index: linux-2.6.38-rc2/mm/memcontrol.c =================================================================== --- linux-2.6.38-rc2.orig/mm/memcontrol.c +++ linux-2.6.38-rc2/mm/memcontrol.c @@ -2145,6 +2145,8 @@ void mem_cgroup_split_huge_fixup(struct struct page_cgroup *tail_pc = lookup_page_cgroup(tail); unsigned long flags; + if (mem_cgroup_disabled()) + return; /* * We have no races with charge/uncharge but will have races with * page state accounting. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] memcg: fix race at move_parent around compound_order() 2011-01-25 5:57 [PATCH 0/3] 3 bugfixes for memory cgroup (2.6.38-rc2) KAMEZAWA Hiroyuki 2011-01-25 6:00 ` [PATCH 1/3] memcg: fix account leak at failure of memsw acconting KAMEZAWA Hiroyuki 2011-01-25 6:01 ` [PATCH 2/3] memcg: bugfix check mem_cgroup_disabled() at split fixup KAMEZAWA Hiroyuki @ 2011-01-25 6:05 ` KAMEZAWA Hiroyuki 2011-01-25 7:07 ` Johannes Weiner 2011-01-25 8:31 ` Daisuke Nishimura 2 siblings, 2 replies; 8+ messages in thread From: KAMEZAWA Hiroyuki @ 2011-01-25 6:05 UTC (permalink / raw) To: KAMEZAWA Hiroyuki; +Cc: linux-kernel, linux-mm, nishimura, balbir, hannes, akpm Based on 2.6.38-rc2 + mm-memcontrolc-fix-uninitialized-variable-use-in-mem_cgroup_move_parent.patch == From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> A fix up mem_cgroup_move_parent() which use compound_order() in asynchrnous manner. This compound_order() may return unknown value because we don't take lock. Use PageTransHuge() and HPAGE_SIZE instead of it. Also clean up for mem_cgroup_move_parent(). - remove unnecessary initialization of local variable. - rename charge_size -> page_size - remove unnecessary (wrong) comment. - added a comment about THP. Changelog: - fixed page size calculation for avoiding race. Note: Current design take compound_page_lock() in caller of move_account(). This should be revisited when we implement direct move_task of hugepage without splitting. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> --- mm/memcontrol.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) Index: linux-2.6.38-rc2/mm/memcontrol.c =================================================================== --- linux-2.6.38-rc2.orig/mm/memcontrol.c +++ linux-2.6.38-rc2/mm/memcontrol.c @@ -2234,7 +2234,12 @@ static int mem_cgroup_move_account(struc { int ret = -EINVAL; unsigned long flags; - + /* + * The page is isolated from LRU. So, collapse function + * will not handle this page. But page splitting can happen. + * Do this check under compound_page_lock(). The caller should + * hold it. + */ if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page)) return -EBUSY; @@ -2266,7 +2271,7 @@ static int mem_cgroup_move_parent(struct struct cgroup *cg = child->css.cgroup; struct cgroup *pcg = cg->parent; struct mem_cgroup *parent; - int charge = PAGE_SIZE; + int page_size = PAGE_SIZE; unsigned long flags; int ret; @@ -2279,22 +2284,24 @@ static int mem_cgroup_move_parent(struct goto out; if (isolate_lru_page(page)) goto put; - /* The page is isolated from LRU and we have no race with splitting */ - charge = PAGE_SIZE << compound_order(page); + + if (PageTransHuge(page)) + page_size = HPAGE_SIZE; parent = mem_cgroup_from_cont(pcg); - ret = __mem_cgroup_try_charge(NULL, gfp_mask, &parent, false, charge); + ret = __mem_cgroup_try_charge(NULL, gfp_mask, + &parent, false, page_size); if (ret || !parent) goto put_back; - if (charge > PAGE_SIZE) + if (page_size > PAGE_SIZE) flags = compound_lock_irqsave(page); - ret = mem_cgroup_move_account(pc, child, parent, true, charge); + ret = mem_cgroup_move_account(pc, child, parent, true, page_size); if (ret) - mem_cgroup_cancel_charge(parent, charge); + mem_cgroup_cancel_charge(parent, page_size); - if (charge > PAGE_SIZE) + if (page_size > PAGE_SIZE) compound_unlock_irqrestore(page, flags); put_back: putback_lru_page(page); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] memcg: fix race at move_parent around compound_order() 2011-01-25 6:05 ` [PATCH 3/3] memcg: fix race at move_parent around compound_order() KAMEZAWA Hiroyuki @ 2011-01-25 7:07 ` Johannes Weiner 2011-01-25 8:31 ` Daisuke Nishimura 1 sibling, 0 replies; 8+ messages in thread From: Johannes Weiner @ 2011-01-25 7:07 UTC (permalink / raw) To: KAMEZAWA Hiroyuki; +Cc: linux-kernel, linux-mm, nishimura, balbir, akpm On Tue, Jan 25, 2011 at 03:05:16PM +0900, KAMEZAWA Hiroyuki wrote: > Based on > 2.6.38-rc2 + > mm-memcontrolc-fix-uninitialized-variable-use-in-mem_cgroup_move_parent.patch > == > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > A fix up mem_cgroup_move_parent() which use compound_order() in > asynchrnous manner. This compound_order() may return unknown value > because we don't take lock. Use PageTransHuge() and HPAGE_SIZE instead of > it. > > Also clean up for mem_cgroup_move_parent(). > - remove unnecessary initialization of local variable. > - rename charge_size -> page_size > - remove unnecessary (wrong) comment. > - added a comment about THP. > > Changelog: > - fixed page size calculation for avoiding race. > > Note: > Current design take compound_page_lock() in caller of move_account(). > This should be revisited when we implement direct move_task of hugepage > without splitting. > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Johannes Weiner <hannes@cmpxchg.org> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] memcg: fix race at move_parent around compound_order() 2011-01-25 6:05 ` [PATCH 3/3] memcg: fix race at move_parent around compound_order() KAMEZAWA Hiroyuki 2011-01-25 7:07 ` Johannes Weiner @ 2011-01-25 8:31 ` Daisuke Nishimura 1 sibling, 0 replies; 8+ messages in thread From: Daisuke Nishimura @ 2011-01-25 8:31 UTC (permalink / raw) To: KAMEZAWA Hiroyuki Cc: linux-kernel, linux-mm, balbir, hannes, akpm, Daisuke Nishimura On Tue, 25 Jan 2011 15:05:16 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > Based on > 2.6.38-rc2 + > mm-memcontrolc-fix-uninitialized-variable-use-in-mem_cgroup_move_parent.patch > == > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > A fix up mem_cgroup_move_parent() which use compound_order() in > asynchrnous manner. This compound_order() may return unknown value > because we don't take lock. Use PageTransHuge() and HPAGE_SIZE instead of > it. > > Also clean up for mem_cgroup_move_parent(). > - remove unnecessary initialization of local variable. > - rename charge_size -> page_size > - remove unnecessary (wrong) comment. > - added a comment about THP. > > Changelog: > - fixed page size calculation for avoiding race. > > Note: > Current design take compound_page_lock() in caller of move_account(). > This should be revisited when we implement direct move_task of hugepage > without splitting. > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-01-25 8:32 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-01-25 5:57 [PATCH 0/3] 3 bugfixes for memory cgroup (2.6.38-rc2) KAMEZAWA Hiroyuki 2011-01-25 6:00 ` [PATCH 1/3] memcg: fix account leak at failure of memsw acconting KAMEZAWA Hiroyuki 2011-01-25 7:07 ` Johannes Weiner 2011-01-25 8:31 ` Daisuke Nishimura 2011-01-25 6:01 ` [PATCH 2/3] memcg: bugfix check mem_cgroup_disabled() at split fixup KAMEZAWA Hiroyuki 2011-01-25 6:05 ` [PATCH 3/3] memcg: fix race at move_parent around compound_order() KAMEZAWA Hiroyuki 2011-01-25 7:07 ` Johannes Weiner 2011-01-25 8:31 ` Daisuke Nishimura
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox