From patchwork Fri Aug 4 06:34:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9880649 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 6CB7D60360 for ; Fri, 4 Aug 2017 06:39:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AED42864A for ; Fri, 4 Aug 2017 06:39:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E216289AC; Fri, 4 Aug 2017 06:39:36 +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 E5E842864A for ; Fri, 4 Aug 2017 06:39:35 +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=tZwE3xS0g/i/Obqfkl56atR26t5Jw0c8C49zZ1ZSHiU=; b=Q0c pRqNm/4ZhiwooEcmmhaHntRKFCvxyHIeD2UVRTsejFDD4mhBJXn9IJ7CHZ1DYNl+0PYKrwIUxWFKc x1q2IZOkmCEXFznRMj+PyYKpf8rier5m7sLiNpHdULS6VDWaKGx4hP930ZAOYf/xkGQkR/GojLPmu DvGbe6MZ/60LhfmHBYnuZ7h2NMfOVtVRsmUqwS8wtRV1R+XfA8Qv7qMlT+e1ycSijvo9Ky5h+XOVA lp7teFegLRxJtSvu4+r1YYbyVhKcTruWFH6vP5xIIdl2IPYaIgtg8MXqgWU1yNrD6Cx3KFTrS2Ba5 5m5Rl53AOncJUKIDn3D1UJVIIAk/2oQ==; 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 1ddWGZ-0005zC-Mc; Fri, 04 Aug 2017 06:39:23 +0000 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddWGW-0005yH-27 for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2017 06:39:22 +0000 Received: by mail-pg0-x241.google.com with SMTP id y192so950882pgd.1 for ; Thu, 03 Aug 2017 23:38:59 -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=5TqGExIKqQ7IZH990KFk8DANogJjXb128vlZEoWtSPM=; b=U8gRRsFf8Z76okN4K7NKzoCZqCFCF7vlixU4eIO+paR7ctFrTLhgtqn5Gp89SqFeOL p42z6/toVWBlTmEgKME9y6kqg5Tf+LIW8vDFVCGjWtghH0DfcuTneO4WD5GYytsF3XP3 BA79QUObOWO7BojSFBWsGbjz3R4jIKZGSfcYma99qtXaxazEbRQ28hq8dWoCT6sf/HBH PjfHBgPLmdlqeLgaXhZyKoq72i+G/gru/3fffO2jlJz5A+6VV8CJ24wNQrAw/a3LNtOI 8qPIYXhJwme5MIN0EC+ootlp9gg75FKW2h9mZY2UNWg+kv9vh4Pn3/WW9z1RQbWaC/5t gx5A== 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=5TqGExIKqQ7IZH990KFk8DANogJjXb128vlZEoWtSPM=; b=hl8DfSrZfUP2cEnh2LEg2WHhpzFRKuTaSG+Ne1otJMf2GXAurokaaW488OHLuKZF1D lxnji3z838nzIAGdt1fcVEif9/4VqNsZ0LATshvhrMpDcDfAZSVKcoNXWP65s0Kt8xAC X4Mi/SmlvajQVT+deVlpz28h47MUsqLf5EUjAOFJlMrp7z0GkBEbYZn+l4HsUH2AT5Ga SzA/8Q+peAVG86PgO9Bh/H2pfY1LEbf1ECdu0x48sfPK1y/aOiOctkOOYyuttQFmMtP8 0l6Ylzx8MOitgaylA/pT95xcZlrl4p6n2ojCvfbdsFf2/Fl60+M5fvGbQbRIRoOmZU2j nedQ== X-Gm-Message-State: AIVw113Y1TPbjMMGxcn6xDZiCQZs/oQLjvwIDspm2572zjz9Qa4NL0BD lD74w5CDbQqeJA== X-Received: by 10.84.211.150 with SMTP id c22mr1535778pli.372.1501828739001; Thu, 03 Aug 2017 23:38:59 -0700 (PDT) Received: from hryu-OptiPlex-9020.corp.ad.wrs.com ([61.107.31.52]) by smtp.gmail.com with ESMTPSA id z8sm1385980pfk.130.2017.08.03.23.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Aug 2017 23:38:58 -0700 (PDT) From: Hoeun Ryu To: Russell King , Andrew Morton , Laura Abbott Subject: [PATCHv2] arm:kexec: have own crash_smp_send_stop() for crash dump for nonpanic cores Date: Fri, 4 Aug 2017 15:34:13 +0900 Message-Id: <1501828470-17751-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-20170803_233920_196005_8C5AC42A X-CRM114-Status: GOOD ( 16.94 ) 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). ARM 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_call_function(machine_crash_nonpanic_core, NULL, false) in the function is useless because all nonpanic CPUs are already offline by smp_send_stop() in this case and smp_call_function() 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 for ARM architecture to fix this problem and the function (strong symbol version) saves crash information for nonpanic CPUs using smp_call_function() and machine_crash_shutdown() tries to save crash information for nonpanic CPUs only when crash_kexec_post_notifiers kernel option is disabled. We might be able to implement the function like arm64 or x86 using a dedicated IPI (let's say IPI_CPU_CRASH_STOP), but we cannot implement this function like that because of the lack of IPI slots. Please see the commit e7273ff4 : (ARM: 8488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI) Signed-off-by: Hoeun Ryu --- v2: - calling crash_smp_send_stop() in machine_crash_shutdown() for the case when crash_kexec_post_notifiers kernel option is disabled. - fix commit messages for it. arch/arm/kernel/machine_kexec.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index fe1419e..b58a49a 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -94,6 +94,31 @@ void machine_crash_nonpanic_core(void *unused) cpu_relax(); } +void crash_smp_send_stop(void) +{ + static int cpus_stopped; + unsigned long msecs; + + /* + * This function can be called twice in panic path, but obviously + * we execute this only once. + */ + if (cpus_stopped) + return; + + atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); + smp_call_function(machine_crash_nonpanic_core, NULL, false); + msecs = 1000; /* Wait at most a second for the other cpus to stop */ + while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { + mdelay(1); + msecs--; + } + if (atomic_read(&waiting_for_crash_ipi) > 0) + pr_warn("Non-crashing CPUs did not react to IPI\n"); + + cpus_stopped = 1; +} + static void machine_kexec_mask_interrupts(void) { unsigned int i; @@ -119,19 +144,11 @@ static void machine_kexec_mask_interrupts(void) void machine_crash_shutdown(struct pt_regs *regs) { - unsigned long msecs; + WARN_ON(num_online_cpus() > 1); local_irq_disable(); - atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); - smp_call_function(machine_crash_nonpanic_core, NULL, false); - msecs = 1000; /* Wait at most a second for the other cpus to stop */ - while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { - mdelay(1); - msecs--; - } - if (atomic_read(&waiting_for_crash_ipi) > 0) - pr_warn("Non-crashing CPUs did not react to IPI\n"); + crash_smp_send_stop(); crash_save_cpu(regs, smp_processor_id()); machine_kexec_mask_interrupts();