diff options
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r-- | kernel/cpu.c | 97 |
1 files changed, 71 insertions, 26 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c index 8ea32e8d68b0..2c9f78f3a2fc 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -15,29 +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 | /* | 18 | #ifdef CONFIG_SMP |
19 | * Represents all cpu's present in the system | 19 | /* Serializes the updates to cpu_online_mask, cpu_present_mask */ |
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 | #ifndef CONFIG_SMP | ||
28 | |||
29 | /* | ||
30 | * Represents all cpu's that are currently online. | ||
31 | */ | ||
32 | cpumask_t cpu_online_map __read_mostly = CPU_MASK_ALL; | ||
33 | EXPORT_SYMBOL(cpu_online_map); | ||
34 | |||
35 | cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL; | ||
36 | EXPORT_SYMBOL(cpu_possible_map); | ||
37 | |||
38 | #else /* CONFIG_SMP */ | ||
39 | |||
40 | /* Serializes the updates to cpu_online_map, cpu_present_map */ | ||
41 | static DEFINE_MUTEX(cpu_add_remove_lock); | 20 | static DEFINE_MUTEX(cpu_add_remove_lock); |
42 | 21 | ||
43 | static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain); | 22 | static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain); |
@@ -64,8 +43,6 @@ void __init cpu_hotplug_init(void) | |||
64 | cpu_hotplug.refcount = 0; | 43 | cpu_hotplug.refcount = 0; |
65 | } | 44 | } |
66 | 45 | ||
67 | cpumask_t cpu_active_map; | ||
68 | |||
69 | #ifdef CONFIG_HOTPLUG_CPU | 46 | #ifdef CONFIG_HOTPLUG_CPU |
70 | 47 | ||
71 | void get_online_cpus(void) | 48 | void get_online_cpus(void) |
@@ -96,7 +73,7 @@ EXPORT_SYMBOL_GPL(put_online_cpus); | |||
96 | 73 | ||
97 | /* | 74 | /* |
98 | * The following two API's must be used when attempting | 75 | * The following two API's must be used when attempting |
99 | * to serialize the updates to cpu_online_map, cpu_present_map. | 76 | * to serialize the updates to cpu_online_mask, cpu_present_mask. |
100 | */ | 77 | */ |
101 | void cpu_maps_update_begin(void) | 78 | void cpu_maps_update_begin(void) |
102 | { | 79 | { |
@@ -502,3 +479,71 @@ EXPORT_SYMBOL_GPL(cpu_bit_bitmap); | |||
502 | 479 | ||
503 | const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL; | 480 | const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL; |
504 | 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); | ||
503 | |||
504 | void set_cpu_possible(unsigned int cpu, bool possible) | ||
505 | { | ||
506 | if (possible) | ||
507 | cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits)); | ||
508 | else | ||
509 | cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits)); | ||
510 | } | ||
511 | |||
512 | void set_cpu_present(unsigned int cpu, bool present) | ||
513 | { | ||
514 | if (present) | ||
515 | cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits)); | ||
516 | else | ||
517 | cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits)); | ||
518 | } | ||
519 | |||
520 | void set_cpu_online(unsigned int cpu, bool online) | ||
521 | { | ||
522 | if (online) | ||
523 | cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits)); | ||
524 | else | ||
525 | cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits)); | ||
526 | } | ||
527 | |||
528 | void set_cpu_active(unsigned int cpu, bool active) | ||
529 | { | ||
530 | if (active) | ||
531 | cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits)); | ||
532 | else | ||
533 | cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits)); | ||
534 | } | ||
535 | |||
536 | void init_cpu_present(const struct cpumask *src) | ||
537 | { | ||
538 | cpumask_copy(to_cpumask(cpu_present_bits), src); | ||
539 | } | ||
540 | |||
541 | void init_cpu_possible(const struct cpumask *src) | ||
542 | { | ||
543 | cpumask_copy(to_cpumask(cpu_possible_bits), src); | ||
544 | } | ||
545 | |||
546 | void init_cpu_online(const struct cpumask *src) | ||
547 | { | ||
548 | cpumask_copy(to_cpumask(cpu_online_bits), src); | ||
549 | } | ||