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 |
---|---|---|
auth_gss | ||
xprtrdma | ||
Kconfig | -rw-r--r-- | 1004 bytes |
Makefile | -rw-r--r-- | 541 bytes |
addr.c | -rw-r--r-- | 8.7 KB |
auth.c | -rw-r--r-- | 15.4 KB |
auth_generic.c | -rw-r--r-- | 4.5 KB |
auth_null.c | -rw-r--r-- | 2.5 KB |
auth_unix.c | -rw-r--r-- | 5.5 KB |
backchannel_rqst.c | -rw-r--r-- | 8.8 KB |
bc_svc.c | -rw-r--r-- | 2.0 KB |
cache.c | -rw-r--r-- | 42.3 KB |
clnt.c | -rw-r--r-- | 44.2 KB |
netns.h | -rw-r--r-- | 353 bytes |
rpc_pipe.c | -rw-r--r-- | 24.7 KB |
rpcb_clnt.c | -rw-r--r-- | 26.5 KB |
sched.c | -rw-r--r-- | 24.0 KB |
socklib.c | -rw-r--r-- | 4.5 KB |
stats.c | -rw-r--r-- | 6.8 KB |
sunrpc.h | -rw-r--r-- | 1.7 KB |
sunrpc_syms.c | -rw-r--r-- | 2.2 KB |
svc.c | -rw-r--r-- | 30.7 KB |
svc_xprt.c | -rw-r--r-- | 33.1 KB |
svcauth.c | -rw-r--r-- | 3.8 KB |
svcauth_unix.c | -rw-r--r-- | 22.1 KB |
svcsock.c | -rw-r--r-- | 40.0 KB |
sysctl.c | -rw-r--r-- | 3.5 KB |
timer.c | -rw-r--r-- | 2.9 KB |
xdr.c | -rw-r--r-- | 28.2 KB |
xprt.c | -rw-r--r-- | 31.0 KB |
xprtsock.c | -rw-r--r-- | 65.4 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...