Commit ca926e80dcfd18adaf7c4304935da4cc8ded8364

Authored by Satoru Takeuchi
Committed by Linus Torvalds
1 parent fca4edb48b

[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>

Showing 1 changed file with 74 additions and 74 deletions Side-by-side Diff

Documentation/cpu-hotplug.txt
... ... @@ -46,7 +46,7 @@
46 46 maxcpus=2 will only boot 2. You can choose to bring the
47 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 50 cpu_possible_map = cpu_present_map + additional_cpus
51 51  
52 52 (*) Option valid only for following architectures
53 53  
54 54  
... ... @@ -101,15 +101,15 @@
101 101  
102 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
107   -for_each_online_cpu - Iterate over cpu_online_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.
  106 + for_each_possible_cpu - Iterate over cpu_possible_map
  107 + for_each_online_cpu - Iterate over cpu_online_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.
110 110  
111   -#include <linux/cpu.h>
112   -lock_cpu_hotplug() and unlock_cpu_hotplug():
  111 + #include <linux/cpu.h>
  112 + lock_cpu_hotplug() and unlock_cpu_hotplug():
113 113  
114 114 The above calls are used to inhibit cpu hotplug operations. While holding the
115 115 cpucontrol mutex, cpu_online_map will not change. If you merely need to avoid
... ... @@ -120,7 +120,7 @@
120 120  
121 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 124 A: When doing make defconfig, Enable CPU hotplug support
125 125  
126 126 "Processor type and Features" -> Support for Hotpluggable CPUs
127 127  
128 128  
129 129  
130 130  
131 131  
... ... @@ -141,39 +141,39 @@
141 141 Check if sysfs is mounted, using the "mount" command. You should notice
142 142 an entry as shown below in the output.
143 143  
144   -....
145   -none on /sys type sysfs (rw)
146   -....
  144 + ....
  145 + none on /sys type sysfs (rw)
  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
151   -#mount -t sysfs sys /sys
  150 + #mkdir /sysfs
  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 154 in a 8-way system.
155 155  
156   -#pwd
157   -#/sys/devices/system/cpu
158   -#ls -l
159   -total 0
160   -drwxr-xr-x 10 root root 0 Sep 19 07:44 .
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
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
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
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
169   -drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7
  156 + #pwd
  157 + #/sys/devices/system/cpu
  158 + #ls -l
  159 + total 0
  160 + drwxr-xr-x 10 root root 0 Sep 19 07:44 .
  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
  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
  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
  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
  169 + drwxr-xr-x 3 root root 0 Sep 19 07:48 cpu7
170 170  
171 171 Under each directory you would find an "online" file which is the control
172 172 file to logically online/offline a processor.
173 173  
174 174 Q: Does hot-add/hot-remove refer to physical add/remove of cpus?
175 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 177 To support physical addition/removal, one would need some BIOS hooks and
178 178 the platform should have something like an attention button in PCI hotplug.
179 179 CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of CPUs.
180 180  
181 181  
182 182  
183 183  
... ... @@ -181,17 +181,17 @@
181 181 Q: How do i logically offline a CPU?
182 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 191 the state as 0 when a cpu if offline and 1 when its online.
192 192  
193   -#To display the current cpu state.
194   -#cat /sys/devices/system/cpu/cpuX/online
  193 + #To display the current cpu state.
  194 + #cat /sys/devices/system/cpu/cpuX/online
195 195  
196 196 Q: Why cant i remove CPU0 on some systems?
197 197 A: Some architectures may have some special dependency on a certain CPU.
... ... @@ -234,8 +234,8 @@
234 234 departure, how to i arrange for proper notification?
235 235 A: This is what you would need in your kernel code to receive notifications.
236 236  
237   - #include <linux/cpu.h>
238   - static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb,
  237 + #include <linux/cpu.h>
  238 + static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb,
239 239 unsigned long action, void *hcpu)
240 240 {
241 241 unsigned int cpu = (unsigned long)hcpu;
242 242  
... ... @@ -279,10 +279,10 @@
279 279 A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined.
280 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 283 foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i);
284   - foobar_cpu_callback(&foobar-cpu_notifier, CPU_ONLINE, i);
285   - }
  284 + foobar_cpu_callback(&foobar_cpu_notifier, CPU_ONLINE, i);
  285 + }
286 286  
287 287 Q: If i would like to develop cpu hotplug support for a new architecture,
288 288 what do i need at a minimum?
289 289  
290 290  
291 291  
292 292  
... ... @@ -307,38 +307,38 @@
307 307 work specific to this cpu is in progress.
308 308 A: First switch the current thread context to preferred cpu
309 309  
310   - int my_func_on_cpu(int cpu)
311   - {
312   - cpumask_t saved_mask, new_mask = CPU_MASK_NONE;
313   - int curr_cpu, err = 0;
  310 + int my_func_on_cpu(int cpu)
  311 + {
  312 + cpumask_t saved_mask, new_mask = CPU_MASK_NONE;
  313 + int curr_cpu, err = 0;
314 314  
315   - saved_mask = current->cpus_allowed;
316   - cpu_set(cpu, new_mask);
317   - err = set_cpus_allowed(current, new_mask);
  315 + saved_mask = current->cpus_allowed;
  316 + cpu_set(cpu, new_mask);
  317 + err = set_cpus_allowed(current, new_mask);
318 318  
319   - if (err)
320   - return err;
  319 + if (err)
  320 + return err;
321 321  
322   - /*
323   - * If we got scheduled out just after the return from
324   - * set_cpus_allowed() before running the work, this ensures
325   - * we stay locked.
326   - */
327   - curr_cpu = get_cpu();
  322 + /*
  323 + * If we got scheduled out just after the return from
  324 + * set_cpus_allowed() before running the work, this ensures
  325 + * we stay locked.
  326 + */
  327 + curr_cpu = get_cpu();
328 328  
329   - if (curr_cpu != cpu) {
330   - err = -EAGAIN;
331   - goto ret;
332   - } else {
333   - /*
334   - * Do work : But cant sleep, since get_cpu() disables preempt
335   - */
336   - }
337   - ret:
338   - put_cpu();
339   - set_cpus_allowed(current, saved_mask);
340   - return err;
341   - }
  329 + if (curr_cpu != cpu) {
  330 + err = -EAGAIN;
  331 + goto ret;
  332 + } else {
  333 + /*
  334 + * Do work : But cant sleep, since get_cpu() disables preempt
  335 + */
  336 + }
  337 + ret:
  338 + put_cpu();
  339 + set_cpus_allowed(current, saved_mask);
  340 + return err;
  341 + }
342 342  
343 343  
344 344 Q: How do we determine how many CPUs are available for hotplug.