diff options
-rw-r--r-- | include/linux/cpumask.h | 75 | ||||
-rw-r--r-- | kernel/cpu.c | 49 |
2 files changed, 52 insertions, 72 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index b5ad19a6f43f..db2341beca45 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -416,65 +416,54 @@ int __next_cpu_nr(int n, const cpumask_t *srcp); | |||
416 | 416 | ||
417 | /* | 417 | /* |
418 | * The following particular system cpumasks and operations manage | 418 | * The following particular system cpumasks and operations manage |
419 | * possible, present, active and online cpus. Each of them is a fixed size | 419 | * possible, present, active and online cpus. |
420 | * bitmap of size NR_CPUS. | ||
421 | * | 420 | * |
422 | * #ifdef CONFIG_HOTPLUG_CPU | 421 | * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable |
423 | * cpu_possible_map - has bit 'cpu' set iff cpu is populatable | 422 | * cpu_present_mask - has bit 'cpu' set iff cpu is populated |
424 | * cpu_present_map - has bit 'cpu' set iff cpu is populated | 423 | * cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler |
425 | * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler | 424 | * cpu_active_mask - has bit 'cpu' set iff cpu available to migration |
426 | * cpu_active_map - has bit 'cpu' set iff cpu available to migration | ||
427 | * #else | ||
428 | * cpu_possible_map - has bit 'cpu' set iff cpu is populated | ||
429 | * cpu_present_map - copy of cpu_possible_map | ||
430 | * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler | ||
431 | * #endif | ||
432 | * | 425 | * |
433 | * In either case, NR_CPUS is fixed at compile time, as the static | 426 | * If !CONFIG_HOTPLUG_CPU, present == possible, and active == online. |
434 | * size of these bitmaps. The cpu_possible_map is fixed at boot | ||
435 | * time, as the set of CPU id's that it is possible might ever | ||
436 | * be plugged in at anytime during the life of that system boot. | ||
437 | * The cpu_present_map is dynamic(*), representing which CPUs | ||
438 | * are currently plugged in. And cpu_online_map is the dynamic | ||
439 | * subset of cpu_present_map, indicating those CPUs available | ||
440 | * for scheduling. | ||
441 | * | 427 | * |
442 | * If HOTPLUG is enabled, then cpu_possible_map is forced to have | 428 | * The cpu_possible_mask is fixed at boot time, as the set of CPU id's |
429 | * that it is possible might ever be plugged in at anytime during the | ||
430 | * life of that system boot. The cpu_present_mask is dynamic(*), | ||
431 | * representing which CPUs are currently plugged in. And | ||
432 | * cpu_online_mask is the dynamic subset of cpu_present_mask, | ||
433 | * indicating those CPUs available for scheduling. | ||
434 | * | ||
435 | * If HOTPLUG is enabled, then cpu_possible_mask is forced to have | ||
443 | * all NR_CPUS bits set, otherwise it is just the set of CPUs that | 436 | * all NR_CPUS bits set, otherwise it is just the set of CPUs that |
444 | * ACPI reports present at boot. | 437 | * ACPI reports present at boot. |
445 | * | 438 | * |
446 | * If HOTPLUG is enabled, then cpu_present_map varies dynamically, | 439 | * If HOTPLUG is enabled, then cpu_present_mask varies dynamically, |
447 | * depending on what ACPI reports as currently plugged in, otherwise | 440 | * depending on what ACPI reports as currently plugged in, otherwise |
448 | * cpu_present_map is just a copy of cpu_possible_map. | 441 | * cpu_present_mask is just a copy of cpu_possible_mask. |
449 | * | 442 | * |
450 | * (*) Well, cpu_present_map is dynamic in the hotplug case. If not | 443 | * (*) Well, cpu_present_mask is dynamic in the hotplug case. If not |
451 | * hotplug, it's a copy of cpu_possible_map, hence fixed at boot. | 444 | * hotplug, it's a copy of cpu_possible_mask, hence fixed at boot. |
452 | * | 445 | * |
453 | * Subtleties: | 446 | * Subtleties: |
454 | * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode | 447 | * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode |
455 | * assumption that their single CPU is online. The UP | 448 | * assumption that their single CPU is online. The UP |
456 | * cpu_{online,possible,present}_maps are placebos. Changing them | 449 | * cpu_{online,possible,present}_masks are placebos. Changing them |
457 | * will have no useful affect on the following num_*_cpus() | 450 | * will have no useful affect on the following num_*_cpus() |
458 | * and cpu_*() macros in the UP case. This ugliness is a UP | 451 | * and cpu_*() macros in the UP case. This ugliness is a UP |
459 | * optimization - don't waste any instructions or memory references | 452 | * optimization - don't waste any instructions or memory references |
460 | * asking if you're online or how many CPUs there are if there is | 453 | * asking if you're online or how many CPUs there are if there is |
461 | * only one CPU. | 454 | * only one CPU. |
462 | * 2) Most SMP arch's #define some of these maps to be some | ||
463 | * other map specific to that arch. Therefore, the following | ||
464 | * must be #define macros, not inlines. To see why, examine | ||
465 | * the assembly code produced by the following. Note that | ||
466 | * set1() writes phys_x_map, but set2() writes x_map: | ||
467 | * int x_map, phys_x_map; | ||
468 | * #define set1(a) x_map = a | ||
469 | * inline void set2(int a) { x_map = a; } | ||
470 | * #define x_map phys_x_map | ||
471 | * main(){ set1(3); set2(5); } | ||
472 | */ | 455 | */ |
473 | 456 | ||
474 | extern cpumask_t cpu_possible_map; | 457 | extern const struct cpumask *const cpu_possible_mask; |
475 | extern cpumask_t cpu_online_map; | 458 | extern const struct cpumask *const cpu_online_mask; |
476 | extern cpumask_t cpu_present_map; | 459 | extern const struct cpumask *const cpu_present_mask; |
477 | extern cpumask_t cpu_active_map; | 460 | extern const struct cpumask *const cpu_active_mask; |
461 | |||
462 | /* These strip const, as traditionally they weren't const. */ | ||
463 | #define cpu_possible_map (*(cpumask_t *)cpu_possible_mask) | ||
464 | #define cpu_online_map (*(cpumask_t *)cpu_online_mask) | ||
465 | #define cpu_present_map (*(cpumask_t *)cpu_present_mask) | ||
466 | #define cpu_active_map (*(cpumask_t *)cpu_active_mask) | ||
478 | 467 | ||
479 | #if NR_CPUS > 1 | 468 | #if NR_CPUS > 1 |
480 | #define num_online_cpus() cpus_weight_nr(cpu_online_map) | 469 | #define num_online_cpus() cpus_weight_nr(cpu_online_map) |
@@ -1058,12 +1047,6 @@ static inline void free_bootmem_cpumask_var(cpumask_var_t mask) | |||
1058 | } | 1047 | } |
1059 | #endif /* CONFIG_CPUMASK_OFFSTACK */ | 1048 | #endif /* CONFIG_CPUMASK_OFFSTACK */ |
1060 | 1049 | ||
1061 | /* The pointer versions of the maps, these will become the primary versions. */ | ||
1062 | #define cpu_possible_mask ((const struct cpumask *)&cpu_possible_map) | ||
1063 | #define cpu_online_mask ((const struct cpumask *)&cpu_online_map) | ||
1064 | #define cpu_present_mask ((const struct cpumask *)&cpu_present_map) | ||
1065 | #define cpu_active_mask ((const struct cpumask *)&cpu_active_map) | ||
1066 | |||
1067 | /* It's common to want to use cpu_all_mask in struct member initializers, | 1050 | /* It's common to want to use cpu_all_mask in struct member initializers, |
1068 | * so it has to refer to an address rather than a pointer. */ | 1051 | * so it has to refer to an address rather than a pointer. */ |
1069 | extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); | 1052 | extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); |
diff --git a/kernel/cpu.c b/kernel/cpu.c index bae131a1211b..3ddc509b19c5 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -15,30 +15,8 @@ | |||
15 | #include <linux/stop_machine.h> | 15 | #include <linux/stop_machine.h> |
16 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
17 | 17 | ||
18 | /* | ||
19 | * Represents all cpu's present in the system | ||
20 | * In systems capable of hotplug, this map could dynamically grow | ||
21 | * as new cpu's are detected in the system via any platform specific | ||
22 | * method, such as ACPI for e.g. | ||
23 | */ | ||
24 | cpumask_t cpu_present_map __read_mostly; | ||
25 | EXPORT_SYMBOL(cpu_present_map); | ||
26 | |||
27 | /* | ||
28 | * Represents all cpu's that are currently online. | ||
29 | */ | ||
30 | cpumask_t cpu_online_map __read_mostly; | ||
31 | EXPORT_SYMBOL(cpu_online_map); | ||
32 | |||
33 | #ifdef CONFIG_INIT_ALL_POSSIBLE | ||
34 | cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL; | ||
35 | #else | ||
36 | cpumask_t cpu_possible_map __read_mostly; | ||
37 | #endif | ||
38 | EXPORT_SYMBOL(cpu_possible_map); | ||
39 | |||
40 | #ifdef CONFIG_SMP | 18 | #ifdef CONFIG_SMP |
41 | /* Serializes the updates to cpu_online_map, cpu_present_map */ | 19 | /* Serializes the updates to cpu_online_mask, cpu_present_mask */ |
42 | static DEFINE_MUTEX(cpu_add_remove_lock); | 20 | static DEFINE_MUTEX(cpu_add_remove_lock); |
43 | 21 | ||
44 | static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain); | 22 | static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain); |
@@ -65,8 +43,6 @@ void __init cpu_hotplug_init(void) | |||
65 | cpu_hotplug.refcount = 0; | 43 | cpu_hotplug.refcount = 0; |
66 | } | 44 | } |
67 | 45 | ||
68 | cpumask_t cpu_active_map; | ||
69 | |||
70 | #ifdef CONFIG_HOTPLUG_CPU | 46 | #ifdef CONFIG_HOTPLUG_CPU |
71 | 47 | ||
72 | void get_online_cpus(void) | 48 | void get_online_cpus(void) |
@@ -97,7 +73,7 @@ EXPORT_SYMBOL_GPL(put_online_cpus); | |||
97 | 73 | ||
98 | /* | 74 | /* |
99 | * The following two API's must be used when attempting | 75 | * The following two API's must be used when attempting |
100 | * to serialize the updates to cpu_online_map, cpu_present_map. | 76 | * to serialize the updates to cpu_online_mask, cpu_present_mask. |
101 | */ | 77 | */ |
102 | void cpu_maps_update_begin(void) | 78 | void cpu_maps_update_begin(void) |
103 | { | 79 | { |
@@ -503,3 +479,24 @@ EXPORT_SYMBOL_GPL(cpu_bit_bitmap); | |||
503 | 479 | ||
504 | const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL; | 480 | const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL; |
505 | EXPORT_SYMBOL(cpu_all_bits); | 481 | EXPORT_SYMBOL(cpu_all_bits); |
482 | |||
483 | #ifdef CONFIG_INIT_ALL_POSSIBLE | ||
484 | static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly | ||
485 | = CPU_BITS_ALL; | ||
486 | #else | ||
487 | static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly; | ||
488 | #endif | ||
489 | const struct cpumask *const cpu_possible_mask = to_cpumask(cpu_possible_bits); | ||
490 | EXPORT_SYMBOL(cpu_possible_mask); | ||
491 | |||
492 | static DECLARE_BITMAP(cpu_online_bits, CONFIG_NR_CPUS) __read_mostly; | ||
493 | const struct cpumask *const cpu_online_mask = to_cpumask(cpu_online_bits); | ||
494 | EXPORT_SYMBOL(cpu_online_mask); | ||
495 | |||
496 | static DECLARE_BITMAP(cpu_present_bits, CONFIG_NR_CPUS) __read_mostly; | ||
497 | const struct cpumask *const cpu_present_mask = to_cpumask(cpu_present_bits); | ||
498 | EXPORT_SYMBOL(cpu_present_mask); | ||
499 | |||
500 | static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly; | ||
501 | const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits); | ||
502 | EXPORT_SYMBOL(cpu_active_mask); | ||