]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - include/linux/stop_machine.h
Merge branch 'kvm-updates-2.6.27' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-hirsute-kernel.git] / include / linux / stop_machine.h
1 #ifndef _LINUX_STOP_MACHINE
2 #define _LINUX_STOP_MACHINE
3 /* "Bogolock": stop the entire machine, disable interrupts. This is a
4 very heavy lock, which is equivalent to grabbing every spinlock
5 (and more). So the "read" side to such a lock is anything which
6 disables preeempt. */
7 #include <linux/cpu.h>
8 #include <linux/cpumask.h>
9 #include <asm/system.h>
10
11 #if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP)
12
13 /**
14 * stop_machine: freeze the machine on all CPUs and run this function
15 * @fn: the function to run
16 * @data: the data ptr for the @fn()
17 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
18 *
19 * Description: This causes a thread to be scheduled on every cpu,
20 * each of which disables interrupts. The result is that noone is
21 * holding a spinlock or inside any other preempt-disabled region when
22 * @fn() runs.
23 *
24 * This can be thought of as a very heavy write lock, equivalent to
25 * grabbing every spinlock in the kernel. */
26 int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus);
27
28 /**
29 * __stop_machine: freeze the machine on all CPUs and run this function
30 * @fn: the function to run
31 * @data: the data ptr for the @fn
32 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
33 *
34 * Description: This is a special version of the above, which assumes cpus
35 * won't come or go while it's being called. Used by hotplug cpu.
36 */
37 int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus);
38 #else
39
40 static inline int stop_machine(int (*fn)(void *), void *data,
41 const cpumask_t *cpus)
42 {
43 int ret;
44 local_irq_disable();
45 ret = fn(data);
46 local_irq_enable();
47 return ret;
48 }
49 #endif /* CONFIG_SMP */
50 #endif /* _LINUX_STOP_MACHINE */