From patchwork Mon Aug 7 05:09:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9884403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71A3E60363 for ; Mon, 7 Aug 2017 05:16:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69C0F284FC for ; Mon, 7 Aug 2017 05:16:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E29628558; Mon, 7 Aug 2017 05:16:43 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 E2C91284FC for ; Mon, 7 Aug 2017 05:16:41 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=q1Sgncl5+1Ga7+PXIm1JgfWw7x3JFD5LOC1v/XGWg3w=; b=luf +NAcQyf4xx4RZqKqJEAxw4Wng82h2HVU5rP/J7OBwlgqnZZqBwpQVN3DeqXL4W88yBeQL/ETApSkn z4uXawWP1JIw+fe7T27yIBZncL6QXQ55eelWlnIQPd2ZJYRxZAfimwIZlNCMca6hioP8sBT+K7Fal NyrITzZQUcvSasPFUDKOAQZ9RwBC/uP5v997W1m/urGF2LESJEpDQ+dfd/xCvNIAThQrqLkZGTruG OpiJYm7eWN1Onthj9+/Z4lzTUaq0SnvGusRFO4jalRpupi3OrOvQOycKSVG+dUib46pvjm6Rk1XCC IOerqmzZ+b8Jjj106Y26iHlmYdzGdXg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1deaOp-0005nm-G3; Mon, 07 Aug 2017 05:16:19 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1deaOl-0005mL-KW for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2017 05:16:17 +0000 Received: by mail-pf0-x241.google.com with SMTP id p13so7998550pfd.4 for ; Sun, 06 Aug 2017 22:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PsOmXsHFdGhg7ReDZ7oIqqAG9dBiDkHYyp4sXQynfPY=; b=cEDCVhh9RHB5DSjWlIaaj1fln052Yv+OjLVShRXx+8c67JhxDxLMZ+FnF/rrOK/QQ8 VEvhCr4iqch5s4br5yLwuI8fMShPxqeOrR++gGPKAO6jCeQcJ6vkpIFwsO90P9cvh/W1 P+wg9SZELLXlMFBC6OBOSgFqN1JXkKhVfLgIo1yEt5J3GHqb7mazb2RXCjRg4fB3mQwk 9/ZykMOI8AaFYBgUEdsnNEmQI4undkxkejxGGF9mUPFThHoa2dtV5uq5F5GeJPROx16G CaKCqljUoSBeS0E+E7JZJiXIaK5fGDLXNOPekmJxmMze8+uhSX9h0KfEW3/sMZmqdEEr 51qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PsOmXsHFdGhg7ReDZ7oIqqAG9dBiDkHYyp4sXQynfPY=; b=JXATGhEd+QoxcrzFKmuKe7rViyNzLgFPUSdvarfCnVm0lDwE9TV7QYufgvFY6hegSf BVWE+g6Fypmc0tZ+bAb18AcAIPIkSi0yZoVhFfSP18dY2Bro7d9DAcSVPqeaiNL2xziv JnfWuL7ysCnaH9QES64nvrE6C7JkbCyH3isWBnfG6AkYu/Wtl6JP6eV3YO3wxZdYVYTd aaGjDpu+MNr+4kDB4hOZ+YAUVlbiwAoru8S0PZLNfJEDGSaW/oE3hj+RuKkHZyzKj4+q 3Hd+tJqKtZmu4ygzCDZPm06E0Kj+6P6I+GW/wC/mGTsYHyKf8WLQqn0cdVvrhI4qizUh EKfw== X-Gm-Message-State: AIVw110pLQ7hvBYyQO2bffZHAuei9O6eCoUUtvOKOPrq0bWyVwBeAZ8e z3or+0vmsqjgBw== X-Received: by 10.99.113.7 with SMTP id m7mr10683656pgc.55.1502082952927; Sun, 06 Aug 2017 22:15:52 -0700 (PDT) Received: from hryu-OptiPlex-9020.corp.ad.wrs.com ([61.107.31.52]) by smtp.gmail.com with ESMTPSA id w6sm14677199pgt.38.2017.08.06.22.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 06 Aug 2017 22:15:51 -0700 (PDT) From: Hoeun Ryu To: Catalin Marinas , Will Deacon , Mark Rutland , AKASHI Takahiro , Robin Murphy , James Morse , Ard Biesheuvel , Ingo Molnar , "Peter Zijlstra (Intel)" , Suzuki K Poulose , David Daney , Rob Herring , Kefeng Wang , Thomas Gleixner Subject: [PATCHv2] arm64:kexec: have own crash_smp_send_stop() for crash dump for nonpanic cores Date: Mon, 7 Aug 2017 14:09:22 +0900 Message-Id: <1502082623-23952-1-git-send-email-hoeun.ryu@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170806_221615_712036_37D99D6D X-CRM114-Status: GOOD ( 14.50 ) 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: Hoeun Ryu , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 Commit 0ee5941 : (x86/panic: replace smp_send_stop() with kdump friendly version in panic path) introduced crash_smp_send_stop() which is a weak function and can be overriden by architecture codes to fix the side effect caused by commit f06e515 : (kernel/panic.c: add "crash_kexec_post_ notifiers" option). ARM64 architecture uses the weak version function and the problem is that the weak function simply calls smp_send_stop() which makes other CPUs offline and takes away the chance to save crash information for nonpanic CPUs in machine_crash_shutdown() when crash_kexec_post_notifiers kernel option is enabled. Calling smp_send_crash_stop() in machine_crash_shutdown() is useless because all nonpanic CPUs are already offline by smp_send_stop() in this case and smp_send_crash_stop() only works against online CPUs. The result is that /proc/vmcore is not available with the error messages; "Warning: Zero PT_NOTE entries found", "Kdump: vmcore not initialized". crash_smp_send_stop() is implemented to fix this problem by replacing the exising smp_send_crash_stop() and adding a check for multiple calling to the function. The function (strong symbol version) saves crash information for nonpanic CPUs and machine_crash_shutdown() tries to save crash information for nonpanic CPUs only when crash_kexec_post_notifiers kernel option is disabled. * crash_kexec_post_notifiers : false panic() __crash_kexec() machine_crash_shutdown() crash_smp_send_stop() <= save crash dump for nonpanic cores * crash_kexec_post_notifiers : true panic() crash_smp_send_stop() <= save crash dump for nonpanic cores __crash_kexec() machine_crash_shutdown() crash_smp_send_stop() <= just return. Signed-off-by: Hoeun Ryu Reviewed-by: James Morse Tested-by: James Morse --- v2: - replace the existing smp_send_crash_stop() with crash_smp_send_stop() and adding called-twice logic to it. - modify the commit message arch/arm64/include/asm/smp.h | 2 +- arch/arm64/kernel/machine_kexec.c | 2 +- arch/arm64/kernel/smp.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index 55f08c5..f82b447 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -148,7 +148,7 @@ static inline void cpu_panic_kernel(void) */ bool cpus_are_stuck_in_kernel(void); -extern void smp_send_crash_stop(void); +extern void crash_smp_send_stop(void); extern bool smp_crash_stop_failed(void); #endif /* ifndef __ASSEMBLY__ */ diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index 481f54a..11121f6 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -252,7 +252,7 @@ void machine_crash_shutdown(struct pt_regs *regs) local_irq_disable(); /* shutdown non-crashing cpus */ - smp_send_crash_stop(); + crash_smp_send_stop(); /* for crashing cpu */ crash_save_cpu(regs, smp_processor_id()); diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index dc66e6e..73d8f5e 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -977,11 +977,21 @@ void smp_send_stop(void) } #ifdef CONFIG_KEXEC_CORE -void smp_send_crash_stop(void) +void crash_smp_send_stop(void) { + static int cpus_stopped; cpumask_t mask; unsigned long timeout; + /* + * This function can be called twice in panic path, but obviously + * we execute this only once. + */ + if (cpus_stopped) + return; + + cpus_stopped = 1; + if (num_online_cpus() == 1) return;