diff options
Diffstat (limited to 'include/linux/stop_machine.h')
-rw-r--r-- | include/linux/stop_machine.h | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h index 5bfc553bdb21..f1cb0ba6d715 100644 --- a/include/linux/stop_machine.h +++ b/include/linux/stop_machine.h | |||
@@ -5,41 +5,43 @@ | |||
5 | (and more). So the "read" side to such a lock is anything which | 5 | (and more). So the "read" side to such a lock is anything which |
6 | diables preeempt. */ | 6 | diables preeempt. */ |
7 | #include <linux/cpu.h> | 7 | #include <linux/cpu.h> |
8 | #include <linux/cpumask.h> | ||
8 | #include <asm/system.h> | 9 | #include <asm/system.h> |
9 | 10 | ||
10 | #if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP) | 11 | #if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP) |
12 | |||
13 | /* Deprecated, but useful for transition. */ | ||
14 | #define ALL_CPUS ~0U | ||
15 | |||
11 | /** | 16 | /** |
12 | * stop_machine_run: freeze the machine on all CPUs and run this function | 17 | * stop_machine: freeze the machine on all CPUs and run this function |
13 | * @fn: the function to run | 18 | * @fn: the function to run |
14 | * @data: the data ptr for the @fn() | 19 | * @data: the data ptr for the @fn() |
15 | * @cpu: the cpu to run @fn() on (or any, if @cpu == NR_CPUS. | 20 | * @cpus: the cpus to run the @fn() on (NULL = any online cpu) |
16 | * | 21 | * |
17 | * Description: This causes a thread to be scheduled on every other cpu, | 22 | * Description: This causes a thread to be scheduled on every cpu, |
18 | * each of which disables interrupts, and finally interrupts are disabled | 23 | * each of which disables interrupts. The result is that noone is |
19 | * on the current CPU. The result is that noone is holding a spinlock | 24 | * holding a spinlock or inside any other preempt-disabled region when |
20 | * or inside any other preempt-disabled region when @fn() runs. | 25 | * @fn() runs. |
21 | * | 26 | * |
22 | * This can be thought of as a very heavy write lock, equivalent to | 27 | * This can be thought of as a very heavy write lock, equivalent to |
23 | * grabbing every spinlock in the kernel. */ | 28 | * grabbing every spinlock in the kernel. */ |
24 | int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu); | 29 | int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus); |
25 | 30 | ||
26 | /** | 31 | /** |
27 | * __stop_machine_run: freeze the machine on all CPUs and run this function | 32 | * __stop_machine: freeze the machine on all CPUs and run this function |
28 | * @fn: the function to run | 33 | * @fn: the function to run |
29 | * @data: the data ptr for the @fn | 34 | * @data: the data ptr for the @fn |
30 | * @cpu: the cpu to run @fn on (or any, if @cpu == NR_CPUS. | 35 | * @cpus: the cpus to run the @fn() on (NULL = any online cpu) |
31 | * | 36 | * |
32 | * Description: This is a special version of the above, which returns the | 37 | * Description: This is a special version of the above, which assumes cpus |
33 | * thread which has run @fn(): kthread_stop will return the return value | 38 | * won't come or go while it's being called. Used by hotplug cpu. |
34 | * of @fn(). Used by hotplug cpu. | ||
35 | */ | 39 | */ |
36 | struct task_struct *__stop_machine_run(int (*fn)(void *), void *data, | 40 | int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus); |
37 | unsigned int cpu); | ||
38 | |||
39 | #else | 41 | #else |
40 | 42 | ||
41 | static inline int stop_machine_run(int (*fn)(void *), void *data, | 43 | static inline int stop_machine(int (*fn)(void *), void *data, |
42 | unsigned int cpu) | 44 | const cpumask_t *cpus) |
43 | { | 45 | { |
44 | int ret; | 46 | int ret; |
45 | local_irq_disable(); | 47 | local_irq_disable(); |
@@ -48,4 +50,18 @@ static inline int stop_machine_run(int (*fn)(void *), void *data, | |||
48 | return ret; | 50 | return ret; |
49 | } | 51 | } |
50 | #endif /* CONFIG_SMP */ | 52 | #endif /* CONFIG_SMP */ |
53 | |||
54 | static inline int __deprecated stop_machine_run(int (*fn)(void *), void *data, | ||
55 | unsigned int cpu) | ||
56 | { | ||
57 | /* If they don't care which cpu fn runs on, just pick one. */ | ||
58 | if (cpu == NR_CPUS) | ||
59 | return stop_machine(fn, data, NULL); | ||
60 | else if (cpu == ~0U) | ||
61 | return stop_machine(fn, data, &cpu_possible_map); | ||
62 | else { | ||
63 | cpumask_t cpus = cpumask_of_cpu(cpu); | ||
64 | return stop_machine(fn, data, &cpus); | ||
65 | } | ||
66 | } | ||
51 | #endif /* _LINUX_STOP_MACHINE */ | 67 | #endif /* _LINUX_STOP_MACHINE */ |