Tejun Heo
154b454eda
memcg: don't register hotcpu notifier from ->css_alloc()
Commit 648bb56d076b ("cgroup: lock cgroup_mutex in cgroup_init_subsys()")
made cgroup_init_subsys() grab cgroup_mutex before invoking
->css_alloc() for the root css. Because memcg registers hotcpu notifier
from ->css_alloc() for the root css, this introduced circular locking
dependency between cgroup_mutex and cpu hotplug.
Fix it by moving hotcpu notifier registration to a subsys initcall.
======================================================
[ INFO: possible circular locking dependency detected ]
3.7.0-rc4-work+ #42 Not tainted
-------------------------------------------------------
bash/645 is trying to acquire lock:
(cgroup_mutex){+.+.+.}, at: [<ffffffff8110c5b7>] cgroup_lock+0x17/0x20
but task is already holding lock:
(cpu_hotplug.lock){+.+.+.}, at: [<ffffffff8109300f>] cpu_hotplug_begin+0x2f/0x60
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (cpu_hotplug.lock){+.+.+.}:
lock_acquire+0x97/0x1e0
mutex_lock_nested+0x61/0x3b0
get_online_cpus+0x3c/0x60
rebuild_sched_domains_locked+0x1b/0x70
cpuset_write_resmask+0x298/0x2c0
cgroup_file_write+0x1ef/0x300
vfs_write+0xa8/0x160
sys_write+0x52/0xa0
system_call_fastpath+0x16/0x1b
-> #0 (cgroup_mutex){+.+.+.}:
__lock_acquire+0x14ce/0x1d20
lock_acquire+0x97/0x1e0
mutex_lock_nested+0x61/0x3b0
cgroup_lock+0x17/0x20
cpuset_handle_hotplug+0x1b/0x560
cpuset_update_active_cpus+0xe/0x10
cpuset_cpu_inactive+0x47/0x50
notifier_call_chain+0x66/0x150
__raw_notifier_call_chain+0xe/0x10
__cpu_notify+0x20/0x40
_cpu_down+0x7e/0x2f0
cpu_down+0x36/0x50
store_online+0x5d/0xe0
dev_attr_store+0x18/0x30
sysfs_write_file+0xe0/0x150
vfs_write+0xa8/0x160
sys_write+0x52/0xa0
system_call_fastpath+0x16/0x1b
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(cpu_hotplug.lock);
lock(cgroup_mutex);
lock(cpu_hotplug.lock);
lock(cgroup_mutex);
*** DEADLOCK ***
5 locks held by bash/645:
#0: (&buffer->mutex){+.+.+.}, at: [<ffffffff8123bab8>] sysfs_write_file+0x48/0x150
#1: (s_active#42){.+.+.+}, at: [<ffffffff8123bb38>] sysfs_write_file+0xc8/0x150
#2: (x86_cpu_hotplug_driver_mutex){+.+...}, at: [<ffffffff81079277>] cpu_hotplug_driver_lock+0x1
+7/0x20
#3: (cpu_add_remove_lock){+.+.+.}, at: [<ffffffff81093157>] cpu_maps_update_begin+0x17/0x20
#4: (cpu_hotplug.lock){+.+.+.}, at: [<ffffffff8109300f>] cpu_hotplug_begin+0x2f/0x60
stack backtrace:
Pid: 645, comm: bash Not tainted 3.7.0-rc4-work+ #42
Call Trace:
print_circular_bug+0x28e/0x29f
__lock_acquire+0x14ce/0x1d20
lock_acquire+0x97/0x1e0
mutex_lock_nested+0x61/0x3b0
cgroup_lock+0x17/0x20
cpuset_handle_hotplug+0x1b/0x560
cpuset_update_active_cpus+0xe/0x10
cpuset_cpu_inactive+0x47/0x50
notifier_call_chain+0x66/0x150
__raw_notifier_call_chain+0xe/0x10
__cpu_notify+0x20/0x40
_cpu_down+0x7e/0x2f0
cpu_down+0x36/0x50
store_online+0x5d/0xe0
dev_attr_store+0x18/0x30
sysfs_write_file+0xe0/0x150
vfs_write+0xa8/0x160
sys_write+0x52/0xa0
system_call_fastpath+0x16/0x1b
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-12-20 17:40:20 -08:00
..
2012-12-17 11:29:09 -08:00
2012-12-11 17:22:26 -08:00
2012-12-12 17:38:35 -08:00
2012-07-18 16:40:35 -04:00
2012-05-29 23:28:33 -04:00
2012-12-20 17:40:18 -08:00
2011-12-06 09:24:07 +01:00
2012-12-11 17:22:24 -08:00
2012-09-26 22:20:08 -04:00
2012-01-03 22:54:56 -05:00
2012-10-09 16:22:58 +09:00
2012-10-09 16:22:47 +09:00
2012-10-19 13:37:57 -07:00
2012-09-21 10:38:12 -04:00
2012-12-20 08:37:05 -08:00
2012-12-20 17:40:20 -08:00
2012-12-18 15:02:15 -08:00
2012-12-18 15:02:15 -08:00
2012-07-31 18:42:43 -07:00
2011-07-26 16:49:47 -07:00
2012-12-16 15:18:08 -08:00
2012-10-09 16:22:42 +09:00
2012-12-18 15:02:12 -08:00
2012-01-10 16:30:42 -08:00
2011-01-27 18:31:51 +00:00
2012-12-18 15:02:15 -08:00
2012-12-20 07:06:56 -08:00
2011-10-31 09:20:12 -04:00
2012-10-09 16:22:18 +09:00
2012-12-11 17:22:26 -08:00
2012-10-24 11:52:21 -07:00
2012-12-20 17:40:20 -08:00
2012-12-18 15:02:15 -08:00
2012-12-16 15:18:08 -08:00
2012-12-17 17:15:17 -08:00
2012-12-16 15:18:08 -08:00
2012-06-25 11:53:47 +02:00
2012-12-17 19:37:03 -08:00
2012-03-21 17:54:54 -07:00
2012-10-09 16:23:03 +09:00
2011-10-31 09:20:12 -04:00
2012-12-16 15:18:08 -08:00
2012-03-21 17:54:59 -07:00
2012-10-25 14:37:53 -07:00
2012-11-16 14:33:04 -08:00
2012-12-18 15:02:15 -08:00
2012-12-16 15:18:08 -08:00
2012-12-12 17:38:34 -08:00
2012-11-15 15:41:22 -08:00
2012-12-12 17:38:34 -08:00
2012-12-20 17:40:19 -08:00
2012-12-12 17:38:32 -08:00
2012-07-31 18:42:47 -07:00
2012-12-11 17:22:22 -08:00
2012-12-20 17:40:18 -08:00
2012-12-12 17:38:31 -08:00
2010-10-02 10:28:42 +03:00
2012-06-20 14:39:36 -07:00
2012-12-02 06:23:04 -08:00
2012-12-11 14:28:34 +00:00
2012-05-31 17:49:32 -07:00
2011-10-31 09:20:11 -04:00
2012-09-26 22:20:08 -04:00
2012-12-16 15:18:08 -08:00
2012-12-17 17:15:12 -08:00
2012-12-18 15:02:14 -08:00
2012-12-18 15:02:15 -08:00
2012-12-18 15:02:14 -08:00
2012-12-18 15:02:14 -08:00
2012-12-18 15:02:15 -08:00
2011-10-31 09:20:11 -04:00
2012-12-11 17:22:23 -08:00
2012-07-31 18:42:47 -07:00
2012-10-09 16:22:55 +09:00
2012-12-11 17:22:27 -08:00
2012-10-09 16:22:56 +09:00
2012-10-28 19:29:19 +01:00
2012-12-11 17:22:22 -08:00
2012-12-20 07:06:56 -08:00
2012-12-16 15:18:08 -08:00