John Stultz
db751fe3ea
cpuset: Fix potential deadlock w/ set_mems_allowed
After adding lockdep support to seqlock/seqcount structures,
I started seeing the following warning:
[ 1.070907] ======================================================
[ 1.072015] [ INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected ]
[ 1.073181] 3.11.0+ #67 Not tainted
[ 1.073801] ------------------------------------------------------
[ 1.074882] kworker/u4:2/708 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
[ 1.076088] (&p->mems_allowed_seq){+.+...}, at: [<ffffffff81187d7f>] new_slab+0x5f/0x280
[ 1.077572]
[ 1.077572] and this task is already holding:
[ 1.078593] (&(&q->__queue_lock)->rlock){..-...}, at: [<ffffffff81339f03>] blk_execute_rq_nowait+0x53/0xf0
[ 1.080042] which would create a new lock dependency:
[ 1.080042] (&(&q->__queue_lock)->rlock){..-...} -> (&p->mems_allowed_seq){+.+...}
[ 1.080042]
[ 1.080042] but this new dependency connects a SOFTIRQ-irq-safe lock:
[ 1.080042] (&(&q->__queue_lock)->rlock){..-...}
[ 1.080042] ... which became SOFTIRQ-irq-safe at:
[ 1.080042] [<ffffffff810ec179>] __lock_acquire+0x5b9/0x1db0
[ 1.080042] [<ffffffff810edfe5>] lock_acquire+0x95/0x130
[ 1.080042] [<ffffffff818968a1>] _raw_spin_lock+0x41/0x80
[ 1.080042] [<ffffffff81560c9e>] scsi_device_unbusy+0x7e/0xd0
[ 1.080042] [<ffffffff8155a612>] scsi_finish_command+0x32/0xf0
[ 1.080042] [<ffffffff81560e91>] scsi_softirq_done+0xa1/0x130
[ 1.080042] [<ffffffff8133b0f3>] blk_done_softirq+0x73/0x90
[ 1.080042] [<ffffffff81095dc0>] __do_softirq+0x110/0x2f0
[ 1.080042] [<ffffffff81095fcd>] run_ksoftirqd+0x2d/0x60
[ 1.080042] [<ffffffff810bc506>] smpboot_thread_fn+0x156/0x1e0
[ 1.080042] [<ffffffff810b3916>] kthread+0xd6/0xe0
[ 1.080042] [<ffffffff818980ac>] ret_from_fork+0x7c/0xb0
[ 1.080042]
[ 1.080042] to a SOFTIRQ-irq-unsafe lock:
[ 1.080042] (&p->mems_allowed_seq){+.+...}
[ 1.080042] ... which became SOFTIRQ-irq-unsafe at:
[ 1.080042] ... [<ffffffff810ec1d3>] __lock_acquire+0x613/0x1db0
[ 1.080042] [<ffffffff810edfe5>] lock_acquire+0x95/0x130
[ 1.080042] [<ffffffff810b3df2>] kthreadd+0x82/0x180
[ 1.080042] [<ffffffff818980ac>] ret_from_fork+0x7c/0xb0
[ 1.080042]
[ 1.080042] other info that might help us debug this:
[ 1.080042]
[ 1.080042] Possible interrupt unsafe locking scenario:
[ 1.080042]
[ 1.080042] CPU0 CPU1
[ 1.080042] ---- ----
[ 1.080042] lock(&p->mems_allowed_seq);
[ 1.080042] local_irq_disable();
[ 1.080042] lock(&(&q->__queue_lock)->rlock);
[ 1.080042] lock(&p->mems_allowed_seq);
[ 1.080042] <Interrupt>
[ 1.080042] lock(&(&q->__queue_lock)->rlock);
[ 1.080042]
[ 1.080042] *** DEADLOCK ***
The issue stems from the kthreadd() function calling set_mems_allowed
with irqs enabled. While its possibly unlikely for the actual deadlock
to trigger, a fix is fairly simple: disable irqs before taking the
mems_allowed_seq lock.
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/1381186321-4906-4-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2013-11-06 12:40:27 +01:00
..
2013-09-02 11:49:56 +05:30
2013-09-26 14:02:33 -04:00
2013-09-09 11:15:49 -07:00
2013-09-06 13:21:16 -07:00
2013-09-09 16:35:29 -07:00
2013-09-10 13:33:09 -07:00
2013-09-05 14:54:29 -07:00
2013-10-10 09:23:59 -07:00
2013-08-30 21:37:01 +01:00
2013-09-16 20:35:55 +02:00
2013-09-12 11:35:33 -07:00
2013-08-30 17:34:52 -07:00
2013-09-10 13:03:41 -07:00
2013-09-17 11:49:25 +01:00
2013-11-06 07:50:37 +01:00
2013-09-10 13:33:09 -07:00
2013-09-10 20:04:59 -07:00
2013-10-17 09:34:30 -07:00
2013-09-11 15:58:04 -07:00
2013-09-30 14:31:02 -07:00
2013-09-11 15:59:04 -07:00
2013-09-21 13:57:47 -06:00
2013-09-04 09:23:46 -04:00
2013-08-30 23:44:11 -07:00
2013-09-11 15:56:57 -07:00
2013-09-11 15:58:25 -07:00
2013-10-11 07:39:14 +02:00
2013-11-06 07:49:19 +01:00
2013-09-13 15:09:52 +02:00
2013-09-10 02:54:50 +02:00
2013-11-06 12:40:27 +01:00
2013-09-11 15:59:10 -07:00
2013-09-07 12:56:26 +10:00
2013-09-10 18:56:29 -04:00
2013-09-20 10:36:34 -04:00
2013-09-09 10:26:33 -07:00
2013-09-10 13:37:36 -07:00
2013-09-03 20:57:49 -04:00
2013-09-07 19:54:57 -04:00
2013-10-07 15:16:45 -04:00
2013-09-12 10:12:47 -07:00
2013-09-13 23:06:40 -04:00
2013-09-06 09:17:30 +01:00
2013-09-06 09:17:30 +01:00
2013-09-03 07:41:11 +02:00
2013-09-11 15:57:35 -07:00
2013-09-25 14:07:54 +02:00
2013-09-13 15:11:21 +02:00
2013-09-12 15:38:03 -07:00
2013-09-11 15:57:49 -07:00
2013-09-26 14:20:21 -07:00
2013-11-06 12:40:26 +01:00
2013-09-11 15:59:37 -07:00
2013-09-24 13:04:07 +02:00
2013-09-13 15:09:52 +02:00
2013-11-03 10:53:11 -08:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-20 15:38:26 -04:00
2013-09-11 15:58:52 -07:00
2013-09-17 12:52:31 +03:00
2013-09-10 18:56:32 -04:00
2013-11-06 12:40:26 +01:00
2013-09-07 15:49:18 -07:00
2013-09-11 15:59:45 -07:00
2013-09-11 15:57:51 -07:00
2013-10-16 21:35:53 -07:00
2013-10-09 12:40:38 +02:00
2013-10-09 12:40:32 +02:00
2013-09-26 11:03:29 +02:00
2013-09-11 15:58:01 -07:00
2013-10-09 14:48:18 +02:00
2013-10-09 14:47:47 +02:00
2013-09-11 15:58:01 -07:00
2013-09-07 09:48:41 -07:00
2013-09-03 16:35:47 +09:30
2013-09-28 12:46:21 +02:00
2013-09-08 20:20:23 -04:00
2013-10-07 12:29:26 -04:00
2013-09-06 14:49:16 -04:00
2013-09-03 15:26:29 -04:00
2013-09-26 10:20:18 -04:00
2013-09-03 16:40:32 -04:00
2013-09-10 13:53:52 -07:00
2013-09-24 21:12:32 -05:00
2013-09-10 13:53:52 -07:00
2013-09-03 22:52:48 -04:00
2013-10-09 14:47:45 +02:00
2013-09-05 14:54:29 -07:00
2013-09-15 17:41:30 -04:00
2013-09-06 13:30:06 -07:00
2013-09-09 14:29:15 -07:00
2013-10-30 14:27:03 -07:00
2013-10-04 09:58:53 +02:00
2013-09-25 14:23:07 +02:00
2013-09-11 15:59:36 -07:00
2013-09-11 15:59:37 -07:00
2013-09-23 06:35:06 -04:00
2013-09-11 15:59:20 -07:00
2013-09-23 09:13:49 -07:00
2013-09-25 06:45:06 -07:00
2013-09-25 06:45:06 -07:00
2013-09-25 06:45:06 -07:00
2013-09-03 10:07:40 -07:00
2013-09-12 15:38:02 -07:00
2013-11-01 08:24:41 +01:00
2013-11-06 12:40:26 +01:00
2013-09-10 18:56:32 -04:00
2013-09-01 14:16:33 -07:00
2013-09-30 22:32:39 -07:00
2013-09-04 20:51:33 +03:00
2013-09-04 23:11:42 +03:00
2013-09-04 20:53:16 +03:00
2013-09-24 17:00:25 -07:00
2013-08-30 17:26:09 -04:00
2013-10-09 12:40:45 +02:00
2013-09-12 15:38:02 -07:00
2013-09-11 15:58:25 -07:00
2013-09-03 09:10:24 -04:00
2013-09-25 13:53:10 +02:00
2013-10-10 12:31:43 -07:00
2013-09-20 12:03:46 +02:00
2013-10-04 10:16:25 +02:00
2013-11-06 12:40:25 +01:00
2013-09-25 14:07:54 +02:00
2013-10-16 13:32:04 -07:00
2013-09-07 14:35:32 -07:00
2013-10-11 15:19:22 +10:00
2013-09-11 15:57:09 -07:00
2013-09-03 18:25:03 -07:00
2013-09-11 15:58:01 -07:00
2013-11-01 08:42:44 +01:00
2013-09-11 15:58:02 -07:00
2013-10-17 15:53:09 -04:00