aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/cpu-hotplug.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/cpu-hotplug.txt')
-rw-r--r--Documentation/cpu-hotplug.txt45
1 files changed, 45 insertions, 0 deletions
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt
index be675d2d15a7..a0b005d2bd95 100644
--- a/Documentation/cpu-hotplug.txt
+++ b/Documentation/cpu-hotplug.txt
@@ -312,12 +312,57 @@ things will happen if a notifier in path sent a BAD notify code.
312Q: I don't see my action being called for all CPUs already up and running? 312Q: I don't see my action being called for all CPUs already up and running?
313A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined. 313A: Yes, CPU notifiers are called only when new CPUs are on-lined or offlined.
314 If you need to perform some action for each cpu already in the system, then 314 If you need to perform some action for each cpu already in the system, then
315 do this:
315 316
316 for_each_online_cpu(i) { 317 for_each_online_cpu(i) {
317 foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i); 318 foobar_cpu_callback(&foobar_cpu_notifier, CPU_UP_PREPARE, i);
318 foobar_cpu_callback(&foobar_cpu_notifier, CPU_ONLINE, i); 319 foobar_cpu_callback(&foobar_cpu_notifier, CPU_ONLINE, i);
319 } 320 }
320 321
322 However, if you want to register a hotplug callback, as well as perform
323 some initialization for CPUs that are already online, then do this:
324
325 Version 1: (Correct)
326 ---------
327
328 cpu_notifier_register_begin();
329
330 for_each_online_cpu(i) {
331 foobar_cpu_callback(&foobar_cpu_notifier,
332 CPU_UP_PREPARE, i);
333 foobar_cpu_callback(&foobar_cpu_notifier,
334 CPU_ONLINE, i);
335 }
336
337 /* Note the use of the double underscored version of the API */
338 __register_cpu_notifier(&foobar_cpu_notifier);
339
340 cpu_notifier_register_done();
341
342 Note that the following code is *NOT* the right way to achieve this,
343 because it is prone to an ABBA deadlock between the cpu_add_remove_lock
344 and the cpu_hotplug.lock.
345
346 Version 2: (Wrong!)
347 ---------
348
349 get_online_cpus();
350
351 for_each_online_cpu(i) {
352 foobar_cpu_callback(&foobar_cpu_notifier,
353 CPU_UP_PREPARE, i);
354 foobar_cpu_callback(&foobar_cpu_notifier,
355 CPU_ONLINE, i);
356 }
357
358 register_cpu_notifier(&foobar_cpu_notifier);
359
360 put_online_cpus();
361
362 So always use the first version shown above when you want to register
363 callbacks as well as initialize the already online CPUs.
364
365
321Q: If i would like to develop cpu hotplug support for a new architecture, 366Q: If i would like to develop cpu hotplug support for a new architecture,
322 what do i need at a minimum? 367 what do i need at a minimum?
323A: The following are what is required for CPU hotplug infrastructure to work 368A: The following are what is required for CPU hotplug infrastructure to work