mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suresh Siddha <suresh.b.siddha@intel.com>
To: "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Arjan van de Ven <arjan@linux.intel.com>
Subject: [patch] x86: avoid unnecessary smp alternatives switch during suspend/resume
Date: Fri, 19 Nov 2010 16:09:24 -0800	[thread overview]
Message-ID: <1290211764.2637.8.camel@sbsiddha-MOBL3.sc.intel.com> (raw)

During suspend, we disable all the non boot cpus. And during resume we bring
them all back again. So no need to do alternatives_smp_switch() in between.

This speeds up both suspend and resume paths.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---

 arch/x86/kernel/smpboot.c |    7 ++++++-
 include/linux/cpu.h       |    2 ++
 kernel/cpu.c              |    3 +++
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index f0a0624..0b04ca3 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1349,7 +1349,12 @@ void native_cpu_die(unsigned int cpu)
 			if (system_state == SYSTEM_RUNNING)
 				pr_info("CPU %u is now offline\n", cpu);
 
-			if (1 == num_online_cpus())
+			/*
+			 * Don't do the smp alternatives switch during
+			 * suspend. We will be back in the SMP mode after
+			 * resume.
+			 */
+			if (1 == num_online_cpus() && !pm_sleep_smp)
 				alternatives_smp_switch(0);
 			return;
 		}
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 4823af6..8cab04c 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -169,11 +169,13 @@ static inline void cpu_hotplug_driver_unlock(void)
 
 #ifdef CONFIG_PM_SLEEP_SMP
 extern int suspend_cpu_hotplug;
+extern int pm_sleep_smp;
 
 extern int disable_nonboot_cpus(void);
 extern void enable_nonboot_cpus(void);
 #else /* !CONFIG_PM_SLEEP_SMP */
 #define suspend_cpu_hotplug	0
+#define pm_sleep_smp		0
 
 static inline int disable_nonboot_cpus(void) { return 0; }
 static inline void enable_nonboot_cpus(void) {}
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 8615aa6..2eed810 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -381,6 +381,7 @@ out:
 
 #ifdef CONFIG_PM_SLEEP_SMP
 static cpumask_var_t frozen_cpus;
+int pm_sleep_smp;
 
 int disable_nonboot_cpus(void)
 {
@@ -393,6 +394,7 @@ int disable_nonboot_cpus(void)
 	 * with the userspace trying to use the CPU hotplug at the same time
 	 */
 	cpumask_clear(frozen_cpus);
+	pm_sleep_smp = 1;
 
 	printk("Disabling non-boot CPUs ...\n");
 	for_each_online_cpu(cpu) {
@@ -454,6 +456,7 @@ void __ref enable_nonboot_cpus(void)
 
 	cpumask_clear(frozen_cpus);
 out:
+	pm_sleep_smp = 0;
 	cpu_maps_update_done();
 }
 



             reply	other threads:[~2010-11-20  0:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-20  0:09 Suresh Siddha [this message]
2010-11-20 16:31 ` Ben Gamari
2010-11-21  6:02 ` Américo Wang
2010-11-21  9:27 ` Nigel Cunningham
2010-11-21 10:03   ` Borislav Petkov
2011-01-02  9:11     ` Pavel Machek
2011-01-03 23:44       ` Suresh Siddha
2010-11-22  2:30   ` H. Peter Anvin
2010-11-24  0:11   ` Suresh Siddha
2010-12-14 21:21     ` [tip:x86/alternatives] x86, suspend: Avoid " tip-bot for Suresh Siddha
2010-12-14 22:31       ` Rafael J. Wysocki

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=1290211764.2637.8.camel@sbsiddha-MOBL3.sc.intel.com \
    --to=suresh.b.siddha@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®