memcg: get/put parents at create/free
authorDaisuke Nishimura <[email protected]>
Thu, 29 Jan 2009 22:25:11 +0000 (14:25 -0800)
committerLinus Torvalds <[email protected]>
Fri, 30 Jan 2009 02:04:43 +0000 (18:04 -0800)
commit7bcc1bb1232de6efc0b85e0c7fe38e90b2436318
tree3952a706885f4c57217f4196f055a7c16d0af80b
parentbaef99a08a2e23d9386b47e53fa5f0d44fc98f66
memcg: get/put parents at create/free

The lifetime of struct cgroup and struct mem_cgroup is different and
mem_cgroup has its own reference count for handling references from
swap_cgroup.

This causes strange problem that the parent mem_cgroup dies while child
mem_cgroup alive, and this problem causes a bug in case of
use_hierarchy==1 because res_counter_uncharge climbs up the tree.

This patch is for avoiding it by getting the parent at create, and putting
it at freeing.

Signed-off-by: Daisuke Nishimura <[email protected]>
Reviewed-by; KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Paul Menage <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/memcontrol.c