summaryrefslogtreecommitdiff
path: root/kvm
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-10-05 10:07:36 -0300
committerAvi Kivity <avi@redhat.com>2009-10-06 11:55:57 +0200
commit041b3c8f2547d8db24a3657b9209c02c0869f1a9 (patch)
tree268305641975e564735184fa67f39f1bc038f23f /kvm
parentRe-enable -Werror for kvm (diff)
downloadqemu-kvm-041b3c8f2547d8db24a3657b9209c02c0869f1a9.tar.gz
qemu-kvm-041b3c8f2547d8db24a3657b9209c02c0869f1a9.tar.bz2
qemu-kvm-041b3c8f2547d8db24a3657b9209c02c0869f1a9.zip
test: add on_cpu_async
Non-wait version of on_cpu. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'kvm')
-rw-r--r--kvm/user/test/lib/x86/smp.c22
-rw-r--r--kvm/user/test/lib/x86/smp.h1
2 files changed, 19 insertions, 4 deletions
diff --git a/kvm/user/test/lib/x86/smp.c b/kvm/user/test/lib/x86/smp.c
index 9eface511..241f7551e 100644
--- a/kvm/user/test/lib/x86/smp.c
+++ b/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;
diff --git a/kvm/user/test/lib/x86/smp.h b/kvm/user/test/lib/x86/smp.h
index bac7e1478..c2e73501c 100644
--- a/kvm/user/test/lib/x86/smp.h
+++ b/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);