From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH v2 00/11] KVM in-guest performance monitoring Date: Thu, 16 Jun 2011 09:34:50 -0600 Message-ID: <4DFA229A.1030004@cisco.com> References: <1307972106-2468-1-git-send-email-avi@redhat.com> <4DF66B1A.6060606@cisco.com> <4DF71DA3.2080300@redhat.com> <4DF7972F.3040103@cisco.com> <4DF79941.9050705@siemens.com> <4DF79B6F.10102@cisco.com> <4DF79EFE.1050201@cisco.com> <4DF7A436.8090308@cisco.com> <4DF873FD.6040903@redhat.com> <4DF8A82F.5090900@cisco.com> <4DF8B1F8.6030502@redhat.com> <4DF8D8FE.2080808@cisco.com> <4DF8DD87.8040905@redhat.com> <4DF8E328.6070708@cisco.com> <4DFA0AC4.9050702@redhat.com> <4DFA0E56.70301@cisco.com> <1308236915.13240.66.camel@twins> <4DFA1F18.4090903@cisco.com> <1308238021.13240.84.camel@twins> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Marcelo Tosatti , kvm@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo To: Peter Zijlstra Return-path: Received: from sj-iport-6.cisco.com ([171.71.176.117]:1347 "EHLO sj-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756710Ab1FPPey (ORCPT ); Thu, 16 Jun 2011 11:34:54 -0400 In-Reply-To: <1308238021.13240.84.camel@twins> Sender: kvm-owner@vger.kernel.org List-ID: On 06/16/2011 09:27 AM, Peter Zijlstra wrote: > Sure, I've got a couple of those things lying around: > > # perf stat -e instructions:u ./loop_1b_instructions-4x > > Performance counter stats for './loop_1b_instructions-4x': > > 4,000,085,344 instructions:u # 0.00 insns per cycle > > 0.311861278 seconds time elapsed > > --- > > #include > #include > #include > > main () > { > int i; > > fork(); > fork(); > > for (i = 0; i < 100000000; i++) { > asm("nop"); > asm("nop"); > asm("nop"); > asm("nop"); > asm("nop"); > asm("nop"); > asm("nop"); > } > wait(NULL); > wait(NULL); > wait(NULL); > wait(NULL); > } > That's the one. Guest: perf stat -e instructions:u /tmp/a.out Performance counter stats for '/tmp/a.out': 4,000,090,357 instructions:u # 0.00 insns per cycle 2.972828828 seconds time elapsed Host: perf stat -e instructions:u /tmp/a.out Performance counter stats for '/tmp/a.out': 4,000,083,592 instructions:u # 0.00 insns per cycle 0.278185315 seconds time elapsed So the counting is correct, but the time to run the command is significantly longer in the guest. That emphasizes the performance overhead of running perf-stat in the VM. Even the default counters for perf-stat are similar, showing correctness in counting: Guest: perf stat ./a.out Performance counter stats for './a.out': 2707.156752 task-clock # 0.996 CPUs utilized 337 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 209 page-faults # 0.000 M/sec 3,103,481,148 cycles # 1.146 GHz [50.25%] stalled-cycles-frontend stalled-cycles-backend 3,999,894,345 instructions # 1.29 insns per cycle [50.03%] 406,716,307 branches # 150.237 M/sec [49.85%] 270,801 branch-misses # 0.07% of all branches [50.02%] 2.717859741 seconds time elapsed Host: perf stat /tmp/a.out Performance counter stats for '/tmp/a.out': 1117.694687 task-clock # 3.845 CPUs utilized 140 context-switches # 0.000 M/sec 3 CPU-migrations # 0.000 M/sec 203 page-faults # 0.000 M/sec 3,052,677,262 cycles # 2.731 GHz 1,449,951,708 stalled-cycles-frontend # 47.50% frontend cycles idle 471,788,212 stalled-cycles-backend # 15.45% backend cycles idle 4,006,074,559 instructions # 1.31 insns per cycle # 0.36 stalled cycles per insn 401,265,264 branches # 359.012 M/sec 29,376 branch-misses # 0.01% of all branches 0.290722796 seconds time elapsed David