aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/alternative.h1
-rw-r--r--arch/x86/kernel/alternative.c3
-rw-r--r--arch/x86/kernel/smpboot.c14
-rw-r--r--kernel/cpu.c11
4 files changed, 28 insertions, 1 deletions
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 76561d20ea2f..01171f6c2c37 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -66,6 +66,7 @@ extern void alternatives_smp_module_add(struct module *mod, char *name,
66extern void alternatives_smp_module_del(struct module *mod); 66extern void alternatives_smp_module_del(struct module *mod);
67extern void alternatives_smp_switch(int smp); 67extern void alternatives_smp_switch(int smp);
68extern int alternatives_text_reserved(void *start, void *end); 68extern int alternatives_text_reserved(void *start, void *end);
69extern bool skip_smp_alternatives;
69#else 70#else
70static inline void alternatives_smp_module_add(struct module *mod, char *name, 71static inline void alternatives_smp_module_add(struct module *mod, char *name,
71 void *locks, void *locks_end, 72 void *locks, void *locks_end,
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 5079f24c955a..9f98eb400fef 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -353,6 +353,7 @@ void __init_or_module alternatives_smp_module_del(struct module *mod)
353 mutex_unlock(&smp_alt); 353 mutex_unlock(&smp_alt);
354} 354}
355 355
356bool skip_smp_alternatives;
356void alternatives_smp_switch(int smp) 357void alternatives_smp_switch(int smp)
357{ 358{
358 struct smp_alt_module *mod; 359 struct smp_alt_module *mod;
@@ -368,7 +369,7 @@ void alternatives_smp_switch(int smp)
368 printk("lockdep: fixing up alternatives.\n"); 369 printk("lockdep: fixing up alternatives.\n");
369#endif 370#endif
370 371
371 if (noreplace_smp || smp_alt_once) 372 if (noreplace_smp || smp_alt_once || skip_smp_alternatives)
372 return; 373 return;
373 BUG_ON(!smp && (num_online_cpus() > 1)); 374 BUG_ON(!smp && (num_online_cpus() > 1));
374 375
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 083e99d1b7df..837c81e99edf 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1166,6 +1166,20 @@ out:
1166 preempt_enable(); 1166 preempt_enable();
1167} 1167}
1168 1168
1169void arch_disable_nonboot_cpus_begin(void)
1170{
1171 /*
1172 * Avoid the smp alternatives switch during the disable_nonboot_cpus().
1173 * In the suspend path, we will be back in the SMP mode shortly anyways.
1174 */
1175 skip_smp_alternatives = true;
1176}
1177
1178void arch_disable_nonboot_cpus_end(void)
1179{
1180 skip_smp_alternatives = false;
1181}
1182
1169void arch_enable_nonboot_cpus_begin(void) 1183void arch_enable_nonboot_cpus_begin(void)
1170{ 1184{
1171 set_mtrr_aps_delayed_init(); 1185 set_mtrr_aps_delayed_init();
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f6e726f18491..8ccc182069ec 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -386,6 +386,14 @@ out:
386#ifdef CONFIG_PM_SLEEP_SMP 386#ifdef CONFIG_PM_SLEEP_SMP
387static cpumask_var_t frozen_cpus; 387static cpumask_var_t frozen_cpus;
388 388
389void __weak arch_disable_nonboot_cpus_begin(void)
390{
391}
392
393void __weak arch_disable_nonboot_cpus_end(void)
394{
395}
396
389int disable_nonboot_cpus(void) 397int disable_nonboot_cpus(void)
390{ 398{
391 int cpu, first_cpu, error = 0; 399 int cpu, first_cpu, error = 0;
@@ -397,6 +405,7 @@ int disable_nonboot_cpus(void)
397 * with the userspace trying to use the CPU hotplug at the same time 405 * with the userspace trying to use the CPU hotplug at the same time
398 */ 406 */
399 cpumask_clear(frozen_cpus); 407 cpumask_clear(frozen_cpus);
408 arch_disable_nonboot_cpus_begin();
400 409
401 printk("Disabling non-boot CPUs ...\n"); 410 printk("Disabling non-boot CPUs ...\n");
402 for_each_online_cpu(cpu) { 411 for_each_online_cpu(cpu) {
@@ -412,6 +421,8 @@ int disable_nonboot_cpus(void)
412 } 421 }
413 } 422 }
414 423
424 arch_disable_nonboot_cpus_end();
425
415 if (!error) { 426 if (!error) {
416 BUG_ON(num_online_cpus() > 1); 427 BUG_ON(num_online_cpus() > 1);
417 /* Make sure the CPUs won't be enabled by someone else */ 428 /* Make sure the CPUs won't be enabled by someone else */