diff options
author | Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> | 2006-10-20 02:29:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-20 13:26:43 -0400 |
commit | ca926e80dcfd18adaf7c4304935da4cc8ded8364 (patch) | |
tree | 40098ae4f244966c614a39e64e804d9e667d717d | |
parent | fca4edb48b693d9df7de4c42d91b4158d8b7e347 (diff) |
[PATCH] doc: fixing cpu-hotplug documentation
Fixing cpu-hotplug documentation as follows:
- moving confusing asterisk on additional_cpus descrition
- fixing some typos
- unifying indentation for source code and command line example
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | Documentation/cpu-hotplug.txt | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt index bc107cb157a8..4868c34f7509 100644 --- a/Documentation/cpu-hotplug.txt +++ b/Documentation/cpu-hotplug.txt | |||
@@ -46,7 +46,7 @@ maxcpus=n Restrict boot time cpus to n. Say if you have 4 cpus, using | |||
46 | maxcpus=2 will only boot 2. You can choose to bring the | 46 | maxcpus=2 will only boot 2. You can choose to bring the |
47 | other cpus later online, read FAQ's for more info. | 47 | other cpus later online, read FAQ's for more info. |
48 | 48 | ||
49 | additional_cpus*=n Use this to limit hotpluggable cpus. This option sets | 49 | additional_cpus=n (*) Use this to limit hotpluggable cpus. This option sets |
50 | cpu_possible_map = cpu_present_map + additional_cpus | 50 | cpu_possible_map = cpu_present_map + additional_cpus |
51 | 51 | ||
52 | (*) Option valid only for following architectures | 52 | (*) Option valid only for following architectures |
@@ -101,15 +101,15 @@ cpu_possible_map/for_each_possible_cpu() to iterate. | |||
101 | 101 | ||
102 | Never use anything other than cpumask_t to represent bitmap of CPUs. | 102 | Never use anything other than cpumask_t to represent bitmap of CPUs. |
103 | 103 | ||
104 | #include <linux/cpumask.h> | 104 | #include <linux/cpumask.h> |
105 | 105 | ||
106 | for_each_possible_cpu - Iterate over cpu_possible_map | 106 | for_each_possible_cpu - Iterate over cpu_possible_map |
107 | for_each_online_cpu - Iterate over cpu_online_map | 107 | for_each_online_cpu - Iterate over cpu_online_map |
108 | for_each_present_cpu - Iterate over cpu_present_map | 108 | for_each_present_cpu - Iterate over cpu_present_map |
109 | for_each_cpu_mask(x,mask) - Iterate over some random collection of cpu mask. | 109 | for_each_cpu_mask(x,mask) - Iterate over some random collection of cpu mask. |
110 | 110 | ||
111 | #include <linux/cpu.h> | 111 | #include <linux/cpu.h> |
112 | lock_cpu_hotplug() and unlock_cpu_hotplug(): | 112 | lock_cpu_hotplug() and unlock_cpu_hotplug(): |
113 | 113 | ||
114 | The above calls are used to inhibit cpu hotplug operations. While holding the | 114 | The above calls are used to inhibit cpu hotplug operations. While holding the |
115 | cpucontrol mutex, cpu_online_map will not change. If you merely need to avoid | 115 | cpucontrol mutex, cpu_online_map will not change. If you merely need to avoid |
@@ -120,7 +120,7 @@ will work as long as stop_machine_run() is used to take a cpu down. | |||
120 | 120 | ||
121 | CPU Hotplug - Frequently Asked Questions. | 121 | CPU Hotplug - Frequently Asked Questions. |
122 | 122 | ||
123 | Q: How to i enable my kernel to support CPU hotplug? | 123 | Q: How to enable my kernel to support CPU hotplug? |
124 | A: When doing make defconfig, Enable CPU hotplug support | 124 | A: When doing make defconfig, Enable CPU hotplug support |
125 | 125 | ||
126 | "Processor type and Features" -> Support for Hotpluggable CPUs | 126 | "Processor type and Features" -> Support for Hotpluggable CPUs |
@@ -141,39 +141,39 @@ A: You should now notice an entry in sysfs. | |||
141 | Check if sysfs is mounted, using the "mount" command. You should notice | 141 | Check if sysfs is mounted, using the "mount" command. You should notice |
142 | an entry as shown below in the output. | 142 | an entry as shown below in the output. |
143 | 143 | ||
144 | .... | 144 | .... |
145 | none on /sys type sysfs (rw) | 145 | none on /sys type sysfs (rw) |
146 | .... | 146 | .... |
147 | 147 | ||
148 | if this is not mounted, do the following. | 148 | If this is not mounted, do the following. |
149 | 149 | ||
150 | #mkdir /sysfs | 150 | #mkdir /sysfs |
151 | #mount -t sysfs sys /sys | 151 | #mount -t sysfs sys /sys |
152 | 152 | ||
153 | now you should see entries for all present cpu, the following is an example | 153 | Now you should see entries for all present cpu, the following is an example |
154 | in a 8-way system. | 154 | in a 8-way system. |
155 | 155 | ||
156 | #pwd | 156 | #pwd |
157 | #/sys/devices/system/cpu | 157 | #/sys/devices/system/cpu |
158 | #ls -l | 158 | #ls -l |
159 | total 0 | 159 | total 0 |
160 | drwxr-xr-x 10 root root 0 Sep 19 07:44 . | 160 | drwxr-xr-x 10 root root 0 Sep 19 07:44 . |
161 | drwxr-xr-x 13 root root 0 Sep 19 07:45 .. | 161 | drwxr-xr-x 13 root root 0 Sep 19 07:45 .. |
162 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu0 | 162 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu0 |
163 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu1 | 163 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu1 |
164 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu2 | 164 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu2 |
165 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu3 | 165 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu3 |
166 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu4 | 166 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu4 |
167 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu5 | 167 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu5 |
168 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu6 | 168 | drwxr-xr-x 3 root root 0 Sep 19 07:44 cpu6 |
169 | drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7 | 169 | drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7 |
170 | 170 | ||
171 | Under each directory you would find an "online" file which is the control | 171 | Under each directory you would find an "online" file which is the control |
172 | file to logically online/offline a processor. | 172 | file to logically online/offline a processor. |
173 | 173 | ||
174 | Q: Does hot-add/hot-remove refer to physical add/remove of cpus? | 174 | Q: Does hot-add/hot-remove refer to physical add/remove of cpus? |
175 | A: The usage of hot-add/remove may not be very consistently used in the code. | 175 | A: The usage of hot-add/remove may not be very consistently used in the code. |
176 | CONFIG_CPU_HOTPLUG enables logical online/offline capability in the kernel. | 176 | CONFIG_HOTPLUG_CPU enables logical online/offline capability in the kernel. |
177 | To support physical addition/removal, one would need some BIOS hooks and | 177 | To support physical addition/removal, one would need some BIOS hooks and |
178 | the platform should have something like an attention button in PCI hotplug. | 178 | the platform should have something like an attention button in PCI hotplug. |
179 | CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs. | 179 | CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs. |
@@ -181,17 +181,17 @@ CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs. | |||
181 | Q: How do i logically offline a CPU? | 181 | Q: How do i logically offline a CPU? |
182 | A: Do the following. | 182 | A: Do the following. |
183 | 183 | ||
184 | #echo 0 > /sys/devices/system/cpu/cpuX/online | 184 | #echo 0 > /sys/devices/system/cpu/cpuX/online |
185 | 185 | ||
186 | once the logical offline is successful, check | 186 | Once the logical offline is successful, check |
187 | 187 | ||
188 | #cat /proc/interrupts | 188 | #cat /proc/interrupts |
189 | 189 | ||
190 | you should now not see the CPU that you removed. Also online file will report | 190 | You should now not see the CPU that you removed. Also online file will report |
191 | the state as 0 when a cpu if offline and 1 when its online. | 191 | the state as 0 when a cpu if offline and 1 when its online. |
192 | 192 | ||
193 | #To display the current cpu state. | 193 | #To display the current cpu state. |
194 | #cat /sys/devices/system/cpu/cpuX/online | 194 | #cat /sys/devices/system/cpu/cpuX/online |
195 | 195 | ||
196 | Q: Why cant i remove CPU0 on some systems? | 196 | Q: Why cant i remove CPU0 on some systems? |
197 | A: Some architectures may have some special dependency on a certain CPU. | 197 | A: Some architectures may have some special dependency on a certain CPU. |
@@ -234,8 +234,8 @@ Q: If i have some kernel code that needs to be aware of CPU arrival and | |||
234 | departure, how to i arrange for proper notification? | 234 | departure, how to i arrange for proper notification? |
235 | A: This is what you would need in your kernel code to receive notifications. | 235 | A: This is what you would need in your kernel code to receive notifications. |
236 | 236 | ||
237 | #include <linux/cpu.h> | 237 | #include <linux/cpu.h> |
238 | static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb, | 238 | static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb, |
239 | unsigned long action, void *hcpu) | 239 | unsigned long action, void *hcpu) |
240 | { | 240 | { |
241 | unsigned int cpu = (unsigned long)hcpu; | 241 | unsigned int cpu = (unsigned long)hcpu; |
@@ -279,10 +279,10 @@ Q: I don't see my action being called for all CPUs already up and running? | |||
279 | A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined. | 279 | A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined. |
280 | If you need to perform some action for each cpu already in the system, then | 280 | If you need to perform some action for each cpu already in the system, then |
281 | 281 | ||
282 | for_each_online_cpu(i) { | 282 | for_each_online_cpu(i) { |
283 | foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i); | 283 | foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i); |
284 | foobar_cpu_callback(&foobar-cpu_notifier, CPU_ONLINE, i); | 284 | foobar_cpu_callback(&foobar_cpu_notifier, CPU_ONLINE, i); |
285 | } | 285 | } |
286 | 286 | ||
287 | Q: If i would like to develop cpu hotplug support for a new architecture, | 287 | Q: If i would like to develop cpu hotplug support for a new architecture, |
288 | what do i need at a minimum? | 288 | what do i need at a minimum? |
@@ -307,38 +307,38 @@ Q: I need to ensure that a particular cpu is not removed when there is some | |||
307 | work specific to this cpu is in progress. | 307 | work specific to this cpu is in progress. |
308 | A: First switch the current thread context to preferred cpu | 308 | A: First switch the current thread context to preferred cpu |
309 | 309 | ||
310 | int my_func_on_cpu(int cpu) | 310 | int my_func_on_cpu(int cpu) |
311 | { | 311 | { |
312 | cpumask_t saved_mask, new_mask = CPU_MASK_NONE; | 312 | cpumask_t saved_mask, new_mask = CPU_MASK_NONE; |
313 | int curr_cpu, err = 0; | 313 | int curr_cpu, err = 0; |
314 | 314 | ||
315 | saved_mask = current->cpus_allowed; | 315 | saved_mask = current->cpus_allowed; |
316 | cpu_set(cpu, new_mask); | 316 | cpu_set(cpu, new_mask); |
317 | err = set_cpus_allowed(current, new_mask); | 317 | err = set_cpus_allowed(current, new_mask); |
318 | 318 | ||
319 | if (err) | 319 | if (err) |
320 | return err; | 320 | return err; |
321 | 321 | ||
322 | /* | 322 | /* |
323 | * If we got scheduled out just after the return from | 323 | * If we got scheduled out just after the return from |
324 | * set_cpus_allowed() before running the work, this ensures | 324 | * set_cpus_allowed() before running the work, this ensures |
325 | * we stay locked. | 325 | * we stay locked. |
326 | */ | 326 | */ |
327 | curr_cpu = get_cpu(); | 327 | curr_cpu = get_cpu(); |
328 | 328 | ||
329 | if (curr_cpu != cpu) { | 329 | if (curr_cpu != cpu) { |
330 | err = -EAGAIN; | 330 | err = -EAGAIN; |
331 | goto ret; | 331 | goto ret; |
332 | } else { | 332 | } else { |
333 | /* | 333 | /* |
334 | * Do work : But cant sleep, since get_cpu() disables preempt | 334 | * Do work : But cant sleep, since get_cpu() disables preempt |
335 | */ | 335 | */ |
336 | } | 336 | } |
337 | ret: | 337 | ret: |
338 | put_cpu(); | 338 | put_cpu(); |
339 | set_cpus_allowed(current, saved_mask); | 339 | set_cpus_allowed(current, saved_mask); |
340 | return err; | 340 | return err; |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | Q: How do we determine how many CPUs are available for hotplug. | 344 | Q: How do we determine how many CPUs are available for hotplug. |