Blame view
include/linux/smp.h
5.98 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 |
#ifndef __LINUX_SMP_H #define __LINUX_SMP_H /* * Generic SMP support * Alan Cox. <alan@redhat.com> */ |
79974a0e4 Let smp_call_func... |
9 |
#include <linux/errno.h> |
54514a70a softirq: Add supp... |
10 |
#include <linux/types.h> |
3d4422332 Add generic helpe... |
11 |
#include <linux/list.h> |
3d4422332 Add generic helpe... |
12 |
#include <linux/cpumask.h> |
04948c7f8 smp: add missing ... |
13 |
#include <linux/init.h> |
6897fc22e kernel: use lockl... |
14 |
#include <linux/llist.h> |
1da177e4c Linux-2.6.12-rc2 |
15 |
|
3a5f65df5 Typedef SMP call ... |
16 |
typedef void (*smp_call_func_t)(void *info); |
966a96711 smp: Avoid using ... |
17 |
struct __call_single_data { |
0ebeb79ce smp: Remove unuse... |
18 |
struct llist_node llist; |
3a5f65df5 Typedef SMP call ... |
19 |
smp_call_func_t func; |
3d4422332 Add generic helpe... |
20 |
void *info; |
f4d03bd14 smp: don't use 16... |
21 |
unsigned int flags; |
3d4422332 Add generic helpe... |
22 |
}; |
966a96711 smp: Avoid using ... |
23 24 25 |
/* Use __aligned() to avoid to use 2 cache lines for 1 csd */ typedef struct __call_single_data call_single_data_t __aligned(sizeof(struct __call_single_data)); |
e057d7aea cpumask: add sysf... |
26 27 |
/* total number of cpus in this system (may exceed NR_CPUS) */ extern unsigned int total_cpus; |
3a5f65df5 Typedef SMP call ... |
28 29 |
int smp_call_function_single(int cpuid, smp_call_func_t func, void *info, int wait); |
53ce3d956 smp_call_function... |
30 |
|
fa688207c smp: quit uncondi... |
31 |
/* |
bff2dc42b smp.h: move !SMP ... |
32 33 |
* Call a function on all processors */ |
caa759323 smp: Remove smp_c... |
34 |
void on_each_cpu(smp_call_func_t func, void *info, int wait); |
bff2dc42b smp.h: move !SMP ... |
35 36 |
/* |
fa688207c smp: quit uncondi... |
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
* Call a function on processors specified by mask, which might include * the local one. */ void on_each_cpu_mask(const struct cpumask *mask, smp_call_func_t func, void *info, bool wait); /* * Call a function on each processor for which the supplied function * cond_func returns a positive value. This may include the local * processor. */ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info), smp_call_func_t func, void *info, bool wait, gfp_t gfp_flags); |
7d49b28a8 smp,cpumask: intr... |
51 52 53 |
void on_each_cpu_cond_mask(bool (*cond_func)(int cpu, void *info), smp_call_func_t func, void *info, bool wait, gfp_t gfp_flags, const struct cpumask *mask); |
966a96711 smp: Avoid using ... |
54 |
int smp_call_function_single_async(int cpu, call_single_data_t *csd); |
7cf64f861 kernel-provide-a-... |
55 |
|
1da177e4c Linux-2.6.12-rc2 |
56 57 58 59 60 61 62 |
#ifdef CONFIG_SMP #include <linux/preempt.h> #include <linux/kernel.h> #include <linux/compiler.h> #include <linux/thread_info.h> #include <asm/smp.h> |
1da177e4c Linux-2.6.12-rc2 |
63 64 65 66 |
/* * main cross-CPU interfaces, handles INIT, TLB flush, STOP, etc. * (defined in asm header): |
d1dedb52a panic, smp: provi... |
67 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
/* * stops all CPUs but the current one: */ extern void smp_send_stop(void); /* * sends a 'reschedule' event to another CPU: */ extern void smp_send_reschedule(int cpu); /* * Prepare machine for booting other CPUs. */ extern void smp_prepare_cpus(unsigned int max_cpus); /* * Bring a CPU up */ |
8239c25f4 smp: Add task_str... |
88 |
extern int __cpu_up(unsigned int cpunum, struct task_struct *tidle); |
1da177e4c Linux-2.6.12-rc2 |
89 90 91 92 93 94 95 96 97 |
/* * Final polishing of CPUs */ extern void smp_cpus_done(unsigned int max_cpus); /* * Call a function on all other processors */ |
caa759323 smp: Remove smp_c... |
98 |
void smp_call_function(smp_call_func_t func, void *info, int wait); |
54b11e6d5 cpumask: smp_call... |
99 |
void smp_call_function_many(const struct cpumask *mask, |
3a5f65df5 Typedef SMP call ... |
100 |
smp_call_func_t func, void *info, bool wait); |
2d3854a37 cpumask: introduc... |
101 |
|
2ea6dec4a generic-ipi: Add ... |
102 |
int smp_call_function_any(const struct cpumask *mask, |
3a5f65df5 Typedef SMP call ... |
103 |
smp_call_func_t func, void *info, int wait); |
2ea6dec4a generic-ipi: Add ... |
104 |
|
f37f435f3 smp: Implement ki... |
105 |
void kick_all_cpus_sync(void); |
c6f4459fc smp: Add new wake... |
106 |
void wake_up_all_idle_cpus(void); |
f37f435f3 smp: Implement ki... |
107 |
|
3d4422332 Add generic helpe... |
108 109 110 |
/* * Generic and arch helpers */ |
d8ad7d112 generic-ipi: Fix ... |
111 |
void __init call_function_init(void); |
3d4422332 Add generic helpe... |
112 |
void generic_smp_call_function_single_interrupt(void); |
9a46ad6d6 smp: make smp_cal... |
113 114 |
#define generic_smp_call_function_interrupt \ generic_smp_call_function_single_interrupt |
a3bc0dbc8 [PATCH] smp_call_... |
115 |
|
1da177e4c Linux-2.6.12-rc2 |
116 |
/* |
1da177e4c Linux-2.6.12-rc2 |
117 118 119 120 |
* Mark the boot cpu "online" so that it can call console drivers in * printk() and can access its per-cpu storage. */ void smp_prepare_boot_cpu(void); |
ca74a6f84 x86: optimize loc... |
121 |
extern unsigned int setup_max_cpus; |
34db18a05 smp: move smp set... |
122 123 |
extern void __init setup_nr_cpu_ids(void); extern void __init smp_init(void); |
ca74a6f84 x86: optimize loc... |
124 |
|
8ce371f98 lockdep: Fix per-... |
125 126 127 128 129 130 |
extern int __boot_cpu_id; static inline int get_boot_cpu_id(void) { return __boot_cpu_id; } |
1da177e4c Linux-2.6.12-rc2 |
131 |
#else /* !SMP */ |
d1dedb52a panic, smp: provi... |
132 |
static inline void smp_send_stop(void) { } |
1da177e4c Linux-2.6.12-rc2 |
133 134 135 |
/* * These macros fold the SMP functionality into a single CPU system */ |
39c715b71 [PATCH] smp_proce... |
136 |
#define raw_smp_processor_id() 0 |
caa759323 smp: Remove smp_c... |
137 |
static inline void up_smp_call_function(smp_call_func_t func, void *info) |
3c30b06df [PATCH] cleanup s... |
138 |
{ |
3c30b06df [PATCH] cleanup s... |
139 |
} |
8691e5a8f smp_call_function... |
140 |
#define smp_call_function(func, info, wait) \ |
a5fbb6d10 KVM: fix !SMP bui... |
141 |
(up_smp_call_function(func, info)) |
3b8967d71 include/linux/smp... |
142 |
|
79a881022 [PATCH] alpha: fi... |
143 |
static inline void smp_send_reschedule(int cpu) { } |
2ac6608c4 Revert broken "st... |
144 |
#define smp_prepare_boot_cpu() do {} while (0) |
d2ff91188 Define smp_call_f... |
145 146 |
#define smp_call_function_many(mask, func, info, wait) \ (up_smp_call_function(func, info)) |
d8ad7d112 generic-ipi: Fix ... |
147 |
static inline void call_function_init(void) { } |
2ea6dec4a generic-ipi: Add ... |
148 149 |
static inline int |
3a5f65df5 Typedef SMP call ... |
150 |
smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, |
2ea6dec4a generic-ipi: Add ... |
151 |
void *info, int wait) |
3d4422332 Add generic helpe... |
152 |
{ |
2ea6dec4a generic-ipi: Add ... |
153 |
return smp_call_function_single(0, func, info, wait); |
3d4422332 Add generic helpe... |
154 |
} |
2ea6dec4a generic-ipi: Add ... |
155 |
|
f37f435f3 smp: Implement ki... |
156 |
static inline void kick_all_cpus_sync(void) { } |
c6f4459fc smp: Add new wake... |
157 |
static inline void wake_up_all_idle_cpus(void) { } |
f37f435f3 smp: Implement ki... |
158 |
|
30b8b0066 init: Get rid of ... |
159 160 161 162 163 164 |
#ifdef CONFIG_UP_LATE_INIT extern void __init up_late_init(void); static inline void smp_init(void) { up_late_init(); } #else static inline void smp_init(void) { } #endif |
8ce371f98 lockdep: Fix per-... |
165 166 167 168 |
static inline int get_boot_cpu_id(void) { return 0; } |
1da177e4c Linux-2.6.12-rc2 |
169 |
#endif /* !SMP */ |
9ed7d75b2 x86/percpu: Relax... |
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
/** * raw_processor_id() - get the current (unstable) CPU id * * For then you know what you are doing and need an unstable * CPU id. */ /** * smp_processor_id() - get the current (stable) CPU id * * This is the normal accessor to the CPU id and should be used * whenever possible. * * The CPU id is stable when: |
1da177e4c Linux-2.6.12-rc2 |
184 |
* |
9ed7d75b2 x86/percpu: Relax... |
185 186 187 |
* - IRQs are disabled; * - preemption is disabled; * - the task is CPU affine. |
1da177e4c Linux-2.6.12-rc2 |
188 |
* |
9ed7d75b2 x86/percpu: Relax... |
189 190 |
* When CONFIG_DEBUG_PREEMPT; we verify these assumption and WARN * when smp_processor_id() is used when the CPU id is not stable. |
1da177e4c Linux-2.6.12-rc2 |
191 |
*/ |
9ed7d75b2 x86/percpu: Relax... |
192 193 194 195 196 197 198 199 200 |
/* * Allow the architecture to differentiate between a stable and unstable read. * For example, x86 uses an IRQ-safe asm-volatile read for the unstable but a * regular asm read for the stable. */ #ifndef __smp_processor_id #define __smp_processor_id(x) raw_smp_processor_id(x) #endif |
39c715b71 [PATCH] smp_proce... |
201 202 203 |
#ifdef CONFIG_DEBUG_PREEMPT extern unsigned int debug_smp_processor_id(void); # define smp_processor_id() debug_smp_processor_id() |
1da177e4c Linux-2.6.12-rc2 |
204 |
#else |
9ed7d75b2 x86/percpu: Relax... |
205 |
# define smp_processor_id() __smp_processor_id() |
1da177e4c Linux-2.6.12-rc2 |
206 |
#endif |
9ed7d75b2 x86/percpu: Relax... |
207 |
#define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) |
1da177e4c Linux-2.6.12-rc2 |
208 |
#define put_cpu() preempt_enable() |
1da177e4c Linux-2.6.12-rc2 |
209 |
|
a146649bc smp, generic: int... |
210 211 212 213 214 |
/* * Callback to arch code if there's nosmp or maxcpus=0 on the * boot command line: */ extern void arch_disable_smp_support(void); |
fb37bb04d smp.h: fix x86+cp... |
215 216 |
extern void arch_enable_nonboot_cpus_begin(void); extern void arch_enable_nonboot_cpus_end(void); |
033ab7f8e [PATCH] add smp_s... |
217 |
void smp_setup_processor_id(void); |
df8ce9d78 smp: Add function... |
218 219 |
int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys); |
31487f832 smp/cfd: Convert ... |
220 221 222 223 |
/* SMP core functions */ int smpcfd_prepare_cpu(unsigned int cpu); int smpcfd_dead_cpu(unsigned int cpu); int smpcfd_dying_cpu(unsigned int cpu); |
1da177e4c Linux-2.6.12-rc2 |
224 |
#endif /* __LINUX_SMP_H */ |