From patchwork Sun Sep 19 13:56:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 193702 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8JDuAeB029648 for ; Sun, 19 Sep 2010 13:56:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754477Ab0ISN4G (ORCPT ); Sun, 19 Sep 2010 09:56:06 -0400 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:49536 "EHLO TX2EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754230Ab0ISN4E (ORCPT ); Sun, 19 Sep 2010 09:56:04 -0400 Received: from mail119-tx2-R.bigfish.com (10.9.14.239) by TX2EHSOBE005.bigfish.com (10.9.40.25) with Microsoft SMTP Server id 8.1.340.0; Sun, 19 Sep 2010 13:56:03 +0000 Received: from mail119-tx2 (localhost.localdomain [127.0.0.1]) by mail119-tx2-R.bigfish.com (Postfix) with ESMTP id 89F2E1858350; Sun, 19 Sep 2010 13:56:03 +0000 (UTC) X-SpamScore: 1 X-BigFish: VS1(zzzz1202hzz8275bhz32i87h2a8h61h) X-Spam-TCS-SCL: 0:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail119-tx2 (localhost.localdomain [127.0.0.1]) by mail119-tx2 (MessageSwitch) id 1284904563168767_11267; Sun, 19 Sep 2010 13:56:03 +0000 (UTC) Received: from TX2EHSMHS017.bigfish.com (unknown [10.9.14.251]) by mail119-tx2.bigfish.com (Postfix) with ESMTP id 1C188182804E; Sun, 19 Sep 2010 13:56:03 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by TX2EHSMHS017.bigfish.com (10.9.99.117) with Microsoft SMTP Server (TLS) id 14.0.482.44; Sun, 19 Sep 2010 13:56:03 +0000 Received: from ausb3twp01.amd.com (ausb3twp01.amd.com [163.181.250.37]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o8JDx6jE022089; Sun, 19 Sep 2010 08:59:09 -0500 X-WSS-ID: 0L8ZYP6-01-0L4-02 X-M-MSG: Received: from sausexhtp01.amd.com (sausexhtp01.amd.com [163.181.3.165]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp01.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 220A3102881C; Sun, 19 Sep 2010 08:55:54 -0500 (CDT) Received: from storexhtp01.amd.com (172.24.4.3) by sausexhtp01.amd.com (163.181.3.165) with Microsoft SMTP Server (TLS) id 8.3.83.0; Sun, 19 Sep 2010 08:55:57 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.3.83.0; Sun, 19 Sep 2010 09:55:56 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 2824C49C113; Sun, 19 Sep 2010 14:55:56 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 346669FFC5; Sun, 19 Sep 2010 15:57:07 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: , Alexander Graf , Joerg Roedel Subject: [PATCH 2/2] svm: Add VMLOAD/VMSAVE latency test Date: Sun, 19 Sep 2010 15:56:51 +0200 Message-ID: <1284904611-2458-3-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1284904611-2458-1-git-send-email-joerg.roedel@amd.com> References: <1284904611-2458-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 19 Sep 2010 13:56:11 +0000 (UTC) diff --git a/x86/svm.c b/x86/svm.c index babd77d..26bf566 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -19,10 +19,15 @@ u64 tsc_start; u64 tsc_end; u64 vmrun_sum, vmexit_sum; +u64 vmsave_sum, vmload_sum; u64 latvmrun_max; u64 latvmrun_min; u64 latvmexit_max; u64 latvmexit_min; +u64 latvmload_max; +u64 latvmload_min; +u64 latvmsave_max; +u64 latvmsave_min; u64 runs; static bool npt_supported(void) @@ -661,6 +666,51 @@ static bool latency_check(struct test *test) return true; } +static void load_save_prepare(struct test *test) +{ + default_prepare(test); + runs = LATENCY_RUNS; + latvmload_min = latvmsave_min = -1ULL; + latvmload_max = latvmsave_max = 0; + vmload_sum = vmsave_sum = 0; +} + +static bool load_save_finished(struct test *test) +{ + u64 vmcb_phys = virt_to_phys(test->vmcb); + u64 cycles; + + for ( ; runs != 0; runs--) { + tsc_start = rdtsc(); + asm volatile("vmload\n\t" : : "a"(vmcb_phys) : "memory"); + cycles = rdtsc() - tsc_start; + if (cycles > latvmload_max) + latvmload_max = cycles; + if (cycles < latvmload_min) + latvmload_min = cycles; + vmload_sum += cycles; + + tsc_start = rdtsc(); + asm volatile("vmsave\n\t" : : "a"(vmcb_phys) : "memory"); + cycles = rdtsc() - tsc_start; + if (cycles > latvmsave_max) + latvmsave_max = cycles; + if (cycles < latvmsave_min) + latvmsave_min = cycles; + vmsave_sum += cycles; + } + + return true; +} + +static bool load_save_check(struct test *test) +{ + printf(" Latency VMLOAD: max: %d min: %d avg: %d\n", latvmload_max, + latvmload_min, vmload_sum / LATENCY_RUNS); + printf(" Latency VMSAVE: max: %d min: %d avg: %d\n", latvmsave_max, + latvmsave_min, vmsave_sum / LATENCY_RUNS); + return true; +} static struct test tests[] = { { "null", default_supported, default_prepare, null_test, default_finished, null_check }, @@ -695,6 +745,8 @@ static struct test tests[] = { default_finished, npt_pfwalk_check }, { "latency_run_exit", default_supported, latency_prepare, latency_test, latency_finished, latency_check }, + { "latency_load_save", default_supported, load_save_prepare, null_test, + load_save_finished, load_save_check }, }; int main(int ac, char **av)