Blame view

include/linux/cpu.h 7.86 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
  /*
   * include/linux/cpu.h - generic cpu definition
   *
   * This is mainly for topological representation. We define the 
   * basic 'struct cpu' here, which can be embedded in per-arch 
   * definitions of processors.
   *
   * Basic handling of the devices is done in drivers/base/cpu.c
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
   *
611a75e18   Robert P. J. Day   include/linux/cpu...
10
   * CPUs are exported via sysfs in the devices/system/cpu
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
   * directory. 
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
14
   */
  #ifndef _LINUX_CPU_H_
  #define _LINUX_CPU_H_
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
16
17
  #include <linux/node.h>
  #include <linux/compiler.h>
  #include <linux/cpumask.h>
cff7d378d   Thomas Gleixner   cpu/hotplug: Conv...
18
  #include <linux/cpuhotplug.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19

313162d0b   Paul Gortmaker   device.h: audit a...
20
  struct device;
d1cb9d1af   David Miller   of: Make cpu node...
21
  struct device_node;
3d52943b3   Sudeep Holla   drivers: base: ad...
22
  struct attribute_group;
313162d0b   Paul Gortmaker   device.h: audit a...
23

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
  struct cpu {
  	int node_id;		/* The node which contains the CPU */
72486f1f8   Siddha, Suresh B   [PATCH] i386: cha...
26
  	int hotpluggable;	/* creates sysfs control file if hotpluggable */
8a25a2fd1   Kay Sievers   cpu: convert 'cpu...
27
  	struct device dev;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
  };
cff7d378d   Thomas Gleixner   cpu/hotplug: Conv...
29
30
  extern void boot_cpu_init(void);
  extern void boot_cpu_state_init(void);
76b67ed9d   KAMEZAWA Hiroyuki   [PATCH] node hotp...
31
  extern int register_cpu(struct cpu *cpu, int num);
8a25a2fd1   Kay Sievers   cpu: convert 'cpu...
32
  extern struct device *get_cpu_device(unsigned cpu);
2987557f5   Josh Triplett   driver-core/cpu: ...
33
  extern bool cpu_is_hotpluggable(unsigned cpu);
183912d35   Sudeep KarkadaNagesha   of: move of_get_c...
34
  extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id);
d1cb9d1af   David Miller   of: Make cpu node...
35
36
  extern bool arch_find_n_match_cpu_physical_id(struct device_node *cpun,
  					      int cpu, unsigned int *thread);
0344c6c53   Christian Krafft   [POWERPC] sysfs: ...
37

8a25a2fd1   Kay Sievers   cpu: convert 'cpu...
38
39
  extern int cpu_add_dev_attr(struct device_attribute *attr);
  extern void cpu_remove_dev_attr(struct device_attribute *attr);
0344c6c53   Christian Krafft   [POWERPC] sysfs: ...
40

8a25a2fd1   Kay Sievers   cpu: convert 'cpu...
41
42
  extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
  extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
0344c6c53   Christian Krafft   [POWERPC] sysfs: ...
43

8db148606   Nicolas Iooss   include, lib: add...
44
45
46
47
  extern __printf(4, 5)
  struct device *cpu_device_create(struct device *parent, void *drvdata,
  				 const struct attribute_group **groups,
  				 const char *fmt, ...);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
  #ifdef CONFIG_HOTPLUG_CPU
76b67ed9d   KAMEZAWA Hiroyuki   [PATCH] node hotp...
49
  extern void unregister_cpu(struct cpu *cpu);
