linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Don Zickus <dzickus@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org, LKML <linux-kernel@vger.kernel.org>,
	tony.luck@intel.com, seiji.aguchi@hds.com, ak@linux.intel.com,
	mjg@redhat.com, levinsasha928@gmail.com
Subject: Re: [PATCH 2/2] x86, reschedule: check to see if system is shutting down
Date: Wed, 15 Feb 2012 22:14:41 -0500	[thread overview]
Message-ID: <20120216031441.GU9751@redhat.com> (raw)
In-Reply-To: <1329328787.2293.173.camel@twins>

On Wed, Feb 15, 2012 at 06:59:47PM +0100, Peter Zijlstra wrote:
> > > The only way is to unplug all cpus except the one. Problem with that is
> > > that we cannot (as of yet) unplug the boot cpu.
> > 
> > Yeah, well we can migrate to the boot cpu.  I think powerpc does that for
> > kdump.
> 
> Right, there's that.

Well we are in luck, migrating to cpu0 is already done in the shutdown
path.

arch/x86/kernel/reboot.c::native_machine_shutdown:662
	set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id));

Now most of the time it seems to be cpu0, but I guess corner cases can put
it elsewhere.  I replaced 'stop_other_cpus' with 'for_each_online_cpu(cpu)
{ cpu_down(cpu) }.  And things seemed to work.  Output below, patch below
that:

=====================
Please stand by while rebooting the system...
[  101.470240] md: stopping all md devices.
[  101.474346] kvm: exiting hardware virtualization
[  101.480071] sd 3:0:0:0: [sdb] Synchronizing SCSI cache
[  101.535977] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  101.643479] Restarting system.
[  101.646624] machine restart
[  101.649501] DONDON: on cpu2
[  101.652502] DONDON: on new cpu0
[  101.658397] Broke affinity for irq 42
[  101.662168] Broke affinity for irq 47
[  101.669281] bnx2fc: CPU 1 offline: Remove Rx thread
[  101.674381] CPU 1 offline: Remove Rx thread
[  101.680595] Broke affinity for irq 22
[  101.686510] bnx2fc: CPU 2 offline: Remove Rx thread
[  101.691569] CPU 2 offline: Remove Rx thread
[  101.697260] Broke affinity for irq 16
[  101.702057] lockdep: fixing up alternatives.
[  101.706476] SMP alternatives: switching to UP code
[  101.720162] bnx2fc: CPU 3 offline: Remove Rx thread
[  101.725206] CPU 3 offline: Remove Rx thread
====================

Does that work for you?

Cheers,
Don

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index d840e69..c3569ac 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -644,6 +644,7 @@ void native_machine_shutdown(void)
 
 	/* The boot cpu is always logical cpu 0 */
 	int reboot_cpu_id = 0;
+	int cpu;
 
 #ifdef CONFIG_X86_32
 	/* See if there has been given a command line override */
@@ -652,17 +653,24 @@ void native_machine_shutdown(void)
 		reboot_cpu_id = reboot_cpu;
 #endif
 
+	printk("DONDON: on cpu%d\n", smp_processor_id());
 	/* Make certain the cpu I'm about to reboot on is online */
 	if (!cpu_online(reboot_cpu_id))
 		reboot_cpu_id = smp_processor_id();
 
 	/* Make certain I only run on the appropriate processor */
 	set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id));
+	printk("DONDON: on new cpu%d\n", smp_processor_id());
 
 	/* O.K Now that I'm on the appropriate processor,
 	 * stop all of the others.
 	 */
-	stop_other_cpus();
+	//stop_other_cpus();
+	for_each_online_cpu(cpu) {
+		if (cpu == 0)
+			continue;
+		cpu_down(cpu);
+	}
 #endif
 
 	lapic_shutdown();

  reply	other threads:[~2012-02-16  3:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-13 20:27 [PATCH 0/2 v2] x86, reboot: cleanup NMI and REBOOT_IRQ Don Zickus
2012-02-13 20:27 ` [PATCH 1/2] x86, reboot: revert stop_other_cpus to using IRQ with NMI fallback Don Zickus
2012-03-02 20:41   ` Seiji Aguchi
2012-03-02 21:11     ` Don Zickus
2012-03-02 21:55       ` Seiji Aguchi
2012-02-13 20:27 ` [PATCH 2/2] x86, reschedule: check to see if system is shutting down Don Zickus
2012-02-13 21:22   ` Seiji Aguchi
2012-02-13 22:43     ` Don Zickus
2012-02-15 11:26   ` Peter Zijlstra
2012-02-15 14:54     ` Don Zickus
2012-02-15 14:57       ` Peter Zijlstra
2012-02-15 15:57         ` Don Zickus
2012-02-15 17:59           ` Peter Zijlstra
2012-02-16  3:14             ` Don Zickus [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-10 21:02 [PATCH 0/2] x86, reboot: cleanup NMI and REBOOT_IRQ Don Zickus
2012-02-10 21:02 ` [PATCH 2/2] x86, reschedule: check to see if system is shutting down Don Zickus
2012-02-10 22:42   ` Luck, Tony
2012-02-10 22:53     ` Don Zickus

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=20120216031441.GU9751@redhat.com \
    --to=dzickus@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=levinsasha928@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=seiji.aguchi@hds.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.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).