From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755362AbcG0Koz (ORCPT ); Wed, 27 Jul 2016 06:44:55 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39502 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752142AbcG0Koy (ORCPT ); Wed, 27 Jul 2016 06:44:54 -0400 Date: Wed, 27 Jul 2016 03:42:50 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: paulmck@linux.vnet.ibm.com, oleg@redhat.com, tj@kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, shuwang@redhat.com, peterz@infradead.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, anderson@redhat.com, torvalds@linux-foundation.org Reply-To: shuwang@redhat.com, peterz@infradead.org, anderson@redhat.com, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, tj@kernel.org In-Reply-To: <20160726185736.GB4088@redhat.com> References: <20160726185736.GB4088@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:core/urgent] stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE Git-Commit-ID: ce4f06dcbb5d6d04d202f1b81ac72d5679dcdfc0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ce4f06dcbb5d6d04d202f1b81ac72d5679dcdfc0 Gitweb: http://git.kernel.org/tip/ce4f06dcbb5d6d04d202f1b81ac72d5679dcdfc0 Author: Oleg Nesterov AuthorDate: Tue, 26 Jul 2016 20:57:36 +0200 Committer: Ingo Molnar CommitDate: Wed, 27 Jul 2016 11:12:11 +0200 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 Signed-off-by: Oleg Nesterov Reviewed-by: Thomas Gleixner Cc: Andrew Morton Cc: Dave Anderson Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Tejun Heo Link: http://lkml.kernel.org/r/20160726185736.GB4088@redhat.com Signed-off-by: Ingo Molnar --- kernel/stop_machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index a467e6c..4a1ca5f 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -21,6 +21,7 @@ #include #include #include +#include /* * Structure to determine completion condition and record errors. May @@ -209,6 +210,13 @@ static int multi_cpu_stop(void *data) break; } ack_state(msdata); + } else if (curstate > MULTI_STOP_PREPARE) { + /* + * At this stage all other CPUs we depend on must spin + * in the same loop. Any reason for hard-lockup should + * be detected and reported on their side. + */ + touch_nmi_watchdog(); } } while (curstate != MULTI_STOP_EXIT);