|
@@ -273,6 +273,7 @@ struct smp_alt_module {
|
|
};
|
|
};
|
|
static LIST_HEAD(smp_alt_modules);
|
|
static LIST_HEAD(smp_alt_modules);
|
|
static DEFINE_SPINLOCK(smp_alt);
|
|
static DEFINE_SPINLOCK(smp_alt);
|
|
|
|
+static int smp_mode = 1; /* protected by smp_alt */
|
|
|
|
|
|
void alternatives_smp_module_add(struct module *mod, char *name,
|
|
void alternatives_smp_module_add(struct module *mod, char *name,
|
|
void *locks, void *locks_end,
|
|
void *locks, void *locks_end,
|
|
@@ -354,7 +355,14 @@ void alternatives_smp_switch(int smp)
|
|
BUG_ON(!smp && (num_online_cpus() > 1));
|
|
BUG_ON(!smp && (num_online_cpus() > 1));
|
|
|
|
|
|
spin_lock_irqsave(&smp_alt, flags);
|
|
spin_lock_irqsave(&smp_alt, flags);
|
|
- if (smp) {
|
|
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Avoid unnecessary switches because it forces JIT based VMs to
|
|
|
|
+ * throw away all cached translations, which can be quite costly.
|
|
|
|
+ */
|
|
|
|
+ if (smp == smp_mode) {
|
|
|
|
+ /* nothing */
|
|
|
|
+ } else if (smp) {
|
|
printk(KERN_INFO "SMP alternatives: switching to SMP code\n");
|
|
printk(KERN_INFO "SMP alternatives: switching to SMP code\n");
|
|
clear_cpu_cap(&boot_cpu_data, X86_FEATURE_UP);
|
|
clear_cpu_cap(&boot_cpu_data, X86_FEATURE_UP);
|
|
clear_cpu_cap(&cpu_data(0), X86_FEATURE_UP);
|
|
clear_cpu_cap(&cpu_data(0), X86_FEATURE_UP);
|
|
@@ -369,6 +377,7 @@ void alternatives_smp_switch(int smp)
|
|
alternatives_smp_unlock(mod->locks, mod->locks_end,
|
|
alternatives_smp_unlock(mod->locks, mod->locks_end,
|
|
mod->text, mod->text_end);
|
|
mod->text, mod->text_end);
|
|
}
|
|
}
|
|
|
|
+ smp_mode = smp;
|
|
spin_unlock_irqrestore(&smp_alt, flags);
|
|
spin_unlock_irqrestore(&smp_alt, flags);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -441,7 +450,10 @@ void __init alternative_instructions(void)
|
|
alternatives_smp_module_add(NULL, "core kernel",
|
|
alternatives_smp_module_add(NULL, "core kernel",
|
|
__smp_locks, __smp_locks_end,
|
|
__smp_locks, __smp_locks_end,
|
|
_text, _etext);
|
|
_text, _etext);
|
|
- alternatives_smp_switch(0);
|
|
|
|
|
|
+
|
|
|
|
+ /* Only switch to UP mode if we don't immediately boot others */
|
|
|
|
+ if (num_possible_cpus() == 1 || setup_max_cpus <= 1)
|
|
|
|
+ alternatives_smp_switch(0);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
apply_paravirt(__parainstructions, __parainstructions_end);
|
|
apply_paravirt(__parainstructions, __parainstructions_end);
|