Blame view

include/linux/smp.h 4.51 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
  #ifndef __LINUX_SMP_H
  #define __LINUX_SMP_H
  
  /*
   *	Generic SMP support
   *		Alan Cox. <alan@redhat.com>
   */
79974a0e4   Heiko Carstens   Let smp_call_func...
8
  #include <linux/errno.h>
54514a70a   David S. Miller   softirq: Add supp...
9
  #include <linux/types.h>
3d4422332   Jens Axboe   Add generic helpe...
10
  #include <linux/list.h>
3d4422332   Jens Axboe   Add generic helpe...
11
  #include <linux/cpumask.h>
04948c7f8   Heiko Carstens   smp: add missing ...
12
  #include <linux/init.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
14
  
  extern void cpu_idle(void);
3a5f65df5   David Howells   Typedef SMP call ...
15
  typedef void (*smp_call_func_t)(void *info);
3d4422332   Jens Axboe   Add generic helpe...
16
17
  struct call_single_data {
  	struct list_head list;
3a5f65df5   David Howells   Typedef SMP call ...
18
  	smp_call_func_t func;
3d4422332   Jens Axboe   Add generic helpe...
19
  	void *info;
54514a70a   David S. Miller   softirq: Add supp...
20
21
  	u16 flags;
  	u16 priv;
3d4422332   Jens Axboe   Add generic helpe...
22
  };
e057d7aea   Mike Travis   cpumask: add sysf...
23
24
  /* total number of cpus in this system (may exceed NR_CPUS) */
  extern unsigned int total_cpus;
3a5f65df5   David Howells   Typedef SMP call ...
25
26
  int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
  			     int wait);
53ce3d956   Andrew Morton   smp_call_function...
27

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
29
30
31
32
33
34
  #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   Linus Torvalds   Linux-2.6.12-rc2
35
36
37
38
  
  /*
   * main cross-CPU interfaces, handles INIT, TLB flush, STOP, etc.
   * (defined in asm header):
d1dedb52a   Ingo Molnar   panic, smp: provi...
39
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  
  /*
   * 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
   */
  extern int __cpu_up(unsigned int cpunum);
  
  /*
   * Final polishing of CPUs
   */
  extern void smp_cpus_done(unsigned int max_cpus);
  
  /*
   * Call a function on all other processors
   */
3a5f65df5   David Howells   Typedef SMP call ...
70
  int smp_call_function(smp_call_func_t func, void *info, int wait);
54b11e6d5   Rusty Russell   cpumask: smp_call...
71
  void smp_call_function_many(const struct cpumask *mask,
3a5f65df5   David Howells   Typedef SMP call ...
72
  			    smp_call_func_t func, void *info, bool wait);
2d3854a37   Rusty Russell   cpumask: introduc...
73

6e2756376   Peter Zijlstra   generic-ipi: remo...
74
75
  void __smp_call_function_single(int cpuid, struct call_single_data *data,
  				int wait);
3d4422332   Jens Axboe   Add generic helpe...
76

2ea6dec4a   Rusty Russell   generic-ipi: Add ...
77
  int smp_call_function_any(const struct cpumask *mask,
3a5f65df5   David Howells   Typedef SMP call ...
78
  			  smp_call_func_t func, void *info, int wait);
2ea6dec4a   Rusty Russell   generic-ipi: Add ...
79

3d4422332   Jens Axboe   Add generic helpe...
80
81
82
83
  /*
   * Generic and arch helpers
   */
  #ifdef CONFIG_USE_GENERIC_SMP_HELPERS
d8ad7d112   Takao Indoh   generic-ipi: Fix ...
84
  void __init call_function_init(void);
3d4422332   Jens Axboe   Add generic helpe...
85
86
  void generic_smp_call_function_single_interrupt(void);
  void generic_smp_call_function_interrupt(void);
3d4422332   Jens Axboe   Add generic helpe...
87
88
89
90
  void ipi_call_lock(void);
  void ipi_call_unlock(void);
  void ipi_call_lock_irq(void);
  void ipi_call_unlock_irq(void);
d8ad7d112   Takao Indoh   generic-ipi: Fix ...
91
92
  #else
  static inline void call_function_init(void) { }
3d4422332   Jens Axboe   Add generic helpe...
93
  #endif
a3bc0dbc8   Andrew Morton   [PATCH] smp_call_...
94

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
  /*
   * Call a function on all processors
   */
3a5f65df5   David Howells   Typedef SMP call ...
98
  int on_each_cpu(smp_call_func_t func, void *info, int wait);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
