From patchwork Tue Aug 8 01:22:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9886399 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 D04B1603B4 for ; Tue, 8 Aug 2017 01:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF4AD28746 for ; Tue, 8 Aug 2017 01:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2EB12874A; Tue, 8 Aug 2017 01:29:54 +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 2F3282874C for ; Tue, 8 Aug 2017 01:29:53 +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=KAsxWje3GrFj4h0Jud+gvRXh2KdM/+63OUbVs/ZHqb0=; b=YrY bQ9vAdvBmvAX80YjxKWY0yrQRsQqHKvf7jxrBpmwH8oMShtP7qcrA9DeuAv5m5nrQWgB2OJbeCD/8 F7FQXkLETOEWYw2CLiuOJb/U+9Oq0LFGgPcxHmhoO+cSPGWLwnJh2WEbYG0Mg3U29D6UBM/ZVLbuv PxiGmnnvI0gnYzAeOMNefYiN11LkaDUknG2KdPX+cODMfpIvgDVkAhkCTFe964xHSw1EJ0dfALuGT TXqMeQfp13RMm2FdxXKdR8T9yBxdQwsCqIsdzTRGJH2JLCDmYi28e6A18RqJAKqg2Z3PIJjxHQmA0 SMx/1vGfZ/VfkagmpdVT/Q9DTyXZGFw==; 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 1detKK-0006mv-FM; Tue, 08 Aug 2017 01:28:56 +0000 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1detK0-0006TI-F6 for linux-arm-kernel@lists.infradead.org; Tue, 08 Aug 2017 01:28:38 +0000 Received: by mail-it0-x244.google.com with SMTP id 77so1533195itj.4 for ; Mon, 07 Aug 2017 18:28:16 -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=vm9eRse960uNjz/uV9T0u92ot0dtUg6l2qU47tPJLio=; b=uQin/jtwUu9qX3m19f5d0W5zn4HkS029h5moDmag0DSvZ27HvXObOcbZontyFapeDN wxbCo6kvTf/D3ZiWwlqwFGq9Aj7d1D2v5Ebj2r7Y2uLYVAaBLTQWq0J02V7UUFV286iD cHHNsXWHUXKHvcL0Tzlpr7/6SqBpmYjYLj5iUDT+2xtMT8xGGr7sbJPndq4I8cRz6tnA yMwvluuMlIao448TMPGxy1BUzkB/EGpOTfMkMghtwKZ2fMTrVZUpz5zfuS03Rwa7sepM r6NUaU91PruOV6LKpAATD5CuElf8dnwQCl7YQyJ8oTsme92oF1AQ7fU7bOSSjYAdRZbi WtLg== 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=vm9eRse960uNjz/uV9T0u92ot0dtUg6l2qU47tPJLio=; b=o1yjefDO7gq81tWbMTafN75XgbH2O75uAXDICELZwM8Cp3uDXgVqq6SBkpwrv5hvp1 evhnJqAxBwvmtRAZ+pusZVLqsfBk2NL05uoNtabwSBEyCTwuRsC6nt7DfTfFKhrzY3LW l4VUSZwTGxBmgtBuqjBV3HjRbchK56MRZD7BpV2n9KL723tT+EfvHdoxOrkr6jpnmr0q gNVCVCmWMdn+KnsY1REvWJUqrIGiOTOj4ldhK2AUg5fpO7f6TSReE6bgWM8FHeYz2nk5 vCEUwSwqpBehRgNn5gjnwEX3BnzgQpsvMjrp1/EaA/SNO5VyEbckVBYCBTFE+S/lPGeI IcVA== X-Gm-Message-State: AHYfb5jYdwoZqJlPSoKcWdQnrYU8b1CIxrgoArrUzopKO2YIpzh1/0uS ybGfNR2LxMhKHiNvSbMLxw== X-Received: by 10.84.236.6 with SMTP id q6mr2651943plk.341.1502155695497; Mon, 07 Aug 2017 18:28:15 -0700 (PDT) Received: from hryu-OptiPlex-9020.corp.ad.wrs.com ([61.107.31.52]) by smtp.gmail.com with ESMTPSA id k85sm162905pfj.5.2017.08.07.18.28.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 18:28:14 -0700 (PDT) From: Hoeun Ryu To: Russell King , Andrew Morton , Laura Abbott Subject: [PATCHv3] arm:kexec: have own crash_smp_send_stop() for crash dump for nonpanic cores Date: Tue, 8 Aug 2017 10:22:54 +0900 Message-Id: <1502155416-5735-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-20170807_182836_551476_7FD1707D X-CRM114-Status: GOOD ( 18.25 ) 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 --- v3: - remove 'WARN_ON(num_online_cpus() > 1)' in machine_crash_shutdown(). it's a false check for the case when crash_kexec_post_notifiers kernel option is disabled. 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 | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index fe1419e..82ef7c7 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -94,6 +94,34 @@ 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; + + cpus_stopped = 1; + + if (num_online_cpus() == 1) + 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"); +} + static void machine_kexec_mask_interrupts(void) { unsigned int i; @@ -119,19 +147,9 @@ static void machine_kexec_mask_interrupts(void) void machine_crash_shutdown(struct pt_regs *regs) { - unsigned long msecs; - 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();