From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [patch 2/2] test: vmexit: run parallel tests on each cpu Date: Mon, 05 Oct 2009 10:07:37 -0300 Message-ID: <20091005130809.472219074@redhat.com> References: <20091005130735.194554408@redhat.com> Cc: avi@redhat.com, Marcelo Tosatti To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:57104 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754035AbZJEUKQ (ORCPT ); Mon, 5 Oct 2009 16:10:16 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n95K9o6Z007171 for ; Mon, 5 Oct 2009 16:09:50 -0400 Content-Disposition: inline; filename=vmexit-parallel Sender: kvm-owner@vger.kernel.org List-ID: So one can measure SMP overhead. Signed-off-by: Marcelo Tosatti Index: qemu-kvm-parallel-vmexit/kvm/user/test/x86/vmexit.c =================================================================== --- qemu-kvm-parallel-vmexit.orig/kvm/user/test/x86/vmexit.c +++ qemu-kvm-parallel-vmexit/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));