From patchwork Fri Aug 4 06:04:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9880615 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 102866031B for ; Fri, 4 Aug 2017 06:10:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0060828760 for ; Fri, 4 Aug 2017 06:10:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E96D1289AD; Fri, 4 Aug 2017 06:10:26 +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=ham 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 D658F28760 for ; Fri, 4 Aug 2017 06:10:25 +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=5JL8Up369z4m+UzKoLSBgqmthq8Oqj4AuYu+tBmRqTk=; b=GjJ 5zMd8iyxff54rMQl1drHKQNOscm7H7ANdLd6zBqFeJmO+DuLb2uP7IqEvZaPgQJ1J5hXuUsD/uu3R pQn83DdugkSpb7gffxqStddHRlb7KfWSJP8vw7eK35F55wRhIjNzev00TS4tpIDJtKMJXUZF+izsm tn5U6f1V/WJ/EQAZCDrp6XLc0UfTAcHwpDGgipuCnnjIN5nfeAzkrkjclI9/CllLOukgjLj6DqDQ3 Zqi3fENf5pqrw2V55VzgPnQXl+ai4X0KuexWhxLwn3+1Y0iOVAp7H3mOFnHQiugHzojzLyNkYatzQ 2l6MhPL4g+/JaGSJXdDmNCI3Dpzjf6w==; 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 1ddVnp-0002sh-BB; Fri, 04 Aug 2017 06:09:41 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddVnl-0002rP-Vt for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2017 06:09:39 +0000 Received: by mail-pf0-x243.google.com with SMTP id h75so914515pfh.5 for ; Thu, 03 Aug 2017 23:09:15 -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=SMm29yx2Xrov5fesQjz/zwpCGBSV2f4YuUl01yZRfgc=; b=YSPL2jQlEzRWBXPWqrifM+wsiVL6ita5BZCJs+aRAVFFBt1e4lWFcmyunZvdzWJXDZ LyXz/OyrsFdxEryeb/GZzchyVA5ZHp2YEGfzuat/uzEJ5PXBX0jukDtd8+sznrlMPTQn R2fyYwZOFvryNBz3dg8RfsnA4B+qhUjlRUAcSgkGqDY9AVocDPZf5C+q19zumRdT1mRu oP36duklYIjaXsGlYayyDPuYxVUUqK8UO3D0X48R7O5yxNqC/Sar57/zAuxSR2osTthv dp9plJ2qbqdpj5JDHPmUgrk/ovoYS/M/Xhk5lc0wm+XhejiJIYepct78VrHhRVs3bwxL dk5w== 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=SMm29yx2Xrov5fesQjz/zwpCGBSV2f4YuUl01yZRfgc=; b=syKTrwIWh9JhWAHohN/Iy9MyCvhL3U5fK4NaT9vybL6SNl4rEPYMfmxsHU/cm1P8vY c8xZPXQ2rS+HByhhDRmBQB1+xLGyju6bru7v6/nTUIn8tUF+8skhHOsy+ILcg7Pukt4z P8YRcBE7ckF5iOjS/i5bMEEBZ8akH1M7xxxmWyB57ZmaxFN1tC+rAE2/wOKebEArajoQ u3X2p3llnYlC0GxNDez1bbMdLXrlViM0SML7ledUtu0KvkN9XQlgLWwJQufTzB6SYCpF UTwbz3Ts17MvSUHjnxwobGF0f8x4+FXAEiklXE6oBCAwTexZc9f74LYpx59m5lSDsnDT anRg== X-Gm-Message-State: AIVw110CGH5C4zguTaXPDJPKUO9pFrIsJ//kachvL/NaCT5zR5Cte4pn sudnRATSBYCrbw== X-Received: by 10.98.113.71 with SMTP id m68mr1293007pfc.220.1501826955196; Thu, 03 Aug 2017 23:09:15 -0700 (PDT) Received: from hryu-OptiPlex-9020.corp.ad.wrs.com ([61.107.31.52]) by smtp.gmail.com with ESMTPSA id g5sm837395pgc.92.2017.08.03.23.09.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Aug 2017 23:09:14 -0700 (PDT) From: Hoeun Ryu To: Russell King , Andrew Morton , Laura Abbott Subject: [PATCH] arm:kexec: have own crash_smp_send_stop() for crash dump for nonpanic cores Date: Fri, 4 Aug 2017 15:04:23 +0900 Message-Id: <1501826682-14148-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_230938_116366_E27339D7 X-CRM114-Status: GOOD ( 16.45 ) 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() saves crash information only for the panic CPU. 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 slot. Please see the commit e7273ff4 : (ARM: 8488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI) Signed-off-by: Hoeun Ryu --- arch/arm/kernel/machine_kexec.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index fe1419e..18d084a 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,20 +144,10 @@ 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_save_cpu(regs, smp_processor_id()); machine_kexec_mask_interrupts();