diff mbox

[1/2] test: add on_cpu_async

Message ID 20091005130809.415119525@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti Oct. 5, 2009, 1:07 p.m. UTC
None
diff mbox

Patch

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);