Revision b1dd693e5b9348bd68a80e679e03cf9c0973b01b authored by Daisuke Nishimura on 24 November 2010, 20:57:06 UTC, committed by Linus Torvalds on 24 November 2010, 21:50:44 UTC
__mem_cgroup_try_charge() can be called under down_write(&mmap_sem)(e.g. mlock does it). This means it can cause deadlock if it races with move charge: Ex.1) move charge | try charge --------------------------------------+------------------------------ mem_cgroup_can_attach() | down_write(&mmap_sem) mc.moving_task = current | .. mem_cgroup_precharge_mc() | __mem_cgroup_try_charge() mem_cgroup_count_precharge() | prepare_to_wait() down_read(&mmap_sem) | if (mc.moving_task) -> cannot aquire the lock | -> true | schedule() Ex.2) move charge | try charge --------------------------------------+------------------------------ mem_cgroup_can_attach() | mc.moving_task = current | mem_cgroup_precharge_mc() | mem_cgroup_count_precharge() | down_read(&mmap_sem) | .. | up_read(&mmap_sem) | | down_write(&mmap_sem) mem_cgroup_move_task() | .. mem_cgroup_move_charge() | __mem_cgroup_try_charge() down_read(&mmap_sem) | prepare_to_wait() -> cannot aquire the lock | if (mc.moving_task) | -> true | schedule() To avoid this deadlock, we do all the move charge works (both can_attach() and attach()) under one mmap_sem section. And after this patch, we set/clear mc.moving_task outside mc.lock, because we use the lock only to check mc.from/to. Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 11e7946
File | Mode | Size |
---|---|---|
Kconfig | -rw-r--r-- | 2.3 KB |
Makefile | -rw-r--r-- | 301 bytes |
xfrm_algo.c | -rw-r--r-- | 13.3 KB |
xfrm_hash.c | -rw-r--r-- | 766 bytes |
xfrm_hash.h | -rw-r--r-- | 3.0 KB |
xfrm_input.c | -rw-r--r-- | 6.0 KB |
xfrm_ipcomp.c | -rw-r--r-- | 7.6 KB |
xfrm_output.c | -rw-r--r-- | 4.5 KB |
xfrm_policy.c | -rw-r--r-- | 69.9 KB |
xfrm_proc.c | -rw-r--r-- | 3.1 KB |
xfrm_state.c | -rw-r--r-- | 55.3 KB |
xfrm_sysctl.c | -rw-r--r-- | 1.7 KB |
xfrm_user.c | -rw-r--r-- | 66.0 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...