From patchwork Fri Nov 2 02:31:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyufen X-Patchwork-Id: 10664893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 570CA15E9 for ; Fri, 2 Nov 2018 02:32:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 437082BEC9 for ; Fri, 2 Nov 2018 02:32:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 373122BF30; Fri, 2 Nov 2018 02:32:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CEC172BEC9 for ; Fri, 2 Nov 2018 02:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=17dvz/etmW3NYgU+qYaXgkTpIlnqw47xEzDMiISUTRw=; b=koMGQD6LNCv6I2 7pBO+65ANiB/zn8aQMD1NS8yisCEm5drAULrd8uw8ZoDMaPKZIV7p4i5LvT7oZliWYYQceJxDZ4Y4 M6NDAXFiulxMMxZs7bP7hdzH92+Z1r6ayzWBT9MZ6Qh3+jhJBrVp4ZaJKCspGbrEVzHNmgqCrkM/R b0BFXSZl4tzUVCZRuLlAPBmMZ0qgCQF8Plip+W6bLEbG4Rb+FvevXxpHc8EyE1egPVSWG4SLy562X Vbc0pIgEBm/RrQHtdYf/pB7ZD9zfG9eD5qDxEYGmfg5mFok2187Sc9eWOrfT7rw91nasvNlOONaNv WJzvNXM9esJL1tT7zAqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIPG6-0005B2-CW; Fri, 02 Nov 2018 02:32:26 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIPG3-0004yt-FD for linux-arm-kernel@lists.infradead.org; Fri, 02 Nov 2018 02:32:24 +0000 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 52B7176F246D1; Fri, 2 Nov 2018 10:32:08 +0800 (CST) Received: from [127.0.0.1] (10.177.25.132) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Fri, 2 Nov 2018 10:31:59 +0800 Subject: [PATCH v2] ARM:kexec:offline panic_smp_self_stop CPU To: Russell King - ARM Linux References: <1541071249-15660-1-git-send-email-wangyufen@huawei.com> <20181101113430.GO30658@n2100.armlinux.org.uk> From: wangyufen Message-ID: <5BDBB6FF.6080907@huawei.com> Date: Fri, 2 Nov 2018 10:31:27 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20181101113430.GO30658@n2100.armlinux.org.uk> X-Originating-IP: [10.177.25.132] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181101_193223_675675_06F4DEEA X-CRM114-Status: GOOD ( 10.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kstewart@linuxfoundation.org, Wangyufen , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, rppt@linux.vnet.ibm.com, weiyongjun1@huawei.com, huawei.libin@huawei.com, pombredanne@nexb.com, akpm@linux-foundation.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In case panic() and panic() called at the same time on different CPUS. For example: CPU 0: panic() __crash_kexec machine_crash_shutdown crash_smp_send_stop machine_kexec BUG_ON(num_online_cpus() > 1); CPU 1: panic() local_irq_disable panic_smp_self_stop If CPU 1 calls panic_smp_self_stop() before crash_smp_send_stop(), kdump fails. CPU1 can't receive the ipi irq, CPU1 will be always online. To fix this problem, this patch split out the panic_smp_self_stop() and add set_cpu_online(smp_processor_id(), false). Signed-off-by: Yufen Wang --- arch/arm/kernel/smp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 9000d8b..d7b86e4 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -682,6 +682,21 @@ void smp_send_stop(void) pr_warn("SMP: failed to stop secondary CPUs\n"); } +/* In case panic() and panic() called at the same time on CPU1 and CPU2, + * and CPU 1 calls panic_smp_self_stop() before crash_smp_send_stop() + * CPU1 can't receive the ipi irqs from CPU2, CPU1 will be always online, + * kdump fails. So split out the panic_smp_self_stop() and add + * set_cpu_online(smp_processor_id(), false). + */ +void panic_smp_self_stop(void) +{ + pr_debug("CPU %u will stop doing anything useful since another CPU has paniced\n", + smp_processor_id()); + set_cpu_online(smp_processor_id(), false); + while (1) + cpu_relax(); +} + /* * not supported here */