102
103
104
  /*
   * 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   Andi Kleen   x86: optimize loc...
105
  extern unsigned int setup_max_cpus;
34db18a05   Amerigo Wang   smp: move smp set...
106
107
  extern void __init setup_nr_cpu_ids(void);
  extern void __init smp_init(void);
ca74a6f84   Andi Kleen   x86: optimize loc...
108

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
109
  #else /* !SMP */
d1dedb52a   Ingo Molnar   panic, smp: provi...
110
  static inline void smp_send_stop(void) { }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111
112
113
  /*
   *	These macros fold the SMP functionality into a single CPU system
   */
39c715b71   Ingo Molnar   [PATCH] smp_proce...
114
  #define raw_smp_processor_id()			0
3a5f65df5   David Howells   Typedef SMP call ...
115
  static inline int up_smp_call_function(smp_call_func_t func, void *info)
3c30b06df   Con Kolivas   [PATCH] cleanup s...
116
117
118
  {
  	return 0;
  }
8691e5a8f   Jens Axboe   smp_call_function...
119
  #define smp_call_function(func, info, wait) \
a5fbb6d10   Ingo Molnar   KVM: fix !SMP bui...
120
  			(up_smp_call_function(func, info))
15c8b6c1a   Jens Axboe   on_each_cpu(): ki...
121
  #define on_each_cpu(func,info,wait)		\
78eef01b0   Andrew Morton   [PATCH] on_each_c...
122
123
124
125
126
127
  	({					\
  		local_irq_disable();		\
  		func(info);			\
  		local_irq_enable();		\
  		0;				\
  	})
79a881022   Richard Henderson   [PATCH] alpha: fi...
128
  static inline void smp_send_reschedule(int cpu) { }
2ac6608c4   Linus Torvalds   Revert broken "st...
129
130
  #define num_booting_cpus()			1
  #define smp_prepare_boot_cpu()			do {} while (0)
d2ff91188   Rusty Russell   Define smp_call_f...
131
132
  #define smp_call_function_many(mask, func, info, wait) \
  			(up_smp_call_function(func, info))
d8ad7d112   Takao Indoh   generic-ipi: Fix ...
133
  static inline void call_function_init(void) { }
2ea6dec4a   Rusty Russell   generic-ipi: Add ...
134
135
  
  static inline int
3a5f65df5   David Howells   Typedef SMP call ...
136
  smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
2ea6dec4a   Rusty Russell   generic-ipi: Add ...
137
  		      void *info, int wait)
3d4422332   Jens Axboe   Add generic helpe...
138
  {
2ea6dec4a   Rusty Russell   generic-ipi: Add ...
139
  	return smp_call_function_single(0, func, info, wait);
3d4422332   Jens Axboe   Add generic helpe...
140
  }
2ea6dec4a   Rusty Russell   generic-ipi: Add ...
141

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142
143
144
  #endif /* !SMP */
  
  /*
39c715b71   Ingo Molnar   [PATCH] smp_proce...
145
   * smp_processor_id(): get the current CPU ID.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
146
   *
cfd8d6c0e   Rakib Mullick   smp: fix document...
147
   * if DEBUG_PREEMPT is enabled then we check whether it is
39c715b71   Ingo Molnar   [PATCH] smp_proce...
148
149
150
   * 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.)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
151
   *
39c715b71   Ingo Molnar   [PATCH] smp_proce...
152
153
154
155
156
157
   * NOTE: raw_smp_processor_id() is for internal use only
   * (smp_processor_id() is the preferred variant), but in rare
   * instances it might also be used to turn off false positives
   * (i.e. smp_processor_id() use that the debugging code reports but
   * which use for some reason is legal). Don't use this to hack around
   * the warning message, as your code might not work under PREEMPT.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
158
   */
39c715b71   Ingo Molnar   [PATCH] smp_proce...
159
160
161
  #ifdef CONFIG_DEBUG_PREEMPT
    extern unsigned int debug_smp_processor_id(void);
  # define smp_processor_id() debug_smp_processor_id()
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
162
  #else
39c715b71   Ingo Molnar   [PATCH] smp_proce...
163
  # define smp_processor_id() raw_smp_processor_id()
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
164
165
166
167
  #endif
  
  #define get_cpu()		({ preempt_disable(); smp_processor_id(); })
  #define put_cpu()		preempt_enable()
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168

a146649bc   Ingo Molnar   smp, generic: int...
169
170
171
172
173
  /*
   * Callback to arch code if there's nosmp or maxcpus=0 on the
   * boot command line:
   */
  extern void arch_disable_smp_support(void);
033ab7f8e   Andrew Morton   [PATCH] add smp_s...
174
  void smp_setup_processor_id(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
175
  #endif /* __LINUX_SMP_H */