فهرست منبع

[PATCH] x86_64/i386: Remove preempt disable calls in lowlevel IPI

I noticed that some lowlevel send_IPI_mask helpers had a hotplug/preempt
race whereupon the cpu_online_map was read before disabling preemption;

...
cpumask_t mask = cpu_online_map;
int cpu = get_cpu();
cpu_clear(cpu, mask);
...

But then i realised that there is no need for these lowlevel functions to
be going through all this trouble when all the callers are already made
hotplug/preempt safe.

Signed-off-by: Zwane Mwaikambo <zwane@arm.linux.org.uk>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Zwane Mwaikambo 19 سال پیش
والد
کامیت
329d400f47
3فایلهای تغییر یافته به همراه6 افزوده شده و 13 حذف شده
  1. 1 4
      arch/x86_64/kernel/genapic_cluster.c
  2. 4 6
      arch/x86_64/kernel/genapic_flat.c
  3. 1 3
      include/asm-i386/mach-default/mach_ipi.h

+ 1 - 4
arch/x86_64/kernel/genapic_cluster.c

@@ -72,14 +72,11 @@ static void cluster_send_IPI_mask(cpumask_t mask, int vector)
 static void cluster_send_IPI_allbutself(int vector)
 {
 	cpumask_t mask = cpu_online_map;
-	int me = get_cpu(); /* Ensure we are not preempted when we clear */
 
-	cpu_clear(me, mask);
+	cpu_clear(smp_processor_id(), mask);
 
 	if (!cpus_empty(mask))
 		cluster_send_IPI_mask(mask, vector);
-
-	put_cpu();
 }
 
 static void cluster_send_IPI_all(int vector)

+ 4 - 6
arch/x86_64/kernel/genapic_flat.c

@@ -83,12 +83,11 @@ static void flat_send_IPI_allbutself(int vector)
 		__send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL);
 #else
 	cpumask_t allbutme = cpu_online_map;
-	int me = get_cpu(); /* Ensure we are not preempted when we clear */
-	cpu_clear(me, allbutme);
+
+	cpu_clear(smp_processor_id(), allbutme);
 
 	if (!cpus_empty(allbutme))
 		flat_send_IPI_mask(allbutme, vector);
-	put_cpu();
 #endif
 }
 
@@ -149,10 +148,9 @@ static void physflat_send_IPI_mask(cpumask_t cpumask, int vector)
 static void physflat_send_IPI_allbutself(int vector)
 {
 	cpumask_t allbutme = cpu_online_map;
-	int me = get_cpu();
-	cpu_clear(me, allbutme);
+
+	cpu_clear(smp_processor_id(), allbutme);
 	physflat_send_IPI_mask(allbutme, vector);
-	put_cpu();
 }
 
 static void physflat_send_IPI_all(int vector)

+ 1 - 3
include/asm-i386/mach-default/mach_ipi.h

@@ -15,11 +15,9 @@ static inline void __local_send_IPI_allbutself(int vector)
 {
 	if (no_broadcast) {
 		cpumask_t mask = cpu_online_map;
-		int this_cpu = get_cpu();
 
-		cpu_clear(this_cpu, mask);
+		cpu_clear(smp_processor_id(), mask);
 		send_IPI_mask(mask, vector);
-		put_cpu();
 	} else
 		__send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
 }