diff options
Diffstat (limited to 'include/linux/smp.h')
| -rw-r--r-- | include/linux/smp.h | 122 |
1 files changed, 83 insertions, 39 deletions
diff --git a/include/linux/smp.h b/include/linux/smp.h index 55232ccf9cf..34347f26be9 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -7,8 +7,48 @@ */ #include <linux/errno.h> +#include <linux/types.h> +#include <linux/list.h> +#include <linux/cpumask.h> +#include <linux/init.h> +#include <linux/llist.h> + +typedef void (*smp_call_func_t)(void *info); +struct call_single_data { + struct llist_node llist; + smp_call_func_t func; + void *info; + u16 flags; +}; + +/* total number of cpus in this system (may exceed NR_CPUS) */ +extern unsigned int total_cpus; + +int smp_call_function_single(int cpuid, smp_call_func_t func, void *info, + int wait); -extern void cpu_idle(void); +/* + * Call a function on all processors + */ +int on_each_cpu(smp_call_func_t func, void *info, int wait); + +/* + * 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); + +int smp_call_function_single_async(int cpu, struct call_single_data *csd); #ifdef CONFIG_SMP @@ -21,7 +61,7 @@ extern void cpu_idle(void); /* * main cross-CPU interfaces, handles INIT, TLB flush, STOP, etc. * (defined in asm header): - */ + */ /* * stops all CPUs but the current one: @@ -42,7 +82,7 @@ extern void smp_prepare_cpus(unsigned int max_cpus); /* * Bring a CPU up */ -extern int __cpu_up(unsigned int cpunum); +extern int __cpu_up(unsigned int cpunum, struct task_struct *tidle); /* * Final polishing of CPUs @@ -52,25 +92,22 @@ extern void smp_cpus_done(unsigned int max_cpus); /* * Call a function on all other processors */ -int smp_call_function(void(*func)(void *info), void *info, int retry, int wait); +int smp_call_function(smp_call_func_t func, void *info, int wait); +void smp_call_function_many(const struct cpumask *mask, + smp_call_func_t func, void *info, bool wait); + +int smp_call_function_any(const struct cpumask *mask, + smp_call_func_t func, void *info, int wait); -int smp_call_function_single(int cpuid, void (*func) (void *info), void *info, - int retry, int wait); +void kick_all_cpus_sync(void); /* - * Call a function on all processors + * Generic and arch helpers */ -int on_each_cpu(void (*func) (void *info), void *info, int retry, int wait); - -#define MSG_ALL_BUT_SELF 0x8000 /* Assume <32768 CPU's */ -#define MSG_ALL 0x8001 - -#define MSG_INVALIDATE_TLB 0x0001 /* Remote processor TLB invalidate */ -#define MSG_STOP_CPU 0x0002 /* Sent to shut down slave CPU's - * when rebooting - */ -#define MSG_RESCHEDULE 0x0003 /* Reschedule request from master CPU*/ -#define MSG_CALL_FUNCTION 0x0004 /* Call function on all other CPUs */ +void __init call_function_init(void); +void generic_smp_call_function_single_interrupt(void); +#define generic_smp_call_function_interrupt \ + generic_smp_call_function_single_interrupt /* * Mark the boot cpu "online" so that it can call console drivers in @@ -79,46 +116,45 @@ int on_each_cpu(void (*func) (void *info), void *info, int retry, int wait); void smp_prepare_boot_cpu(void); extern unsigned int setup_max_cpus; +extern void __init setup_nr_cpu_ids(void); +extern void __init smp_init(void); #else /* !SMP */ +static inline void smp_send_stop(void) { } + /* * These macros fold the SMP functionality into a single CPU system */ #define raw_smp_processor_id() 0 -static inline int up_smp_call_function(void (*func)(void *), void *info) +static inline int up_smp_call_function(smp_call_func_t func, void *info) { return 0; } -#define smp_call_function(func, info, retry, wait) \ +#define smp_call_function(func, info, wait) \ (up_smp_call_function(func, info)) -#define on_each_cpu(func,info,retry,wait) \ - ({ \ - local_irq_disable(); \ - func(info); \ - local_irq_enable(); \ - 0; \ - }) + static inline void smp_send_reschedule(int cpu) { } -#define num_booting_cpus() 1 #define smp_prepare_boot_cpu() do {} while (0) -#define smp_call_function_single(cpuid, func, info, retry, wait) \ -({ \ - WARN_ON(cpuid != 0); \ - local_irq_disable(); \ - (func)(info); \ - local_irq_enable(); \ - 0; \ -}) -#define smp_call_function_mask(mask, func, info, wait) \ +#define smp_call_function_many(mask, func, info, wait) \ (up_smp_call_function(func, info)) +static inline void call_function_init(void) { } + +static inline int +smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, + void *info, int wait) +{ + return smp_call_function_single(0, func, info, wait); +} + +static inline void kick_all_cpus_sync(void) { } #endif /* !SMP */ /* * smp_processor_id(): get the current CPU ID. * - * if DEBUG_PREEMPT is enabled the we check whether it is + * if DEBUG_PREEMPT is enabled then we check whether it is * used in a preemption-safe way. (smp_processor_id() is safe * if it's used in a preemption-off critical section, or in * a thread that is bound to the current CPU.) @@ -139,7 +175,15 @@ static inline void smp_send_reschedule(int cpu) { } #define get_cpu() ({ preempt_disable(); smp_processor_id(); }) #define put_cpu() preempt_enable() -#define put_cpu_no_resched() preempt_enable_no_resched() + +/* + * Callback to arch code if there's nosmp or maxcpus=0 on the + * boot command line: + */ +extern void arch_disable_smp_support(void); + +extern void arch_enable_nonboot_cpus_begin(void); +extern void arch_enable_nonboot_cpus_end(void); void smp_setup_processor_id(void); |
