diff options
author | Oleg Nesterov <oleg@redhat.com> | 2016-07-26 14:57:36 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-07-27 05:12:11 -0400 |
commit | ce4f06dcbb5d6d04d202f1b81ac72d5679dcdfc0 (patch) | |
tree | 5f7b351d9cfc0374eeacc3c1034fd7effd5bd9ff /kernel | |
parent | 5cada17426505b09a045cd9e6d7fb6db19b76ea1 (diff) |
stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE
Suppose that stop_machine(fn) hangs because fn() hangs. In this case NMI
hard-lockup can be triggered on another CPU which does nothing wrong and
the trace from nmi_panic() won't help to investigate the problem.
And this change "fixes" the problem we (seem to) hit in practice.
- stop_two_cpus(0, 1) races with show_state_filter() running on CPU_0.
- CPU_1 already spins in MULTI_STOP_PREPARE state, it detects the soft
lockup and tries to report the problem.
- show_state_filter() enables preemption, CPU_0 calls multi_cpu_stop()
which goes to MULTI_STOP_DISABLE_IRQ state and disables interrupts.
- CPU_1 spends more than 10 seconds trying to flush the log buffer to
the slow serial console.
- NMI interrupt on CPU_0 (which now waits for CPU_1) calls nmi_panic().
Reported-by: Wang Shu <shuwang@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Anderson <anderson@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20160726185736.GB4088@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/stop_machine.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index a467e6c28a3b..4a1ca5f6da7e 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/smpboot.h> | 21 | #include <linux/smpboot.h> |
22 | #include <linux/atomic.h> | 22 | #include <linux/atomic.h> |
23 | #include <linux/lglock.h> | 23 | #include <linux/lglock.h> |
24 | #include <linux/nmi.h> | ||
24 | 25 | ||
25 | /* | 26 | /* |
26 | * Structure to determine completion condition and record errors. May | 27 | * Structure to determine completion condition and record errors. May |
@@ -209,6 +210,13 @@ static int multi_cpu_stop(void *data) | |||
209 | break; | 210 | break; |
210 | } | 211 | } |
211 | ack_state(msdata); | 212 | ack_state(msdata); |
213 | } else if (curstate > MULTI_STOP_PREPARE) { | ||
214 | /* | ||
215 | * At this stage all other CPUs we depend on must spin | ||
216 | * in the same loop. Any reason for hard-lockup should | ||
217 | * be detected and reported on their side. | ||
218 | */ | ||
219 | touch_nmi_watchdog(); | ||
212 | } | 220 | } |
213 | } while (curstate != MULTI_STOP_EXIT); | 221 | } while (curstate != MULTI_STOP_EXIT); |
214 | 222 | ||