Merge branch 'semaphore' of git://git.kernel.org/pub/scm/linux/kernel/git/willy/misc
[sfrench/cifs-2.6.git] / kernel / stop_machine.c
index fcee2a8e6da37a79a02a09a4dfaca30887098292..dc25b0baaa96944df5a61cc3cfef356f7f0c3bbd 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/interrupt.h>
 
 #include <asm/atomic.h>
-#include <asm/semaphore.h>
 #include <asm/uaccess.h>
 
 /* Since we effect priority and affinity (both of which are visible
@@ -29,14 +28,13 @@ enum stopmachine_state {
 static enum stopmachine_state stopmachine_state;
 static unsigned int stopmachine_num_threads;
 static atomic_t stopmachine_thread_ack;
-static DECLARE_MUTEX(stopmachine_mutex);
 
 static int stopmachine(void *cpu)
 {
        int irqs_disabled = 0;
        int prepared = 0;
 
-       set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu));
+       set_cpus_allowed_ptr(current, &cpumask_of_cpu((int)(long)cpu));
 
        /* Ack: we are alive */
        smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */
@@ -93,10 +91,6 @@ static void stopmachine_set_state(enum stopmachine_state state)
 static int stop_machine(void)
 {
        int i, ret = 0;
-       struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
-
-       /* One high-prio thread per cpu.  We'll do this one. */
-       sched_setscheduler(current, SCHED_FIFO, &param);
 
        atomic_set(&stopmachine_thread_ack, 0);
        stopmachine_num_threads = 0;
@@ -174,6 +168,7 @@ static int do_stop(void *_smdata)
 struct task_struct *__stop_machine_run(int (*fn)(void *), void *data,
                                       unsigned int cpu)
 {
+       static DEFINE_MUTEX(stopmachine_mutex);
        struct stop_machine_data smdata;
        struct task_struct *p;
 
@@ -181,7 +176,7 @@ struct task_struct *__stop_machine_run(int (*fn)(void *), void *data,
        smdata.data = data;
        init_completion(&smdata.done);
 
-       down(&stopmachine_mutex);
+       mutex_lock(&stopmachine_mutex);
 
        /* If they don't care which CPU fn runs on, bind to any online one. */
        if (cpu == NR_CPUS)
@@ -189,11 +184,15 @@ struct task_struct *__stop_machine_run(int (*fn)(void *), void *data,
 
        p = kthread_create(do_stop, &smdata, "kstopmachine");
        if (!IS_ERR(p)) {
+               struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
+
+               /* One high-prio thread per cpu.  We'll do this one. */
+               sched_setscheduler(p, SCHED_FIFO, &param);
                kthread_bind(p, cpu);
                wake_up_process(p);
                wait_for_completion(&smdata.done);
        }
-       up(&stopmachine_mutex);
+       mutex_unlock(&stopmachine_mutex);
        return p;
 }
 
@@ -203,13 +202,13 @@ int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu)
        int ret;
 
        /* No CPUs can come up or down during this. */
-       lock_cpu_hotplug();
+       get_online_cpus();
        p = __stop_machine_run(fn, data, cpu);
        if (!IS_ERR(p))
                ret = kthread_stop(p);
        else
                ret = PTR_ERR(p);
-       unlock_cpu_hotplug();
+       put_online_cpus();
 
        return ret;
 }