linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] arm64: Improve parking of stopped CPUs
@ 2019-06-17 20:35 Aaro Koskinen
  2019-06-17 20:35 ` [PATCH v2 2/2] arm64: Implement panic_smp_self_stop() Aaro Koskinen
  2019-06-25 15:43 ` [PATCH v2 1/2] arm64: Improve parking of stopped CPUs Catalin Marinas
  0 siblings, 2 replies; 4+ messages in thread
From: Aaro Koskinen @ 2019-06-17 20:35 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, James Morse,
	Jayachandran Chandrasekharan Nair
  Cc: Aaro Koskinen, linux-arm-kernel, Aaro Koskinen

From: Jayachandran C <jnair@caviumnetworks.com>

The current code puts the stopped cpus in an 'yield' instruction loop.
Using a busy loop here is unnecessary, we can use the cpu_park_loop()
function here to do a wfi/wfe.

Signed-off-by: Jayachandran C <jnair@caviumnetworks.com>
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Acked-by: Will Deacon <will.deacon@arm.com>
---

	v2: Add Acked-by

	v1: https://patchwork.kernel.org/patch/10988099/

 arch/arm64/kernel/smp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index bb4b3f07761a..1a1b96a50245 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -854,9 +854,7 @@ static void ipi_cpu_stop(unsigned int cpu)
 
 	local_daif_mask();
 	sdei_mask_local_cpu();
-
-	while (1)
-		cpu_relax();
+	cpu_park_loop();
 }
 
 #ifdef CONFIG_KEXEC_CORE
-- 
2.17.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] arm64: Implement panic_smp_self_stop()
  2019-06-17 20:35 [PATCH v2 1/2] arm64: Improve parking of stopped CPUs Aaro Koskinen
@ 2019-06-17 20:35 ` Aaro Koskinen
  2019-06-18 12:51   ` Will Deacon
  2019-06-25 15:43 ` [PATCH v2 1/2] arm64: Improve parking of stopped CPUs Catalin Marinas
  1 sibling, 1 reply; 4+ messages in thread
From: Aaro Koskinen @ 2019-06-17 20:35 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, James Morse,
	Jayachandran Chandrasekharan Nair
  Cc: Aaro Koskinen, linux-arm-kernel, Aaro Koskinen

From: Aaro Koskinen <aaro.koskinen@nokia.com>

Currently arm64 uses the default implementation of panic_smp_self_stop()
where the CPU runs in a cpu_relax() loop unable to receive IPIs anymore.
As a result, when two CPUs panic() simultaneously we get "SMP: failed to
stop secondary CPUs" warnings and extra delays before a reset, because
smp_send_stop() still tries to stop the other paniced CPU.

Provide an implementation of panic_smp_self_stop() that is identical to
the IPI CPU stop handler, so that the online status of stopped CPUs gets
properly updated.

Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
---

	v2: Update the commit log
	    Rename ipi_cpu_stop() to local_cpu_stop() and make it void func
	    Add a comment for panic_smp_self_stop()

	v1: https://patchwork.kernel.org/patch/10988103/

 arch/arm64/kernel/smp.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 1a1b96a50245..1ac4aa34ffb6 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -845,18 +845,25 @@ void arch_irq_work_raise(void)
 }
 #endif
 
-/*
- * ipi_cpu_stop - handle IPI from smp_send_stop()
- */
-static void ipi_cpu_stop(unsigned int cpu)
+static void local_cpu_stop(void)
 {
-	set_cpu_online(cpu, false);
+	set_cpu_online(smp_processor_id(), false);
 
 	local_daif_mask();
 	sdei_mask_local_cpu();
 	cpu_park_loop();
 }
 
+/*
+ * We need to implement panic_smp_self_stop() for parallel panic() calls, so
+ * that cpu_online_mask gets correctly updated and smp_send_stop() can skip
+ * CPUs that have already stopped themselves.
+ */
+void panic_smp_self_stop(void)
+{
+	local_cpu_stop();
+}
+
 #ifdef CONFIG_KEXEC_CORE
 static atomic_t waiting_for_crash_ipi = ATOMIC_INIT(0);
 #endif
@@ -907,7 +914,7 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
 
 	case IPI_CPU_STOP:
 		irq_enter();
-		ipi_cpu_stop(cpu);
+		local_cpu_stop();
 		irq_exit();
 		break;
 
-- 
2.17.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] arm64: Implement panic_smp_self_stop()
  2019-06-17 20:35 ` [PATCH v2 2/2] arm64: Implement panic_smp_self_stop() Aaro Koskinen
@ 2019-06-18 12:51   ` Will Deacon
  0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2019-06-18 12:51 UTC (permalink / raw)
  To: Aaro Koskinen
  Cc: Catalin Marinas, Jayachandran Chandrasekharan Nair, James Morse,
	linux-arm-kernel, Aaro Koskinen

On Mon, Jun 17, 2019 at 11:35:19PM +0300, Aaro Koskinen wrote:
> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> 
> Currently arm64 uses the default implementation of panic_smp_self_stop()
> where the CPU runs in a cpu_relax() loop unable to receive IPIs anymore.
> As a result, when two CPUs panic() simultaneously we get "SMP: failed to
> stop secondary CPUs" warnings and extra delays before a reset, because
> smp_send_stop() still tries to stop the other paniced CPU.
> 
> Provide an implementation of panic_smp_self_stop() that is identical to
> the IPI CPU stop handler, so that the online status of stopped CPUs gets
> properly updated.
> 
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> ---
> 
> 	v2: Update the commit log
> 	    Rename ipi_cpu_stop() to local_cpu_stop() and make it void func
> 	    Add a comment for panic_smp_self_stop()
> 
> 	v1: https://patchwork.kernel.org/patch/10988103/
> 
>  arch/arm64/kernel/smp.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)

Acked-by: Will Deacon <will.deacon@arm.com>

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] arm64: Improve parking of stopped CPUs
  2019-06-17 20:35 [PATCH v2 1/2] arm64: Improve parking of stopped CPUs Aaro Koskinen
  2019-06-17 20:35 ` [PATCH v2 2/2] arm64: Implement panic_smp_self_stop() Aaro Koskinen
@ 2019-06-25 15:43 ` Catalin Marinas
  1 sibling, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2019-06-25 15:43 UTC (permalink / raw)
  To: Aaro Koskinen
  Cc: James Morse, Jayachandran Chandrasekharan Nair, Will Deacon,
	linux-arm-kernel, Aaro Koskinen

On Mon, Jun 17, 2019 at 11:35:18PM +0300, Aaro Koskinen wrote:
> From: Jayachandran C <jnair@caviumnetworks.com>
> 
> The current code puts the stopped cpus in an 'yield' instruction loop.
> Using a busy loop here is unnecessary, we can use the cpu_park_loop()
> function here to do a wfi/wfe.
> 
> Signed-off-by: Jayachandran C <jnair@caviumnetworks.com>
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> Acked-by: Will Deacon <will.deacon@arm.com>

Both patches queued for 5.3. Thanks.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-25 15:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 20:35 [PATCH v2 1/2] arm64: Improve parking of stopped CPUs Aaro Koskinen
2019-06-17 20:35 ` [PATCH v2 2/2] arm64: Implement panic_smp_self_stop() Aaro Koskinen
2019-06-18 12:51   ` Will Deacon
2019-06-25 15:43 ` [PATCH v2 1/2] arm64: Improve parking of stopped CPUs Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).