12633e803   Nathan Fontenot   sysfs/cpu: Add pr...
50
51
  extern ssize_t arch_cpu_probe(const char *, size_t);
  extern ssize_t arch_cpu_release(const char *, size_t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52
53
  #endif
  struct notifier_block;
80f1ff97d   Amerigo Wang   notifiers: cpu: m...
54
55
56
57
58
59
  #define CPU_ONLINE		0x0002 /* CPU (unsigned)v is up */
  #define CPU_UP_PREPARE		0x0003 /* CPU (unsigned)v coming up */
  #define CPU_UP_CANCELED		0x0004 /* CPU (unsigned)v NOT coming up */
  #define CPU_DOWN_PREPARE	0x0005 /* CPU (unsigned)v going down */
  #define CPU_DOWN_FAILED		0x0006 /* CPU (unsigned)v NOT going down */
  #define CPU_DEAD		0x0007 /* CPU (unsigned)v dead */
80f1ff97d   Amerigo Wang   notifiers: cpu: m...
60
61
  #define CPU_POST_DEAD		0x0009 /* CPU (unsigned)v dead, cpu_hotplug
  					* lock is dropped */
27d50c7ee   Thomas Gleixner   rcu: Make CPU_DYI...
62
  #define CPU_BROKEN		0x000B /* CPU (unsigned)v did not die properly,
8038dad7e   Paul E. McKenney   smpboot: Add comm...
63
  					* perhaps due to preemption. */
80f1ff97d   Amerigo Wang   notifiers: cpu: m...
64
65
66
67
68
69
70
71
72
73
74
75
  
  /* Used for CPU hotplug events occurring while tasks are frozen due to a suspend
   * operation in progress
   */
  #define CPU_TASKS_FROZEN	0x0010
  
  #define CPU_ONLINE_FROZEN	(CPU_ONLINE | CPU_TASKS_FROZEN)
  #define CPU_UP_PREPARE_FROZEN	(CPU_UP_PREPARE | CPU_TASKS_FROZEN)
  #define CPU_UP_CANCELED_FROZEN	(CPU_UP_CANCELED | CPU_TASKS_FROZEN)
  #define CPU_DOWN_PREPARE_FROZEN	(CPU_DOWN_PREPARE | CPU_TASKS_FROZEN)
  #define CPU_DOWN_FAILED_FROZEN	(CPU_DOWN_FAILED | CPU_TASKS_FROZEN)
  #define CPU_DEAD_FROZEN		(CPU_DEAD | CPU_TASKS_FROZEN)
80f1ff97d   Amerigo Wang   notifiers: cpu: m...
76

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
  #ifdef CONFIG_SMP
090e77c39   Thomas Gleixner   cpu/hotplug: Rest...
78
  extern bool cpuhp_tasks_frozen;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79
  /* Need to know about CPUs going up/down? */
799e64f05   Paul E. McKenney   cpu hotplug: Intr...
80
81
  #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
  #define cpu_notifier(fn, pri) {					\
0db0628d9   Paul Gortmaker   kernel: delete __...
82
  	static struct notifier_block fn##_nb =			\
799e64f05   Paul E. McKenney   cpu hotplug: Intr...
83
84
85
  		{ .notifier_call = fn, .priority = pri };	\
  	register_cpu_notifier(&fn##_nb);			\
  }
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
86
87
88
89
90
91
  
  #define __cpu_notifier(fn, pri) {				\
  	static struct notifier_block fn##_nb =			\
  		{ .notifier_call = fn, .priority = pri };	\
  	__register_cpu_notifier(&fn##_nb);			\
  }
799e64f05   Paul E. McKenney   cpu hotplug: Intr...
92
93
  #else /* #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */
  #define cpu_notifier(fn, pri)	do { (void)(fn); } while (0)
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
94
  #define __cpu_notifier(fn, pri)	do { (void)(fn); } while (0)
799e64f05   Paul E. McKenney   cpu hotplug: Intr...
95
  #endif /* #else #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
96

65edc68c3   Chandra Seetharaman   [PATCH] cpu hotpl...
97
  #ifdef CONFIG_HOTPLUG_CPU
47e627bc8   Avi Kivity   [PATCH] hotplug: ...
98
  extern int register_cpu_notifier(struct notifier_block *nb);
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
99
  extern int __register_cpu_notifier(struct notifier_block *nb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
  extern void unregister_cpu_notifier(struct notifier_block *nb);
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
101
  extern void __unregister_cpu_notifier(struct notifier_block *nb);
65edc68c3   Chandra Seetharaman   [PATCH] cpu hotpl...
102
  #else
47e627bc8   Avi Kivity   [PATCH] hotplug: ...
103
104
105
  
  #ifndef MODULE
  extern int register_cpu_notifier(struct notifier_block *nb);
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
106
  extern int __register_cpu_notifier(struct notifier_block *nb);
47e627bc8   Avi Kivity   [PATCH] hotplug: ...
107
108
109
110
111
  #else
  static inline int register_cpu_notifier(struct notifier_block *nb)
  {
  	return 0;
  }
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
112
113
114
115
116
  
  static inline int __register_cpu_notifier(struct notifier_block *nb)
  {
  	return 0;
  }
47e627bc8   Avi Kivity   [PATCH] hotplug: ...
117
  #endif
65edc68c3   Chandra Seetharaman   [PATCH] cpu hotpl...
118
119
120
  static inline void unregister_cpu_notifier(struct notifier_block *nb)
  {
  }
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
121
122
123
124
  
  static inline void __unregister_cpu_notifier(struct notifier_block *nb)
  {
  }
65edc68c3   Chandra Seetharaman   [PATCH] cpu hotpl...
125
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
126
127
  
  int cpu_up(unsigned int cpu);
e545a6140   Manfred Spraul   kernel/cpu.c: cre...
128
  void notify_cpu_starting(unsigned int cpu);
3da1c84c0   Oleg Nesterov   workqueues: make ...
129
130
  extern void cpu_maps_update_begin(void);
  extern void cpu_maps_update_done(void);
d0d23b543   Ingo Molnar   cpu-hotplug: fix ...
131

93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
132
133
  #define cpu_notifier_register_begin	cpu_maps_update_begin
  #define cpu_notifier_register_done	cpu_maps_update_done
3da1c84c0   Oleg Nesterov   workqueues: make ...
134
  #else	/* CONFIG_SMP */
090e77c39   Thomas Gleixner   cpu/hotplug: Rest...
135
  #define cpuhp_tasks_frozen	0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136

799e64f05   Paul E. McKenney   cpu hotplug: Intr...
137
  #define cpu_notifier(fn, pri)	do { (void)(fn); } while (0)
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
138
  #define __cpu_notifier(fn, pri)	do { (void)(fn); } while (0)
799e64f05   Paul E. McKenney   cpu hotplug: Intr...
139

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
141
142
143
  static inline int register_cpu_notifier(struct notifier_block *nb)
  {
  	return 0;
  }
d0d23b543   Ingo Molnar   cpu-hotplug: fix ...
144

93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
145
146
147
148
  static inline int __register_cpu_notifier(struct notifier_block *nb)
  {
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
150
151
  static inline void unregister_cpu_notifier(struct notifier_block *nb)
  {
  }
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
152
153
154
  static inline void __unregister_cpu_notifier(struct notifier_block *nb)
  {
  }
3da1c84c0   Oleg Nesterov   workqueues: make ...
155
156
157
158
159
160
161
  static inline void cpu_maps_update_begin(void)
  {
  }
  
  static inline void cpu_maps_update_done(void)
  {
  }
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
162
163
164
165
166
167
168
  static inline void cpu_notifier_register_begin(void)
  {
  }
  
  static inline void cpu_notifier_register_done(void)
  {
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
169
  #endif /* CONFIG_SMP */
8a25a2fd1   Kay Sievers   cpu: convert 'cpu...
170
  extern struct bus_type cpu_subsys;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
171
172
173
  
  #ifdef CONFIG_HOTPLUG_CPU
  /* Stop CPUs going up and down. */
f7dff2b12   Gautham R Shenoy   [PATCH] Handle pe...
174

b9d10be7a   Toshi Kani   ACPI / processor:...
175
176
  extern void cpu_hotplug_begin(void);
  extern void cpu_hotplug_done(void);
86ef5c9a8   Gautham R Shenoy   cpu-hotplug: repl...
177
178
  extern void get_online_cpus(void);
  extern void put_online_cpus(void);
16e53dbf1   Srivatsa S. Bhat   CPU hotplug: prov...
179
180
  extern void cpu_hotplug_disable(void);
  extern void cpu_hotplug_enable(void);
799e64f05   Paul E. McKenney   cpu hotplug: Intr...
181
  #define hotcpu_notifier(fn, pri)	cpu_notifier(fn, pri)
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
182
  #define __hotcpu_notifier(fn, pri)	__cpu_notifier(fn, pri)
39f4885c5   Chandra Seetharaman   [PATCH] cpu hotpl...
183
  #define register_hotcpu_notifier(nb)	register_cpu_notifier(nb)
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
184
  #define __register_hotcpu_notifier(nb)	__register_cpu_notifier(nb)
39f4885c5   Chandra Seetharaman   [PATCH] cpu hotpl...
185
  #define unregister_hotcpu_notifier(nb)	unregister_cpu_notifier(nb)
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
186
  #define __unregister_hotcpu_notifier(nb)	__unregister_cpu_notifier(nb)
cb79295e2   Anton Vorontsov   cpu: introduce cl...
187
  void clear_tasks_mm_cpumask(int cpu);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
188
  int cpu_down(unsigned int cpu);
f7dff2b12   Gautham R Shenoy   [PATCH] Handle pe...
189
190
  
  #else		/* CONFIG_HOTPLUG_CPU */
b9d10be7a   Toshi Kani   ACPI / processor:...
191
192
  static inline void cpu_hotplug_begin(void) {}
  static inline void cpu_hotplug_done(void) {}
86ef5c9a8   Gautham R Shenoy   cpu-hotplug: repl...
193
194
  #define get_online_cpus()	do { } while (0)
  #define put_online_cpus()	do { } while (0)
16e53dbf1   Srivatsa S. Bhat   CPU hotplug: prov...
195
196
  #define cpu_hotplug_disable()	do { } while (0)
  #define cpu_hotplug_enable()	do { } while (0)
023160678   Ingo Molnar   [PATCH] hotplug C...
197
  #define hotcpu_notifier(fn, pri)	do { (void)(fn); } while (0)
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
198
  #define __hotcpu_notifier(fn, pri)	do { (void)(fn); } while (0)
761bb4319   Satyam Sharma   Redefine {un}regi...
199
200
  /* These aren't inline functions due to a GCC bug. */
  #define register_hotcpu_notifier(nb)	({ (void)(nb); 0; })
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
201
  #define __register_hotcpu_notifier(nb)	({ (void)(nb); 0; })
761bb4319   Satyam Sharma   Redefine {un}regi...
202
  #define unregister_hotcpu_notifier(nb)	({ (void)(nb); })
93ae4f978   Srivatsa S. Bhat   CPU hotplug: Prov...
203
  #define __unregister_hotcpu_notifier(nb)	({ (void)(nb); })
f7dff2b12   Gautham R Shenoy   [PATCH] Handle pe...
204
  #endif		/* CONFIG_HOTPLUG_CPU */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
205

f3de4be9d   Rafael J. Wysocki   PM: Fix dependenc...
206
  #ifdef CONFIG_PM_SLEEP_SMP
d391e5522   James Morse   cpu/hotplug: Allo...
207
208
209
210
211
  extern int freeze_secondary_cpus(int primary);
  static inline int disable_nonboot_cpus(void)
  {
  	return freeze_secondary_cpus(0);
  }
e3920fb42   Rafael J. Wysocki   [PATCH] Disable C...
212
  extern void enable_nonboot_cpus(void);
f3de4be9d   Rafael J. Wysocki   PM: Fix dependenc...
213
  #else /* !CONFIG_PM_SLEEP_SMP */
e3920fb42   Rafael J. Wysocki   [PATCH] Disable C...
214
215
  static inline int disable_nonboot_cpus(void) { return 0; }
  static inline void enable_nonboot_cpus(void) {}
f3de4be9d   Rafael J. Wysocki   PM: Fix dependenc...
216
  #endif /* !CONFIG_PM_SLEEP_SMP */
e3920fb42   Rafael J. Wysocki   [PATCH] Disable C...
217

a1a04ec3c   Thomas Gleixner   idle: Provide a g...
218
  void cpu_startup_entry(enum cpuhp_state state);
a1a04ec3c   Thomas Gleixner   idle: Provide a g...
219

d16699123   Thomas Gleixner   idle: Implement g...
220
  void cpu_idle_poll_ctrl(bool enable);
6727ad9e2   Chris Metcalf   nmi_backtrace: ge...
221
222
223
224
  /* Attach to any functions which should be considered cpuidle. */
  #define __cpuidle	__attribute__((__section__(".cpuidle.text")))
  
  bool cpu_in_idle(unsigned long pc);
d16699123   Thomas Gleixner   idle: Implement g...
225
226
227
228
229
  void arch_cpu_idle(void);
  void arch_cpu_idle_prepare(void);
  void arch_cpu_idle_enter(void);
  void arch_cpu_idle_exit(void);
  void arch_cpu_idle_dead(void);
8038dad7e   Paul E. McKenney   smpboot: Add comm...
230
231
232
233
234
235
  int cpu_report_state(int cpu);
  int cpu_check_up_prepare(int cpu);
  void cpu_set_state_online(int cpu);
  #ifdef CONFIG_HOTPLUG_CPU
  bool cpu_wait_death(unsigned int cpu, int seconds);
  bool cpu_report_death(void);
e69aab131   Thomas Gleixner   cpu/hotplug: Make...
236
237
238
  void cpuhp_report_idle_dead(void);
  #else
  static inline void cpuhp_report_idle_dead(void) { }
8038dad7e   Paul E. McKenney   smpboot: Add comm...
239
  #endif /* #ifdef CONFIG_HOTPLUG_CPU */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240
  #endif /* _LINUX_CPU_H_ */