Thread (1 message) 1 message, 1 author, 2019-06-18

Re: [PATCH] arm64: smp: fix smp_send_stop() behaviour

From: Cristian Marussi <cristian.marussi@arm.com>
Date: 2019-06-18 09:56:50

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 [off-list ref]
wrote:
quoted
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 <Dave.Martin@arm.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---

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/ (local)
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help