kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 2/2] test: vmexit: run parallel tests on each cpu
Date: Mon, 05 Oct 2009 10:07:37 -0300	[thread overview]
Message-ID: <20091005130809.472219074@redhat.com> (raw)
In-Reply-To: 20091005130735.194554408@redhat.com

[-- Attachment #1: vmexit-parallel --]
[-- Type: text/plain, Size: 1931 bytes --]

So one can measure SMP overhead.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

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



  parent reply	other threads:[~2009-10-05 20:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-28 11:22 [patch 0/2] test: parallel vmexit Marcelo Tosatti
2009-09-28 11:22 ` [patch 1/2] test: add wait parameter to on_cpu Marcelo Tosatti
2009-09-29  8:32   ` Avi Kivity
2009-09-28 11:22 ` [patch 2/2] test: vmexit: run parallel tests on each cpu Marcelo Tosatti
2009-09-29  8:35   ` Avi Kivity
2009-10-05 13:07 ` [patch 0/2] kvm: test: parallel vmexit (v2) Marcelo Tosatti
2009-10-05 13:07   ` [patch 1/2] test: add on_cpu_async Marcelo Tosatti
2009-10-05 13:07   ` Marcelo Tosatti [this message]
2009-10-06  0:56     ` [patch 3/3] test: vmexit: inl from pmtimer Marcelo Tosatti
2009-10-06  9:56   ` [patch 0/2] kvm: test: parallel vmexit (v2) Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091005130809.472219074@redhat.com \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).