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-- | 248 bytes |
Makefile | -rw-r--r-- | 992 bytes |
af_llc.c | -rw-r--r-- | 30.7 KB |
llc_c_ac.c | -rw-r--r-- | 35.4 KB |
llc_c_ev.c | -rw-r--r-- | 21.3 KB |
llc_c_st.c | -rw-r--r-- | 149.8 KB |
llc_conn.c | -rw-r--r-- | 27.2 KB |
llc_core.c | -rw-r--r-- | 4.2 KB |
llc_if.c | -rw-r--r-- | 4.4 KB |
llc_input.c | -rw-r--r-- | 5.5 KB |
llc_output.c | -rw-r--r-- | 2.4 KB |
llc_pdu.c | -rw-r--r-- | 10.6 KB |
llc_proc.c | -rw-r--r-- | 6.6 KB |
llc_s_ac.c | -rw-r--r-- | 5.9 KB |
llc_s_ev.c | -rw-r--r-- | 3.5 KB |
llc_s_st.c | -rw-r--r-- | 5.7 KB |
llc_sap.c | -rw-r--r-- | 11.4 KB |
llc_station.c | -rw-r--r-- | 20.7 KB |
sysctl_net_llc.c | -rw-r--r-- | 2.0 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...