]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86, x2apic: Remove duplicate code for IPI mask routines
authorSuresh Siddha <suresh.b.siddha@intel.com>
Thu, 19 May 2011 23:45:47 +0000 (16:45 -0700)
committerIngo Molnar <mingo@elte.hu>
Fri, 20 May 2011 11:41:06 +0000 (13:41 +0200)
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: steiner@sgi.com
Cc: yinghai@kernel.org
Link: http://lkml.kernel.org/r/20110519234637.337024125@sbsiddha-MOBL3.sc.intel.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/apic/x2apic_cluster.c
arch/x86/kernel/apic/x2apic_phys.c

index 2967bab775e55072ddb1a6ca7bf5580e57d7856e..b2617993de19b7b74290834a2c7c53b094f07ba8 100644 (file)
@@ -54,64 +54,48 @@ static void
  * at once. We have 16 cpu's in a cluster. This will minimize IPI register
  * writes.
  */
-static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
+static void
+__x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
 {
        unsigned long query_cpu;
+       unsigned long this_cpu;
        unsigned long flags;
 
        x2apic_wrmsr_fence();
 
        local_irq_save(flags);
+
+       this_cpu = smp_processor_id();
        for_each_cpu(query_cpu, mask) {
+               if (apic_dest == APIC_DEST_ALLBUT && query_cpu == this_cpu)
+                       continue;
                __x2apic_send_IPI_dest(
                        per_cpu(x86_cpu_to_logical_apicid, query_cpu),
                        vector, apic->dest_logical);
        }
+
        local_irq_restore(flags);
 }
 
+static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
+{
+       __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC);
+}
+
 static void
  x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
 {
-       unsigned long this_cpu = smp_processor_id();
-       unsigned long query_cpu;
-       unsigned long flags;
-
-       x2apic_wrmsr_fence();
-
-       local_irq_save(flags);
-       for_each_cpu(query_cpu, mask) {
-               if (query_cpu == this_cpu)
-                       continue;
-               __x2apic_send_IPI_dest(
-                               per_cpu(x86_cpu_to_logical_apicid, query_cpu),
-                               vector, apic->dest_logical);
-       }
-       local_irq_restore(flags);
+       __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
 }
 
 static void x2apic_send_IPI_allbutself(int vector)
 {
-       unsigned long this_cpu = smp_processor_id();
-       unsigned long query_cpu;
-       unsigned long flags;
-
-       x2apic_wrmsr_fence();
-
-       local_irq_save(flags);
-       for_each_online_cpu(query_cpu) {
-               if (query_cpu == this_cpu)
-                       continue;
-               __x2apic_send_IPI_dest(
-                               per_cpu(x86_cpu_to_logical_apicid, query_cpu),
-                               vector, apic->dest_logical);
-       }
-       local_irq_restore(flags);
+       __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT);
 }
 
 static void x2apic_send_IPI_all(int vector)
 {
-       x2apic_send_IPI_mask(cpu_online_mask, vector);
+       __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
 }
 
 static int x2apic_apic_id_registered(void)
index 8f21771249f635d89daf92afbc2da4d622e7f1e7..6ef49e338a731c24e8cac9f3ba46271226762087 100644 (file)
@@ -55,61 +55,46 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
        native_x2apic_icr_write(cfg, apicid);
 }
 
-static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
+static void
+__x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
 {
        unsigned long query_cpu;
+       unsigned long this_cpu;
        unsigned long flags;
 
        x2apic_wrmsr_fence();
 
        local_irq_save(flags);
+
+       this_cpu = smp_processor_id();
        for_each_cpu(query_cpu, mask) {
+               if (apic_dest == APIC_DEST_ALLBUT && this_cpu == query_cpu)
+                       continue;
                __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
                                       vector, APIC_DEST_PHYSICAL);
        }
        local_irq_restore(flags);
 }
 
+static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
+{
+       __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC);
+}
+
 static void
  x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
 {
-       unsigned long this_cpu = smp_processor_id();
-       unsigned long query_cpu;
-       unsigned long flags;
-
-       x2apic_wrmsr_fence();
-
-       local_irq_save(flags);
-       for_each_cpu(query_cpu, mask) {
-               if (query_cpu != this_cpu)
-                       __x2apic_send_IPI_dest(
-                               per_cpu(x86_cpu_to_apicid, query_cpu),
-                               vector, APIC_DEST_PHYSICAL);
-       }
-       local_irq_restore(flags);
+       __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
 }
 
 static void x2apic_send_IPI_allbutself(int vector)
 {
-       unsigned long this_cpu = smp_processor_id();
-       unsigned long query_cpu;
-       unsigned long flags;
-
-       x2apic_wrmsr_fence();
-
-       local_irq_save(flags);
-       for_each_online_cpu(query_cpu) {
-               if (query_cpu == this_cpu)
-                       continue;
-               __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
-                                      vector, APIC_DEST_PHYSICAL);
-       }
-       local_irq_restore(flags);
+       __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT);
 }
 
 static void x2apic_send_IPI_all(int vector)
 {
-       x2apic_send_IPI_mask(cpu_online_mask, vector);
+       __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
 }
 
 static int x2apic_apic_id_registered(void)