[patch 1/2] test: add on_cpu_async

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Non-wait version of on_cpu.

Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>

Index: qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.c
===================================================================
--- qemu-kvm-parallel-vmexit.orig/kvm/user/test/lib/x86/smp.c
+++ qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.c
@@ -82,24 +82,38 @@ static void setup_smp_id(void *data)
     asm ("mov %0, %%gs:0" : : "r"(apic_id()) : "memory");
 }
 
-void on_cpu(int cpu, void (*function)(void *data), void *data)
+static void __on_cpu(int cpu, void (*function)(void *data), void *data,
+                     int wait)
 {
     spin_lock(&ipi_lock);
     if (cpu == smp_id())
 	function(data);
     else {
+	ipi_done = 0;
 	ipi_function = function;
 	ipi_data = data;
 	apic_icr_write(APIC_INT_ASSERT | APIC_DEST_PHYSICAL | APIC_DM_FIXED
                        | IPI_VECTOR,
                        cpu);
-	while (!ipi_done)
-	    ;
-	ipi_done = 0;
+	if (wait) {
+		while (!ipi_done)
+		    ;
+	}
     }
     spin_unlock(&ipi_lock);
 }
 
+void on_cpu(int cpu, void (*function)(void *data), void *data)
+{
+    __on_cpu(cpu, function, data, 1);
+}
+
+void on_cpu_async(int cpu, void (*function)(void *data), void *data)
+{
+    __on_cpu(cpu, function, data, 0);
+}
+
+
 void smp_init(void)
 {
     int i;
Index: qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.h
===================================================================
--- qemu-kvm-parallel-vmexit.orig/kvm/user/test/lib/x86/smp.h
+++ qemu-kvm-parallel-vmexit/kvm/user/test/lib/x86/smp.h
@@ -10,6 +10,7 @@ void smp_init(void);
 int cpu_count(void);
 int smp_id(void);
 void on_cpu(int cpu, void (*function)(void *data), void *data);
+void on_cpu_async(int cpu, void (*function)(void *data), void *data);
 void spin_lock(struct spinlock *lock);
 void spin_unlock(struct spinlock *lock);
 


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux