diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2009-10-05 10:07:37 -0300 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-10-06 11:55:57 +0200 |
commit | d1bc50647a8a3fc12bab4d231745ddcac9e52f74 (patch) | |
tree | cb3237a26645454a949b234647853e67f6c546c9 /kvm | |
parent | test: add on_cpu_async (diff) | |
download | qemu-kvm-d1bc50647a8a3fc12bab4d231745ddcac9e52f74.tar.gz qemu-kvm-d1bc50647a8a3fc12bab4d231745ddcac9e52f74.tar.bz2 qemu-kvm-d1bc50647a8a3fc12bab4d231745ddcac9e52f74.zip |
test: vmexit: run parallel tests on each cpu
So one can measure SMP overhead.
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/x86/vmexit.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c index e7cb5efe0..5455919c5 100644 --- a/kvm/user/test/x86/vmexit.c +++ b/kvm/user/test/x86/vmexit.c @@ -80,22 +80,38 @@ static struct test { void (*func)(void); const char *name; int (*valid)(void); + int parallel; } tests[] = { - { cpuid, "cpuid", }, - { vmcall, "vmcall", }, - { mov_from_cr8, "mov_from_cr8" }, - { mov_to_cr8, "mov_to_cr8" }, - { ipi, "ipi", is_smp }, - { ipi_halt, "ipi+halt", is_smp }, + { cpuid, "cpuid", .parallel = 1, }, + { vmcall, "vmcall", .parallel = 1, }, + { mov_from_cr8, "mov_from_cr8", .parallel = 1, }, + { mov_to_cr8, "mov_to_cr8" , .parallel = 1, }, + { ipi, "ipi", is_smp, .parallel = 0, }, + { ipi_halt, "ipi+halt", is_smp, .parallel = 0, }, }; +unsigned iterations; +volatile int nr_cpus_done; + +static void run_test(void *_func) +{ + int i; + void (*func)(void) = _func; + + for (i = 0; i < iterations; ++i) + func(); + + nr_cpus_done++; +} + static void do_test(struct test *test) { int i; unsigned long long t1, t2; - unsigned iterations = 32; void (*func)(void) = test->func; + iterations = 32; + if (test->valid && !test->valid()) { printf("%s (skipped)\n", test->name); return; @@ -104,8 +120,17 @@ static void do_test(struct test *test) do { iterations *= 2; t1 = rdtsc(); - for (i = 0; i < iterations; ++i) - func(); + + if (!test->parallel) { + for (i = 0; i < iterations; ++i) + func(); + } else { + nr_cpus_done = 0; + for (i = cpu_count(); i > 0; i--) + on_cpu_async(i-1, run_test, func); + while (nr_cpus_done < cpu_count()) + ; + } t2 = rdtsc(); } while ((t2 - t1) < GOAL); printf("%s %d\n", test->name, (int)((t2 - t1) / iterations)); |