public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <daahern@cisco.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	kvm@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Subject: Re: [PATCH v2 00/11] KVM in-guest performance monitoring
Date: Thu, 16 Jun 2011 09:34:50 -0600	[thread overview]
Message-ID: <4DFA229A.1030004@cisco.com> (raw)
In-Reply-To: <1308238021.13240.84.camel@twins>

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 <stdlib.h>
> #include <stdio.h>
> #include <time.h>
> 
> 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%]
   <not supported> stalled-cycles-frontend
   <not supported> 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

  reply	other threads:[~2011-06-16 15:34 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 13:34 [PATCH v2 00/11] KVM in-guest performance monitoring Avi Kivity
2011-06-13 13:34 ` [PATCH v2 01/11] perf: add context field to perf_event Avi Kivity
2011-06-13 13:34 ` [PATCH v2 02/11] x86, perf: add constraints for architectural PMU v1 Avi Kivity
2011-06-13 13:34 ` [PATCH v2 03/11] perf: export perf_event_refresh() to modules Avi Kivity
2011-06-13 13:34 ` [PATCH v2 04/11] KVM: Expose kvm_lapic_local_deliver() Avi Kivity
2011-06-13 13:35 ` [PATCH v2 05/11] KVM: Expose a version 1 architectural PMU to guests Avi Kivity
2011-06-13 18:10   ` David Ahern
2011-06-14  8:33     ` Avi Kivity
2011-06-27 14:10   ` lidong chen
2011-06-27 14:13     ` Avi Kivity
2011-06-28  2:54       ` lidong chen
2011-06-28  8:15         ` Avi Kivity
2011-06-13 13:35 ` [PATCH v2 06/11] KVM: Add generic RDPMC support Avi Kivity
2011-06-13 13:35 ` [PATCH v2 07/11] KVM: SVM: Intercept RDPMC Avi Kivity
2011-06-13 13:35 ` [PATCH v2 08/11] KVM: VMX: " Avi Kivity
2011-06-13 16:17   ` David Ahern
2011-06-13 16:29     ` Avi Kivity
2011-06-13 16:59       ` David Ahern
2011-06-13 17:38         ` Ingo Molnar
2011-06-13 18:09           ` David Ahern
2011-06-14  8:34           ` Avi Kivity
2011-06-14  9:27             ` Ingo Molnar
2011-06-13 13:35 ` [PATCH v2 09/11] KVM: Expose the architectural performance monitoring CPUID leaf Avi Kivity
2011-06-13 13:35 ` [PATCH v2 10/11] KVM: x86 emulator: fix RDPMC privilege check Avi Kivity
2011-06-13 13:35 ` [PATCH v2 11/11] KVM: x86 emulator: implement RDPMC (0F 33) Avi Kivity
2011-06-13 19:55 ` [PATCH v2 00/11] KVM in-guest performance monitoring David Ahern
2011-06-14  8:36   ` Avi Kivity
2011-06-14 17:15     ` David Ahern
2011-06-14 17:24       ` Jan Kiszka
2011-06-14 17:33         ` David Ahern
2011-06-14 17:48           ` David Ahern
2011-06-14 18:11             ` David Ahern
2011-06-15  8:57               ` Avi Kivity
2011-06-15 12:40                 ` David Ahern
2011-06-15 13:22                   ` Avi Kivity
2011-06-15 16:08                     ` David Ahern
2011-06-15 16:27                       ` Avi Kivity
2011-06-15 16:51                         ` David Ahern
2011-06-16 13:53                           ` Avi Kivity
2011-06-16 14:08                             ` David Ahern
2011-06-16 14:19                               ` David Ahern
2011-06-16 14:20                                 ` Avi Kivity
2011-06-16 14:32                                   ` David Ahern
2011-06-16 14:36                                     ` Avi Kivity
2011-06-16 15:04                                       ` David Ahern
2011-06-16 15:08                               ` Peter Zijlstra
2011-06-16 15:18                                 ` David Ahern
2011-06-16 15:19                                 ` David Ahern
2011-06-16 15:27                                   ` Peter Zijlstra
2011-06-16 15:34                                     ` David Ahern [this message]
2011-06-16 15:59                                       ` Avi Kivity
2011-06-16 16:04                                         ` David Ahern
2011-06-16 16:31                                           ` Avi Kivity
2011-06-16 17:16                                             ` David Ahern
2011-06-29  7:52 ` Avi Kivity
2011-06-29  8:38   ` Peter Zijlstra
2011-06-29  9:26     ` 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=4DFA229A.1030004@cisco.com \
    --to=daahern@cisco.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox