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
8 #include <linux/cpumask.h>
9 #include <asm/system.h>
11 #if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP)
13 /* Deprecated, but useful for transition. */
17 * stop_machine: freeze the machine on all CPUs and run this function
18 * @fn: the function to run
19 * @data: the data ptr for the @fn()
20 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
22 * Description: This causes a thread to be scheduled on every cpu,
23 * each of which disables interrupts. The result is that noone is
24 * holding a spinlock or inside any other preempt-disabled region when
27 * This can be thought of as a very heavy write lock, equivalent to
28 * grabbing every spinlock in the kernel. */
29 int stop_machine(int (*fn
)(void *), void *data
, const cpumask_t
*cpus
);
32 * __stop_machine: freeze the machine on all CPUs and run this function
33 * @fn: the function to run
34 * @data: the data ptr for the @fn
35 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
37 * Description: This is a special version of the above, which assumes cpus
38 * won't come or go while it's being called. Used by hotplug cpu.
40 int __stop_machine(int (*fn
)(void *), void *data
, const cpumask_t
*cpus
);
43 static inline int stop_machine(int (*fn
)(void *), void *data
,
44 const cpumask_t
*cpus
)
52 #endif /* CONFIG_SMP */
54 static inline int __deprecated
stop_machine_run(int (*fn
)(void *), void *data
,
57 /* If they don't care which cpu fn runs on, just pick one. */
59 return stop_machine(fn
, data
, NULL
);
61 return stop_machine(fn
, data
, &cpu_possible_map
);
63 cpumask_t cpus
= cpumask_of_cpu(cpu
);
64 return stop_machine(fn
, data
, &cpus
);
67 #endif /* _LINUX_STOP_MACHINE */