aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/smpboot_32.c
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2007-10-19 14:35:03 -0400
committerThomas Gleixner <tglx@linutronix.de>2007-10-19 14:35:03 -0400
commit71fff5e6ca1b738ac4742580e4c0ff79d906f6c8 (patch)
tree390e67123d684ab7f490291db987e097e5b3c728 /arch/x86/kernel/smpboot_32.c
parentdbeb2be21d678c49a8d8bbf774903df15dd55474 (diff)
x86: convert cpu_to_apicid to be a per cpu variable
This patch converts the x86_cpu_to_apicid array to be a per cpu variable. This saves sizeof(apicid) * NR unused cpus. Access is mostly from startup and CPU HOTPLUG functions. MP_processor_info() is one of the functions that require access to the x86_cpu_to_apicid array before the per_cpu data area is setup. For this case, a pointer to the __initdata array is initialized in setup_arch() and removed in smp_prepare_cpus() after the per_cpu data area is initialized. A second change is included to change the initial array value of ARCH i386 from 0xff to BAD_APICID to be consistent with ARCH x86_64. Signed-off-by: Mike Travis <travis@sgi.com> Cc: Andi Kleen <ak@suse.de> Cc: Christoph Lameter <clameter@sgi.com> Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/smpboot_32.c')
-rw-r--r--arch/x86/kernel/smpboot_32.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/arch/x86/kernel/smpboot_32.c b/arch/x86/kernel/smpboot_32.c
index 65e5de7d64db..631be36ec2a9 100644
--- a/arch/x86/kernel/smpboot_32.c
+++ b/arch/x86/kernel/smpboot_32.c
@@ -92,9 +92,17 @@ static cpumask_t smp_commenced_mask;
92struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned; 92struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
93EXPORT_SYMBOL(cpu_data); 93EXPORT_SYMBOL(cpu_data);
94 94
95u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly = 95/*
96 { [0 ... NR_CPUS-1] = 0xff }; 96 * The following static array is used during kernel startup
97EXPORT_SYMBOL(x86_cpu_to_apicid); 97 * and the x86_cpu_to_apicid_ptr contains the address of the
98 * array during this time. Is it zeroed when the per_cpu
99 * data area is removed.
100 */
101u8 x86_cpu_to_apicid_init[NR_CPUS] __initdata =
102 { [0 ... NR_CPUS-1] = BAD_APICID };
103void *x86_cpu_to_apicid_ptr;
104DEFINE_PER_CPU(u8, x86_cpu_to_apicid) = BAD_APICID;
105EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
98 106
99u8 apicid_2_node[MAX_APICID]; 107u8 apicid_2_node[MAX_APICID];
100 108
@@ -804,7 +812,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
804 812
805 irq_ctx_init(cpu); 813 irq_ctx_init(cpu);
806 814
807 x86_cpu_to_apicid[cpu] = apicid; 815 per_cpu(x86_cpu_to_apicid, cpu) = apicid;
808 /* 816 /*
809 * This grunge runs the startup process for 817 * This grunge runs the startup process for
810 * the targeted processor. 818 * the targeted processor.
@@ -866,7 +874,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
866 cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */ 874 cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */
867 cpucount--; 875 cpucount--;
868 } else { 876 } else {
869 x86_cpu_to_apicid[cpu] = apicid; 877 per_cpu(x86_cpu_to_apicid, cpu) = apicid;
870 cpu_set(cpu, cpu_present_map); 878 cpu_set(cpu, cpu_present_map);
871 } 879 }
872 880
@@ -915,7 +923,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
915 struct warm_boot_cpu_info info; 923 struct warm_boot_cpu_info info;
916 int apicid, ret; 924 int apicid, ret;
917 925
918 apicid = x86_cpu_to_apicid[cpu]; 926 apicid = per_cpu(x86_cpu_to_apicid, cpu);
919 if (apicid == BAD_APICID) { 927 if (apicid == BAD_APICID) {
920 ret = -ENODEV; 928 ret = -ENODEV;
921 goto exit; 929 goto exit;
@@ -965,7 +973,7 @@ static void __init smp_boot_cpus(unsigned int max_cpus)
965 973
966 boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); 974 boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
967 boot_cpu_logical_apicid = logical_smp_processor_id(); 975 boot_cpu_logical_apicid = logical_smp_processor_id();
968 x86_cpu_to_apicid[0] = boot_cpu_physical_apicid; 976 per_cpu(x86_cpu_to_apicid, 0) = boot_cpu_physical_apicid;
969 977
970 current_thread_info()->cpu = 0; 978 current_thread_info()->cpu = 0;
971 979