linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zwane Mwaikambo <zwane@arm.linux.org.uk>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>, Andi Kleen <ak@suse.de>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	Stephen Hemminger <shemminger@osdl.org>
Subject: [PATCH] i386/x86_64: Don't IPI to offline cpus on shutdown
Date: Sun, 27 Nov 2005 02:05:45 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.61.0511270115020.20046@montezuma.fsmlabs.com> (raw)

http://bugzilla.kernel.org/show_bug.cgi?id=5203

There is a small race during SMP shutdown between the processor issuing 
the shutdown and the other processors clearing themselves off the 
cpu_online_map as they do this without using the normal cpu offline 
synchronisation. To avoid this we should wait for all the other processors 
to clear their corresponding bits and then proceed. This way we can safely 
make the cpu_online test in smp_send_reschedule, it's safe during normal 
runtime as smp_send_reschedule is called with a lock held / preemption 
disabled.

Signed-off-by: Zwane Mwaikambo <zwane@arm.linux.org.uk>

 arch/i386/kernel/smp.c   |   12 +++++++++---
 arch/x86_64/kernel/smp.c |   12 +++++++++++-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff -r 2c0d5afbfb94 arch/i386/kernel/smp.c
--- a/arch/i386/kernel/smp.c	Fri Nov 25 17:42:19 2005
+++ b/arch/i386/kernel/smp.c	Sun Nov 27 02:00:59 2005
@@ -164,7 +164,6 @@
 	unsigned long flags;
 
 	local_irq_save(flags);
-	WARN_ON(mask & ~cpus_addr(cpu_online_map)[0]);
 	/*
 	 * Wait for idle.
 	 */
@@ -476,8 +475,8 @@
  */
 void smp_send_reschedule(int cpu)
 {
-	WARN_ON(cpu_is_offline(cpu));
-	send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
+	if (likely(cpu_online(cpu)))
+		send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
 }
 
 /*
@@ -585,7 +584,14 @@
 
 void smp_send_stop(void)
 {
+	cpumask_t mask;
+
+	mask = cpumask_of_cpu(smp_processor_id());
 	smp_call_function(stop_this_cpu, NULL, 1, 0);
+
+	/* Wait for other cpus to halt */
+	while (!cpus_equal(mask, cpu_online_map))
+		cpu_relax();
 
 	local_irq_disable();
 	disable_local_APIC();
diff -r 2c0d5afbfb94 arch/x86_64/kernel/smp.c
--- a/arch/x86_64/kernel/smp.c	Fri Nov 25 17:42:19 2005
+++ b/arch/x86_64/kernel/smp.c	Sun Nov 27 02:00:59 2005
@@ -293,7 +293,8 @@
 
 void smp_send_reschedule(int cpu)
 {
-	send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
+	if (likely(cpu_online(cpu)))
+		send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
 }
 
 /*
@@ -470,6 +471,8 @@
 void smp_send_stop(void)
 {
 	int nolock = 0;
+	cpumask_t mask;
+
 	if (reboot_force)
 		return;
 	/* Don't deadlock on the call lock in panic */
@@ -477,7 +480,14 @@
 		/* ignore locking because we have paniced anyways */
 		nolock = 1;
 	}
+
+	mask = cpumask_of_cpu(smp_processor_id());
 	__smp_call_function(smp_really_stop_cpu, NULL, 0, 0);
+
+	/* wait for the other cpus to halt */
+	while (!cpus_equal(mask, cpu_online_map))
+		cpu_relax();
+
 	if (!nolock)
 		spin_unlock(&call_lock);
 

             reply	other threads:[~2005-11-27 10:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-27 10:05 Zwane Mwaikambo [this message]
2005-11-27 13:58 ` [PATCH] i386/x86_64: Don't IPI to offline cpus on shutdown Andi Kleen
2005-11-27 14:14   ` Eric W. Biederman
2005-11-27 16:45     ` Zwane Mwaikambo
2005-11-28  2:27       ` Eric W. Biederman
2005-11-28  5:33         ` Andi Kleen
2005-11-28 17:29         ` Zwane Mwaikambo
     [not found]         ` <Pine.LNX.4.64.0512021221210.13220@montezuma.fsmlabs.com>
     [not found]           ` <m1iru7dlww.fsf@ebiederm.dsl.xmission.com>
     [not found]             ` <Pine.LNX.4.64.0512050014000.6637@montezuma.fsmlabs.com>
     [not found]               ` <m1zmncb0n5.fsf@ebiederm.dsl.xmission.com>
     [not found]                 ` <Pine.LNX.4.64.0512072158500.2557@montezuma.fsmlabs.com>
     [not found]                   ` <m1vey0azeu.fsf@ebiederm.dsl.xmission.com>
     [not found]                     ` <Pine.LNX.4.64.0512072249000.2557@montezuma.fsmlabs.com>
2005-12-08  7:39                       ` [PATCH] Don't attempt to power off if power off is not implemented Eric W. Biederman
1970-01-02  3:13                         ` Pavel Machek
2005-12-14 17:12                           ` Eric W. Biederman
2005-12-11 22:57                         ` Paul Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0511270115020.20046@montezuma.fsmlabs.com \
    --to=zwane@arm.linux.org.uk \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=ashok.raj@intel.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shemminger@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).