]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/smp.h
e2935c0a1bb4448d1e1dcb1c53b83fa2841cc1a4
6 * Alan Cox. <alan@redhat.com>
9 #include <linux/errno.h>
10 #include <linux/types.h>
11 #include <linux/list.h>
12 #include <linux/cpumask.h>
13 #include <linux/init.h>
14 #include <linux/llist.h>
16 typedef void (*smp_call_func_t
)(void *info
);
17 struct call_single_data
{
18 struct llist_node llist
;
24 /* total number of cpus in this system (may exceed NR_CPUS) */
25 extern unsigned int total_cpus
;
27 int smp_call_function_single(int cpuid
, smp_call_func_t func
, void *info
,
31 * Call a function on all processors
33 int on_each_cpu(smp_call_func_t func
, void *info
, int wait
);
36 * Call a function on processors specified by mask, which might include
39 void on_each_cpu_mask(const struct cpumask
*mask
, smp_call_func_t func
,
40 void *info
, bool wait
);
43 * Call a function on each processor for which the supplied function
44 * cond_func returns a positive value. This may include the local
47 void on_each_cpu_cond(bool (*cond_func
)(int cpu
, void *info
),
48 smp_call_func_t func
, void *info
, bool wait
,
51 int smp_call_function_single_async(int cpu
, struct call_single_data
*csd
);
54 /* indicate usage of IBRS to control execution speculation */
56 extern u32 sysctl_ibrs_enabled
;
57 extern struct mutex spec_ctrl_mutex
;
58 #define ibrs_supported (use_ibrs & 0x2)
59 #define ibrs_disabled (use_ibrs & 0x4)
60 static inline void set_ibrs_inuse(void)
65 static inline void clear_ibrs_inuse(void)
69 static inline int check_ibrs_inuse(void)
74 /* rmb to prevent wrong speculation for security */
78 static inline void set_ibrs_supported(void)
84 static inline void set_ibrs_disabled(void)
87 if (check_ibrs_inuse())
90 static inline void clear_ibrs_disabled(void)
95 #define ibrs_inuse (check_ibrs_inuse())
97 /* indicate usage of IBPB to control execution speculation */
99 extern u32 sysctl_ibpb_enabled
;
100 #define ibpb_supported (use_ibpb & 0x2)
101 #define ibpb_disabled (use_ibpb & 0x4)
102 static inline void set_ibpb_inuse(void)
107 static inline void clear_ibpb_inuse(void)
111 static inline int check_ibpb_inuse(void)
116 /* rmb to prevent wrong speculation for security */
120 static inline void set_ibpb_supported(void)
126 static inline void set_ibpb_disabled(void)
129 if (check_ibpb_inuse())
132 static inline void clear_ibpb_disabled(void)
137 #define ibpb_inuse (check_ibpb_inuse())
142 #include <linux/preempt.h>
143 #include <linux/kernel.h>
144 #include <linux/compiler.h>
145 #include <linux/thread_info.h>
149 * main cross-CPU interfaces, handles INIT, TLB flush, STOP, etc.
150 * (defined in asm header):
154 * stops all CPUs but the current one:
156 extern void smp_send_stop(void);
159 * sends a 'reschedule' event to another CPU:
161 extern void smp_send_reschedule(int cpu
);
165 * Prepare machine for booting other CPUs.
167 extern void smp_prepare_cpus(unsigned int max_cpus
);
172 extern int __cpu_up(unsigned int cpunum
, struct task_struct
*tidle
);
175 * Final polishing of CPUs
177 extern void smp_cpus_done(unsigned int max_cpus
);
180 * Call a function on all other processors
182 int smp_call_function(smp_call_func_t func
, void *info
, int wait
);
183 void smp_call_function_many(const struct cpumask
*mask
,
184 smp_call_func_t func
, void *info
, bool wait
);
186 int smp_call_function_any(const struct cpumask
*mask
,
187 smp_call_func_t func
, void *info
, int wait
);
189 void kick_all_cpus_sync(void);
190 void wake_up_all_idle_cpus(void);
193 * Generic and arch helpers
195 void __init
call_function_init(void);
196 void generic_smp_call_function_single_interrupt(void);
197 #define generic_smp_call_function_interrupt \
198 generic_smp_call_function_single_interrupt
201 * Mark the boot cpu "online" so that it can call console drivers in
202 * printk() and can access its per-cpu storage.
204 void smp_prepare_boot_cpu(void);
206 extern unsigned int setup_max_cpus
;
207 extern void __init
setup_nr_cpu_ids(void);
208 extern void __init
smp_init(void);
210 extern int __boot_cpu_id
;
212 static inline int get_boot_cpu_id(void)
214 return __boot_cpu_id
;
219 static inline void smp_send_stop(void) { }
222 * These macros fold the SMP functionality into a single CPU system
224 #define raw_smp_processor_id() 0
225 static inline int up_smp_call_function(smp_call_func_t func
, void *info
)
229 #define smp_call_function(func, info, wait) \
230 (up_smp_call_function(func, info))
232 static inline void smp_send_reschedule(int cpu
) { }
233 #define smp_prepare_boot_cpu() do {} while (0)
234 #define smp_call_function_many(mask, func, info, wait) \
235 (up_smp_call_function(func, info))
236 static inline void call_function_init(void) { }
239 smp_call_function_any(const struct cpumask
*mask
, smp_call_func_t func
,
240 void *info
, int wait
)
242 return smp_call_function_single(0, func
, info
, wait
);
245 static inline void kick_all_cpus_sync(void) { }
246 static inline void wake_up_all_idle_cpus(void) { }
248 #ifdef CONFIG_UP_LATE_INIT
249 extern void __init
up_late_init(void);
250 static inline void smp_init(void) { up_late_init(); }
252 static inline void smp_init(void) { }
255 static inline int get_boot_cpu_id(void)
263 * smp_processor_id(): get the current CPU ID.
265 * if DEBUG_PREEMPT is enabled then we check whether it is
266 * used in a preemption-safe way. (smp_processor_id() is safe
267 * if it's used in a preemption-off critical section, or in
268 * a thread that is bound to the current CPU.)
270 * NOTE: raw_smp_processor_id() is for internal use only
271 * (smp_processor_id() is the preferred variant), but in rare
272 * instances it might also be used to turn off false positives
273 * (i.e. smp_processor_id() use that the debugging code reports but
274 * which use for some reason is legal). Don't use this to hack around
275 * the warning message, as your code might not work under PREEMPT.
277 #ifdef CONFIG_DEBUG_PREEMPT
278 extern unsigned int debug_smp_processor_id(void);
279 # define smp_processor_id() debug_smp_processor_id()
281 # define smp_processor_id() raw_smp_processor_id()
284 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
285 #define put_cpu() preempt_enable()
288 * Callback to arch code if there's nosmp or maxcpus=0 on the
291 extern void arch_disable_smp_support(void);
293 extern void arch_enable_nonboot_cpus_begin(void);
294 extern void arch_enable_nonboot_cpus_end(void);
296 void smp_setup_processor_id(void);
298 int smp_call_on_cpu(unsigned int cpu
, int (*func
)(void *), void *par
,
301 /* SMP core functions */
302 int smpcfd_prepare_cpu(unsigned int cpu
);
303 int smpcfd_dead_cpu(unsigned int cpu
);
304 int smpcfd_dying_cpu(unsigned int cpu
);
306 #endif /* __LINUX_SMP_H */