x86: Always use x86_cpu_to_logical_apicid for cpu -> logical apic id
authorTejun Heo <tj@kernel.org>
Sun, 23 Jan 2011 13:37:31 +0000 (14:37 +0100)
committerIngo Molnar <mingo@elte.hu>
Fri, 28 Jan 2011 13:54:05 +0000 (14:54 +0100)
Currently, cpu -> logical apic id translation is done by
apic->cpu_to_logical_apicid() callback which may or may not use
x86_cpu_to_logical_apicid.  This is unnecessary as it should
always equal logical_smp_processor_id() which is known early
during CPU bring up.

Initialize x86_cpu_to_logical_apicid after apic->init_apic_ldr()
in setup_local_APIC() and always use x86_cpu_to_logical_apicid
for cpu -> logical apic id mapping.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: eric.dumazet@gmail.com
Cc: yinghai@kernel.org
Cc: brgerst@gmail.com
Cc: gorcunov@gmail.com
Cc: penberg@kernel.org
Cc: shaohui.zheng@intel.com
Cc: rientjes@google.com
LKML-Reference: <1295789862-25482-6-git-send-email-tj@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/ipi.c
arch/x86/kernel/smpboot.c

index 126d5a3b00e9cdc8cdc3e5e25cc9ea82fb3e4cbf..ae08246f320c426c3f6aeea147c7168cf0b1143d 100644 (file)
@@ -1248,6 +1248,14 @@ void __cpuinit setup_local_APIC(void)
         */
        apic->init_apic_ldr();
 
+#ifdef CONFIG_X86_32
+       /*
+        * APIC LDR is initialized.  Fetch and store logical_apic_id.
+        */
+       early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
+               logical_smp_processor_id();
+#endif
+
        /*
         * Set Task Priority to 'accept all'. We never change this
         * later on.
index 5037736c460d2d1392d6af20102a16a4f93495e2..cce91bf26676cddee4b5c42fa21016a801411079 100644 (file)
@@ -73,8 +73,8 @@ void default_send_IPI_mask_sequence_logical(const struct cpumask *mask,
        local_irq_save(flags);
        for_each_cpu(query_cpu, mask)
                __default_send_IPI_dest_field(
-                       apic->cpu_to_logical_apicid(query_cpu), vector,
-                       apic->dest_logical);
+                       early_per_cpu(x86_cpu_to_logical_apicid, query_cpu),
+                       vector, apic->dest_logical);
        local_irq_restore(flags);
 }
 
@@ -92,8 +92,8 @@ void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask,
                if (query_cpu == this_cpu)
                        continue;
                __default_send_IPI_dest_field(
-                       apic->cpu_to_logical_apicid(query_cpu), vector,
-                       apic->dest_logical);
+                       early_per_cpu(x86_cpu_to_logical_apicid, query_cpu),
+                       vector, apic->dest_logical);
                }
        local_irq_restore(flags);
 }
index df934e46bf5334645247effc657acf3f49a1e481..ca20f6bee3be2156c283da2894265a4f2ce90831 100644 (file)
@@ -168,19 +168,18 @@ static void unmap_cpu_to_node(int cpu)
 static void map_cpu_to_logical_apicid(void)
 {
        int cpu = smp_processor_id();
-       int apicid = logical_smp_processor_id();
-       int node = apic->apicid_to_node(apicid);
+       int logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
+       int node;
 
+       node = apic->apicid_to_node(logical_apicid);
        if (!node_online(node))
                node = first_online_node;
 
-       early_per_cpu(x86_cpu_to_logical_apicid, cpu) = apicid;
        map_cpu_to_node(cpu, node);
 }
 
 void numa_remove_cpu(int cpu)
 {
-       early_per_cpu(x86_cpu_to_logical_apicid, cpu) = BAD_APICID;
        unmap_cpu_to_node(cpu);
 }
 #else