From: Heiko Carstens If only one cpu is online we might as well use the non-smp variant of stop_machine which should be much faster since no scheduling is needed. Signed-off-by: Heiko Carstens --- include/linux/stop_machine.h | 16 +++++++++++----- kernel/stop_machine.c | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) Index: linux-2.6/include/linux/stop_machine.h =================================================================== --- linux-2.6.orig/include/linux/stop_machine.h +++ linux-2.6/include/linux/stop_machine.h @@ -8,6 +8,16 @@ #include #include +static inline int stop_machine_simple(int (*fn)(void *), void *data, + const cpumask_t *cpus) +{ + int ret; + local_irq_disable(); + ret = fn(data); + local_irq_enable(); + return ret; +} + #if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP) /** @@ -40,11 +50,7 @@ int __stop_machine(int (*fn)(void *), vo static inline int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) { - int ret; - local_irq_disable(); - ret = fn(data); - local_irq_enable(); - return ret; + return stop_machine_simple(fn, data, cpus); } #endif /* CONFIG_SMP */ #endif /* _LINUX_STOP_MACHINE */ Index: linux-2.6/kernel/stop_machine.c =================================================================== --- linux-2.6.orig/kernel/stop_machine.c +++ linux-2.6/kernel/stop_machine.c @@ -111,6 +111,9 @@ int __stop_machine(int (*fn)(void *), vo struct work_struct *sm_work; int i; + if (num_online_cpus() == 1) + return stop_machine_simple(fn, data, cpus); + /* Set up initial state. */ mutex_lock(&lock); num_threads = num_online_cpus(); -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/