From patchwork Thu Jun 13 12:21:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 10991647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 169D915E6 for ; Thu, 13 Jun 2019 12:22:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFBFD288D9 for ; Thu, 13 Jun 2019 12:22:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDDB328BB6; Thu, 13 Jun 2019 12:22:18 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 8B6D8288D9 for ; Thu, 13 Jun 2019 12:22:18 +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=7EVn3PyFJqVyiOFjCIpBNI6FfSa2sVh5v17yHDJX41Q=; b=GmZ px5dIPqaR1yCktBgKdVwCr3WF9skt0N44wNZWyhrnA7p9oJ9fnC1R47DgbgrKB9qypsGqrxHPokZE dOY+aVitZ1QN6TVky9hipnhe7A/L6xubu1yvCb8cORL14r/N8y0Er1n1wi/jNmugfI+3H6U8nLXeG 0wFIo3LXRZTXH2lqexp6dTkDXEs1H3bfXKP/YZivgC25ANyHkrN28WMjn5M0YZZZlXZ5O8UJox9t2 jIZ8Y6XhgfAwqKedKv00kQZBXDZ0IELioke7aNshxFVakDSjNCmjA76H+pvPBCLdBFOItniEzpTnE Ic3DGoyy5rc3QAySq9QVZB/AlDPg+ZA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbOkA-0007ej-L3; Thu, 13 Jun 2019 12:22:14 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hbOk6-0007eK-Rr for linux-arm-kernel@lists.infradead.org; Thu, 13 Jun 2019 12:22:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F2282B; Thu, 13 Jun 2019 05:22:06 -0700 (PDT) Received: from e120937-lin.cambridge.arm.com (e120937-lin.cambridge.arm.com [10.1.197.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AE6433F694; Thu, 13 Jun 2019 05:22:05 -0700 (PDT) From: Cristian Marussi To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH] arm64: smp: fix smp_send_stop() behaviour Date: Thu, 13 Jun 2019 13:21:46 +0100 Message-Id: <20190613122146.45459-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190613_052210_949954_0766F095 X-CRM114-Status: GOOD ( 12.16 ) 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: , Cc: mark.rutland@arm.com, dave.martin@arm.com 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 On a 2-CPUs system, when one CPU is already online if the other panics while starting-up, smp_send_stop() will fail to send any STOP message to the other already online core, resulting in a system still responsive and alive at the end of the panic procedure. This patch makes smp_send_stop() account also for the online status of the calling CPU while evaluating how many CPUs are effectively online: this way, an adequate number of STOPs is sent, so enforcing a proper freeze of the system at the end of panic even under the above conditions. Reported-by: Dave Martin Signed-off-by: Cristian Marussi --- This peculiar panic-procedure behaviour was exposed hitting a BUG() while running a KSFT cpu-hotplug test on a 2-core ARMv8 model. Such trigger-BUG() was fixed by a distinct commit already included in Linux 5.2-rc4 [0] [0] https://lore.kernel.org/linux-arm-kernel/1559576102-12156-1-git-send-email-Dave.Martin@arm.com/ --- arch/arm64/kernel/smp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index bb4b3f07761a..c7d604427883 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -971,8 +971,14 @@ void tick_broadcast(const struct cpumask *mask) void smp_send_stop(void) { unsigned long timeout; + unsigned int this_cpu_online = cpu_online(smp_processor_id()); - if (num_online_cpus() > 1) { + /* + * If this CPU isn't fully online, it will not be counted in + * num_online_cpus(): on a 2-CPU system this situation will + * result in no message being sent to the other already online CPU. + */ + if (num_online_cpus() > this_cpu_online) { cpumask_t mask; cpumask_copy(&mask, cpu_online_mask); @@ -985,10 +991,10 @@ void smp_send_stop(void) /* Wait up to one second for other CPUs to stop */ timeout = USEC_PER_SEC; - while (num_online_cpus() > 1 && timeout--) + while (num_online_cpus() > this_cpu_online && timeout--) udelay(1); - if (num_online_cpus() > 1) + if (num_online_cpus() > this_cpu_online) pr_warning("SMP: failed to stop secondary CPUs %*pbl\n", cpumask_pr_args(cpu_online_mask));