]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
memcg: fix deadlock between lock_page_cgroup and mapping tree_lock
authorDaisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Thu, 28 May 2009 21:34:28 +0000 (14:34 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 29 May 2009 15:40:02 +0000 (08:40 -0700)
commite767e0561d7fd2333df1921f1ab4176211f9036b
tree3b936733f80ceb1ee61ce99f927d002d2296250e
parentbd6daba909d8484bd2ccf6017db4028d7a420927
memcg: fix deadlock between lock_page_cgroup and mapping tree_lock

mapping->tree_lock can be acquired from interrupt context.  Then,
following dead lock can occur.

Assume "A" as a page.

 CPU0:
       lock_page_cgroup(A)
interrupted
-> take mapping->tree_lock.
 CPU1:
       take mapping->tree_lock
-> lock_page_cgroup(A)

This patch tries to fix above deadlock by moving memcg's hook to out of
mapping->tree_lock.  charge/uncharge of pagecache/swapcache is protected
by page lock, not tree_lock.

After this patch, lock_page_cgroup() is not called under mapping->tree_lock.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/swap.h
mm/filemap.c
mm/memcontrol.c
mm/swap_state.c
mm/truncate.c
mm/vmscan.c