Daisuke Nishimura 7f4d454dee memcg: avoid deadlock caused by race between oom and cpuset_attach
mpol_rebind_mm(), which can be called from cpuset_attach(), does
down_write(mm->mmap_sem).  This means down_write(mm->mmap_sem) can be
called under cgroup_mutex.

OTOH, page fault path does down_read(mm->mmap_sem) and calls
mem_cgroup_try_charge_xxx(), which may eventually calls
mem_cgroup_out_of_memory().  And mem_cgroup_out_of_memory() calls
cgroup_lock().  This means cgroup_lock() can be called under
down_read(mm->mmap_sem).

If those two paths race, deadlock can happen.

This patch avoid this deadlock by:
  - remove cgroup_lock() from mem_cgroup_out_of_memory().
  - define new mutex (memcg_tasklist) and serialize mem_cgroup_move_task()
    (->attach handler of memory cgroup) and mem_cgroup_out_of_memory.

Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-08 08:31:09 -08:00
..
2008-12-29 11:27:46 +02:00
2009-01-08 08:31:06 -08:00
2009-01-06 15:59:14 -08:00
2009-01-06 15:59:08 -08:00
2009-01-08 08:31:06 -08:00
2008-11-14 11:29:12 +11:00
2009-01-08 08:31:04 -08:00
2008-04-28 08:58:18 -07:00
2009-01-06 15:59:10 -08:00
2008-07-28 16:30:21 -07:00
2009-01-05 17:44:42 -08:00
2009-01-05 11:54:28 -05:00
2009-01-05 11:54:28 -05:00
2009-01-08 08:31:07 -08:00
2009-01-08 08:31:05 -08:00
2008-06-12 18:05:41 -07:00
2009-01-01 10:12:29 +10:30
2009-01-08 08:31:06 -08:00
2009-01-01 10:12:29 +10:30
2008-11-30 10:03:35 -08:00
2009-01-08 08:31:05 -08:00
2009-01-08 08:31:08 -08:00
2009-01-08 08:31:06 -08:00
2009-01-01 10:12:29 +10:30