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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 60C66C31E51 for ; Tue, 18 Jun 2019 09:56:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 07514206BA for ; Tue, 18 Jun 2019 09:56:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="A2nrIDE9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07514206BA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=drjhf+z29+c77VhoT8l0AgqY6lKRmP6AeyIeeJc9kKE=; b=A2nrIDE9BEOavy FFH/tKxYzTO+pyDmPOZPaXfM6xdngcOsgI5xJ+QCoA6rdXfK8w+LtDmaV/qn8L/72gu0vwvU1ke7r Z/lRBTvCwboCsiZPiISwuSF1DwGS62aPP7rpM7QqUZe01HFGPyiGhsPGAa3SB9FAJ8ZPVurbhNx1b l5tOJhb+KLnZiCOUwIm1GRVwFvfshEMtVHfWRo1M0D2IaEmOH81dbzPKDPR+viFvV3uqa9CZYZxCN a05HqBggAbvHhLMtUb8jxOK3EdPnv9OnnPJ/zzEaJA21xylIw5C9yBfjuY+GhWKYBWxFLJYslNe24 eNt/mEj1slOWKy/A8hdg==; 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 1hdAr7-0001Ze-Ft; Tue, 18 Jun 2019 09:56:45 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hdAr3-0001YR-54 for linux-arm-kernel@lists.infradead.org; Tue, 18 Jun 2019 09:56:42 +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 BA5B0344; Tue, 18 Jun 2019 02:56:40 -0700 (PDT) Received: from [10.1.197.50] (e120937-lin.cambridge.arm.com [10.1.197.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BC9FE3F246; Tue, 18 Jun 2019 02:58:25 -0700 (PDT) Subject: Re: [PATCH] arm64: smp: fix smp_send_stop() behaviour To: Itaru Kitayama References: <20190613122146.45459-1-cristian.marussi@arm.com> From: Cristian Marussi Message-ID: <639232f2-61f7-1b9c-2db7-4901dec7ca05@arm.com> Date: Tue, 18 Jun 2019 10:56:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190618_025641_495167_0D1E8641 X-CRM114-Status: GOOD ( 20.03 ) 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, catalin.marinas@arm.com, will.deacon@arm.com, dave.martin@arm.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Itaru thanks for the review. On 17/06/2019 20:58, Itaru Kitayama wrote: > Could you avoid using the magic number like in udelay()? > If you mean udelay(1) it is just that I avoided modifying anything which was not strictly related to the fix addressed by this patch. Thanks Cristian > On Thu, Jun 13, 2019 at 21:22 Cristian Marussi > wrote: > >> 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)); >> >> -- >> 2.17.1 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >> > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel