From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DB7CC2D0A3 for ; Fri, 6 Nov 2020 23:28:13 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B97A206CB for ; Fri, 6 Nov 2020 23:28:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OgboDaKN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="t4xJ7y8D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B97A206CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=u848zvDvnFaiVD/37uxiXsceSy2g8Gu/yLAnu4gKRsY=; b=OgboDaKN8sw8V04dRgBMzXPajD ycORW/dDddHEGd7VfXxCjIILguhxz8jxjh7/6Harsj94iQRo/DXm/ftdFXqJSWfXLgRbUeNwm+Pgf KZC5smTf1Gf5QvKQ3xIJqYTK43mIrXg1mTB6H+s0BopuM9h6TUCusCSw//8tkDrTDxjzbYW/IKWtl ggjxttb8j8V7SAu03cXlY1z6FzlwiI72kNSQ2JcgJ3vrWHy3V7NWIMVLFpeh4Us3wovUVVJXWj88Y +avccI87oNCMlWKpXjGnxOPQnNrwjIxX/ZKke67Q6RZ0kWpQNASxui558dAcjDNzWhazEe8yuvdNo zq0B5dwA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kbB7V-0005TD-Qg; Fri, 06 Nov 2020 23:26:13 +0000 Received: from userp2120.oracle.com ([156.151.31.85]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kbB7R-0005Su-QK for linux-arm-kernel@lists.infradead.org; Fri, 06 Nov 2020 23:26:12 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0A6NJ4wP066494; Fri, 6 Nov 2020 23:25:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2020-01-29; bh=2tRXw/dchPQ13IhlNROOnimve1oFHuJwjVjFCIkQL9s=; b=t4xJ7y8D5a6j2f17ZwmtzWXhWCibYCpYKHz5hM4k35Ijao8Zd7CSE5HcNASyWw+7u6kn CRWidzhqXwCQE3Qnpzh7DDoysDdeSw2Zt5u67slbp662TgMnTljTU3fy/8P3TEvsibol cXtMU6V6lCg0aEu8720TIiAYOy3+TtP8YwLRmeltCdByw0WkIoXHq/pjiksub6RM0OhW cTCh6J55RfhxZQUZhh+iuJhg5wp+CyyUpeOq9UlynqwFDxUiy4iyA+k6oYjtaee5JZmS 3tpTJc85Q3m5BDiWj6iyXJoZi6tCMr+WPN0a1oP4pJPDc11sV3GsaK6oITu2eal3+RRU lw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 34hhw33g8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 06 Nov 2020 23:25:58 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0A6NJtOf098828; Fri, 6 Nov 2020 23:25:57 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 34hvs3bg1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Nov 2020 23:25:57 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0A6NPtas032501; Fri, 6 Nov 2020 23:25:56 GMT Received: from ca-dev-arm29.us.oracle.com (/10.129.136.23) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 06 Nov 2020 15:25:55 -0800 From: Henry Willard To: , , , , Subject: [PATCH] arm64: kexec: Use smp_send_stop in machine_shutdown Date: Fri, 6 Nov 2020 15:25:48 -0800 Message-Id: <1604705148-1831-1-git-send-email-henry.willard@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9797 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011060156 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9797 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 clxscore=1011 priorityscore=1501 impostorscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011060156 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201106_182610_011549_E9F0D2E2 X-CRM114-Status: GOOD ( 33.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org machine_shutdown() is called by kernel_kexec() to shutdown the non-boot CPUs prior to starting the new kernel. The implementation of machine_shutdown() varies by architecture. Many make an interprocessor call, such as smp_send_stop(), to stop the non-boot CPUs. On some architectures the CPUs make some sort of firmware call to stop the CPU. On some architectures without the necessary firmware support to stop the CPU, the CPUs go into a disabled loop, which is not suitable for supporting kexec. On Arm64 systems that support PSCI, CPUs can be stopped with a PSCI CPU_OFF call. Arm64 machine_shutdown() uses the CPU hotplug infrastructure via smp_shutdown_nonboot_cpus() to stop each CPU. This is relatively slow and takes a best case of .02 to .03 seconds per CPU which are stopped sequentially. This can take the better part of a second for all the CPUs to be stopped depending on how many CPUs are present. If for some reason the CPUs are busy at the time of the kexec reboot, it can take several seconds to shut them all down. Each CPU shuts itself down by calling PSCI CPU_OFF. In some applications such as embedded systems, which need a very fast reboot (less than a second), this may be too slow. This patch reverts to using smp_send_stop() to signal all CPUs to stop immediately. Currently smp_send_stop() causes each cpu to call local_cpu_stop(), which goes into a disabled loop. This patch modifies local_cpu_stop() to call cpu_die() when kexec_in_progress is true, so that the CPU calls PSCI CPU_OFF just as in the case of smp_shutdown_nonboot_cpus(). Using smp_send_stop() instead of smp_shutdown_nonboot_cpus() reduces the shutdown time for 23 CPUs from about .65 seconds on an idle system to less than 5 msecs. On a busy system smp_shutdown_nonboot_cpus() may take several seconds, while smp_send_stop() needs only the 5 msecs. Signed-off-by: Henry Willard --- arch/arm64/kernel/process.c | 17 ++++++++++++++--- arch/arm64/kernel/smp.c | 8 +++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 4784011cecac..2568452a2417 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -142,12 +143,22 @@ void arch_cpu_idle_dead(void) * This must completely disable all secondary CPUs; simply causing those CPUs * to execute e.g. a RAM-based pin loop is not sufficient. This allows the * kexec'd kernel to use any and all RAM as it sees fit, without having to - * avoid any code or data used by any SW CPU pin loop. The CPU hotplug - * functionality embodied in smpt_shutdown_nonboot_cpus() to achieve this. + * avoid any code or data used by any SW CPU pin loop. The target stop function + * will call cpu_die() if kexec_in_progress is set. */ void machine_shutdown(void) { - smp_shutdown_nonboot_cpus(reboot_cpu); + unsigned long timeout; + + /* + * Don't wait forever, but no longer than a second + */ + timeout = USEC_PER_SEC; + + smp_send_stop(); + while (num_online_cpus() > 1 && timeout--) + udelay(1); + return; } /* diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 09c96f57818c..310cdf327d91 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -373,7 +373,9 @@ void cpu_die(void) unsigned int cpu = smp_processor_id(); const struct cpu_operations *ops = get_cpu_ops(cpu); - idle_task_exit(); + /* Skip this if we are about to exit the machine */ + if (!kexec_in_progress) + idle_task_exit(); local_daif_mask(); @@ -847,6 +849,10 @@ static void local_cpu_stop(void) local_daif_mask(); sdei_mask_local_cpu(); + + if (kexec_in_progress) + cpu_die(); + cpu_park_loop(); } -- 1.8.3.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel