mm/hugetlb: export hugetlb_entry_migration helper
[linux-2.6-block.git] / kernel / stop_machine.c
index 1eb82661ecdb1257adcbf1c377804a4fc446c93b..b7591261652d3ea88811f9d2af2a3ce188fb3320 100644 (file)
@@ -552,7 +552,8 @@ static int __init cpu_stop_init(void)
 }
 early_initcall(cpu_stop_init);
 
-static int __stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus)
+int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data,
+                           const struct cpumask *cpus)
 {
        struct multi_stop_data msdata = {
                .fn = fn,
@@ -561,6 +562,8 @@ static int __stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cp
                .active_cpus = cpus,
        };
 
+       lockdep_assert_cpus_held();
+
        if (!stop_machine_initialized) {
                /*
                 * Handle the case where stop_machine() is called
@@ -590,9 +593,9 @@ int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus)
        int ret;
 
        /* No CPUs can come up or down during this. */
-       get_online_cpus();
-       ret = __stop_machine(fn, data, cpus);
-       put_online_cpus();
+       cpus_read_lock();
+       ret = stop_machine_cpuslocked(fn, data, cpus);
+       cpus_read_unlock();
        return ret;
 }
 EXPORT_SYMBOL_GPL(stop_machine);