All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [PATCH QEMU-KVM 7/7] test: Auto-tune vmexit test
Date: Mon, 21 Sep 2009 11:55:38 +0300	[thread overview]
Message-ID: <1253523338-22784-8-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1253523338-22784-1-git-send-email-avi@redhat.com>

Scale up iterations until we measure at least 1G cycles.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 kvm/user/test/x86/vmexit.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 5088dc9..e7cb5ef 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -17,7 +17,7 @@ static inline unsigned long long rdtsc()
 	return r;
 }
 
-#define N (1 << 22)
+#define GOAL (1ull << 30)
 
 #ifdef __x86_64__
 #  define R "r"
@@ -93,6 +93,7 @@ static void do_test(struct test *test)
 {
 	int i;
 	unsigned long long t1, t2;
+	unsigned iterations = 32;
         void (*func)(void) = test->func;
 
         if (test->valid && !test->valid()) {
@@ -100,11 +101,14 @@ static void do_test(struct test *test)
 		return;
 	}
 
-	t1 = rdtsc();
-	for (i = 0; i < N; ++i)
-            func();
-	t2 = rdtsc();
-	printf("%s %d\n", test->name, (int)((t2 - t1) / N));
+	do {
+		iterations *= 2;
+		t1 = rdtsc();
+		for (i = 0; i < iterations; ++i)
+			func();
+		t2 = rdtsc();
+	} while ((t2 - t1) < GOAL);
+	printf("%s %d\n", test->name, (int)((t2 - t1) / iterations));
 }
 
 #define ARRAY_SIZE(_x) (sizeof(_x) / sizeof((_x)[0]))
-- 
1.6.4.1


      parent reply	other threads:[~2009-09-21  8:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-21  8:55 [PATCH QEMU-KVM 0/7] test: more IPI tests Avi Kivity
2009-09-21  8:55 ` [PATCH QEMU-KVM 1/7] test: issue EOI after IPI Avi Kivity
2009-09-21  8:55 ` [PATCH QEMU-KVM 2/7] test: set up per-cpu area Avi Kivity
2009-09-21  8:55 ` [PATCH QEMU-KVM 3/7] test: optimize smp_id() Avi Kivity
2009-09-21  8:55 ` [PATCH QEMU-KVM 4/7] test: add conditional execution for vmexit tests Avi Kivity
2009-09-21  8:55 ` [PATCH QEMU-KVM 5/7] test: add ipi latency test Avi Kivity
2009-09-21  8:55 ` [PATCH QEMU-KVM 6/7] test: Add ipi_halt benchmark Avi Kivity
2009-09-22  1:54   ` Marcelo Tosatti
2009-09-22  6:12     ` Avi Kivity
2009-09-21  8:55 ` Avi Kivity [this message]

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=1253523338-22784-8-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.