Glauber Costa | 68a1c3f | 2008-03-03 14:12:42 -0300 | [diff] [blame] | 1 | #include <linux/init.h> |
| 2 | #include <linux/smp.h> |
Glauber Costa | a355352 | 2008-03-03 14:12:58 -0300 | [diff] [blame^] | 3 | #include <linux/module.h> |
Glauber Costa | 68a1c3f | 2008-03-03 14:12:42 -0300 | [diff] [blame] | 4 | |
Glauber Costa | a355352 | 2008-03-03 14:12:58 -0300 | [diff] [blame^] | 5 | /* Number of siblings per CPU package */ |
| 6 | int smp_num_siblings = 1; |
| 7 | EXPORT_SYMBOL(smp_num_siblings); |
| 8 | |
| 9 | /* Last level cache ID of each logical CPU */ |
| 10 | DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID; |
| 11 | |
| 12 | /* bitmap of online cpus */ |
| 13 | cpumask_t cpu_online_map __read_mostly; |
| 14 | EXPORT_SYMBOL(cpu_online_map); |
| 15 | |
| 16 | cpumask_t cpu_callin_map; |
| 17 | cpumask_t cpu_callout_map; |
| 18 | cpumask_t cpu_possible_map; |
| 19 | EXPORT_SYMBOL(cpu_possible_map); |
| 20 | |
| 21 | /* representing HT siblings of each logical CPU */ |
| 22 | DEFINE_PER_CPU(cpumask_t, cpu_sibling_map); |
| 23 | EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); |
| 24 | |
| 25 | /* representing HT and core siblings of each logical CPU */ |
| 26 | DEFINE_PER_CPU(cpumask_t, cpu_core_map); |
| 27 | EXPORT_PER_CPU_SYMBOL(cpu_core_map); |
| 28 | |
| 29 | /* Per CPU bogomips and other parameters */ |
| 30 | DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); |
| 31 | EXPORT_PER_CPU_SYMBOL(cpu_info); |
Glauber Costa | 68a1c3f | 2008-03-03 14:12:42 -0300 | [diff] [blame] | 32 | #ifdef CONFIG_HOTPLUG_CPU |
| 33 | |
| 34 | int additional_cpus __initdata = -1; |
| 35 | |
| 36 | static __init int setup_additional_cpus(char *s) |
| 37 | { |
| 38 | return s && get_option(&s, &additional_cpus) ? 0 : -EINVAL; |
| 39 | } |
| 40 | early_param("additional_cpus", setup_additional_cpus); |
| 41 | |
| 42 | /* |
| 43 | * cpu_possible_map should be static, it cannot change as cpu's |
| 44 | * are onlined, or offlined. The reason is per-cpu data-structures |
| 45 | * are allocated by some modules at init time, and dont expect to |
| 46 | * do this dynamically on cpu arrival/departure. |
| 47 | * cpu_present_map on the other hand can change dynamically. |
| 48 | * In case when cpu_hotplug is not compiled, then we resort to current |
| 49 | * behaviour, which is cpu_possible == cpu_present. |
| 50 | * - Ashok Raj |
| 51 | * |
| 52 | * Three ways to find out the number of additional hotplug CPUs: |
| 53 | * - If the BIOS specified disabled CPUs in ACPI/mptables use that. |
| 54 | * - The user can overwrite it with additional_cpus=NUM |
| 55 | * - Otherwise don't reserve additional CPUs. |
| 56 | * We do this because additional CPUs waste a lot of memory. |
| 57 | * -AK |
| 58 | */ |
| 59 | __init void prefill_possible_map(void) |
| 60 | { |
| 61 | int i; |
| 62 | int possible; |
| 63 | |
| 64 | if (additional_cpus == -1) { |
| 65 | if (disabled_cpus > 0) |
| 66 | additional_cpus = disabled_cpus; |
| 67 | else |
| 68 | additional_cpus = 0; |
| 69 | } |
| 70 | possible = num_processors + additional_cpus; |
| 71 | if (possible > NR_CPUS) |
| 72 | possible = NR_CPUS; |
| 73 | |
| 74 | printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n", |
| 75 | possible, max_t(int, possible - num_processors, 0)); |
| 76 | |
| 77 | for (i = 0; i < possible; i++) |
| 78 | cpu_set(i, cpu_possible_map); |
| 79 | } |
| 80 | #endif |
| 81 | |