[PATCH] Add call to non-crashing cores through IPI

Russell King - ARM Linux linux at arm.linux.org.uk
Mon Nov 22 06:27:59 EST 2010


On Mon, Nov 22, 2010 at 10:47:40AM +0000, Russell King - ARM Linux wrote:
> However, we do need smp_send_stop() to wait for a limited time for the
> other CPUs to respond to the request.

ARM: smp: make smp_send_stop() wait for secondary CPUs to stop

Wait up to one second for secondary CPUs to respond to a request to
stop.  This avoids the sender CPU continuing and possibly destroying
state before the recipients have had a chance to respond to the stop.
However, if the recipients have crashed, we won't hang the sender
CPU indefinitely.

Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
 arch/arm/kernel/smp.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 5d0dc16..32a2158 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -589,10 +589,16 @@ void smp_send_reschedule(int cpu)
 
 void smp_send_stop(void)
 {
+	unsigned long timeout;
 	cpumask_t mask = cpu_online_map;
 	cpu_clear(smp_processor_id(), mask);
 	if (!cpus_empty(mask))
 		send_ipi_message(&mask, IPI_CPU_STOP);
+
+	/* Wait up to one second for other CPUs to stop */
+	timeout = USEC_PER_SEC;
+	while (num_online_cpus() > 1 && timeout--)
+		udelay(1);
 }
 
 /*




More information about the kexec mailing list