]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - kernel/up.c
up.c: use local_irq_{save,restore}() in smp_call_function_single.
[mirror_ubuntu-zesty-kernel.git] / kernel / up.c
CommitLineData
53ce3d95
AM
1/*
2 * Uniprocessor-only support functions. The counterpart to kernel/smp.c
3 */
4
6e962814 5#include <linux/interrupt.h>
53ce3d95 6#include <linux/kernel.h>
9984de1a 7#include <linux/export.h>
53ce3d95
AM
8#include <linux/smp.h>
9
10int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
11 int wait)
12{
081192b2
DD
13 unsigned long flags;
14
93423b86
IM
15 WARN_ON(cpu != 0);
16
081192b2
DD
17 local_irq_save(flags);
18 func(info);
19 local_irq_restore(flags);
93423b86 20
53ce3d95
AM
21 return 0;
22}
23EXPORT_SYMBOL(smp_call_function_single);
fa688207
DD
24
25/*
26 * Note we still need to test the mask even for UP
27 * because we actually can get an empty mask from
28 * code that on SMP might call us without the local
29 * CPU in the mask.
30 */
31void on_each_cpu_mask(const struct cpumask *mask,
32 smp_call_func_t func, void *info, bool wait)
33{
34 unsigned long flags;
35
36 if (cpumask_test_cpu(0, mask)) {
37 local_irq_save(flags);
38 func(info);
39 local_irq_restore(flags);
40 }
41}
42EXPORT_SYMBOL(on_each_cpu_mask);
43
44/*
45 * Preemption is disabled here to make sure the cond_func is called under the
46 * same condtions in UP and SMP.
47 */
48void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
49 smp_call_func_t func, void *info, bool wait,
50 gfp_t gfp_flags)
51{
52 unsigned long flags;
53
54 preempt_disable();
55 if (cond_func(0, info)) {
56 local_irq_save(flags);
57 func(info);
58 local_irq_restore(flags);
59 }
60 preempt_enable();
61}
62EXPORT_SYMBOL(on_each_cpu_cond);