From patchwork Mon Sep 21 08:55:38 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 49013 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8L8trnH027919 for ; Mon, 21 Sep 2009 08:55:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755502AbZIUIzr (ORCPT ); Mon, 21 Sep 2009 04:55:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755443AbZIUIzq (ORCPT ); Mon, 21 Sep 2009 04:55:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48499 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755463AbZIUIzk (ORCPT ); Mon, 21 Sep 2009 04:55:40 -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 n8L8thHi023250 for ; Mon, 21 Sep 2009 04:55:43 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8L8tf1m011851; Mon, 21 Sep 2009 04:55:42 -0400 Received: from localhost.localdomain (cleopatra.tlv.redhat.com [10.35.255.11]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 181E1250054; Mon, 21 Sep 2009 11:55:39 +0300 (IDT) From: Avi Kivity To: kvm@vger.kernel.org Cc: Marcelo Tosatti Subject: [PATCH QEMU-KVM 7/7] test: Auto-tune vmexit test Date: Mon, 21 Sep 2009 11:55:38 +0300 Message-Id: <1253523338-22784-8-git-send-email-avi@redhat.com> In-Reply-To: <1253523338-22784-1-git-send-email-avi@redhat.com> References: <1253523338-22784-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Scale up iterations until we measure at least 1G cycles. Signed-off-by: Avi Kivity --- 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]))