linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] KVM: perf: a smart tool to analyse kvm events
@ 2012-01-16  9:30 Xiao Guangrong
  2012-01-16  9:31 ` [PATCH 1/3] KVM: trace mmio read event properly Xiao Guangrong
                   ` (4 more replies)
  0 siblings, 5 replies; 40+ messages in thread
From: Xiao Guangrong @ 2012-01-16  9:30 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, LKML, KVM

This tool is very like xenoprof(if i remember correctly), and traces kvm events
smartly. currently, it supports vmexit/mmio/ioport events.

Usage:
- to trace kvm events:
# ./perf kvm-events record

- show the result
# ./perf kvm-events report

Some output are as follow:
# ./perf kvm-events report
  Warning: Error: expected type 5 but read 4
  Warning: Error: expected type 5 but read 0
  Warning: unknown op '}'


Analyze events for all VCPUs:

             VM-EXIT    Samples      Samples%         Time%        Avg time

         APIC_ACCESS     438107        44.89%         6.20%        17.91us
  EXTERNAL_INTERRUPT     219226        22.46%         8.01%        46.20us
      IO_INSTRUCTION     122651        12.57%         1.88%        19.44us
       EPT_VIOLATION      83110         8.52%         1.36%        20.75us
   PENDING_INTERRUPT      37055         3.80%         0.16%         5.38us
               CPUID      32718         3.35%         0.08%         3.15us
       EXCEPTION_NMI      23601         2.42%         0.17%         8.87us
                 HLT      15424         1.58%        82.12%      6735.06us
           CR_ACCESS       4089         0.42%         0.02%         6.08us

Total Samples:975981, Total events handled time:126502464.88us.

The default event to be analysed is vmexit, we can use --event to specify it,
for example, if we want to trace mmio event:
# ./perf kvm-events report --event mmio
  Warning: Error: expected type 5 but read 4
  Warning: Error: expected type 5 but read 0
  Warning: unknown op '}'


Analyze events for all VCPUs:

         MMIO Access    Samples      Samples%         Time%        Avg time

        0xfee00380:W     196589        64.95%        70.01%         3.83us
        0xfee00310:W      35356        11.68%         6.48%         1.97us
        0xfee00300:W      35356        11.68%        16.37%         4.97us
        0xfee00300:R      35356        11.68%         7.14%         2.17us

Total Samples:302657, Total events handled time:1074746.01us.

We can use --vcpu to specify which vcpu is traced:
root@localhost perf]# ./perf kvm-events report --event mmio --vcpu 1
  Warning: Error: expected type 5 but read 4
  Warning: Error: expected type 5 but read 0
  Warning: unknown op '}'


Analyze events for VCPU 1:

         MMIO Access    Samples      Samples%         Time%        Avg time

        0xfee00380:W      58041        71.20%        74.90%         3.70us
        0xfee00310:W       7826         9.60%         5.28%         1.93us
        0xfee00300:W       7826         9.60%        13.82%         5.06us
        0xfee00300:R       7826         9.60%         6.01%         2.20us

Total Samples:81519, Total events handled time:286577.81us.

And, '--key' is used to sort the result, the possible value sample (default,
the result is sorted by samples number), time(the result is sorted by time%):
# ./perf kvm-events report --key time
  Warning: Error: expected type 5 but read 4
  Warning: Error: expected type 5 but read 0
  Warning: unknown op '}'


Analyze events for all VCPUs:

             VM-EXIT    Samples      Samples%         Time%        Avg time

                 HLT      15424         1.58%        82.12%      6735.06us
  EXTERNAL_INTERRUPT     219226        22.46%         8.01%        46.20us
         APIC_ACCESS     438107        44.89%         6.20%        17.91us
      IO_INSTRUCTION     122651        12.57%         1.88%        19.44us
       EPT_VIOLATION      83110         8.52%         1.36%        20.75us
       EXCEPTION_NMI      23601         2.42%         0.17%         8.87us
   PENDING_INTERRUPT      37055         3.80%         0.16%         5.38us
               CPUID      32718         3.35%         0.08%         3.15us
           CR_ACCESS       4089         0.42%         0.02%         6.08us

Total Samples:975981, Total events handled time:126502464.88us.

I hope guys will like it and any comments are welcome! :)


^ permalink raw reply	[flat|nested] 40+ messages in thread
* [PATCH v4 0/3] KVM: perf: kvm events analysis tool
@ 2012-02-09  9:06 Xiao Guangrong
  2012-02-09  9:09 ` [PATCH 3/3] " Xiao Guangrong
  0 siblings, 1 reply; 40+ messages in thread
From: Xiao Guangrong @ 2012-02-09  9:06 UTC (permalink / raw)
  To: Avi Kivity
  Cc: Marcelo Tosatti, Ingo Molnar, Arnaldo Carvalho de Melo,
	David Ahern, LKML, KVM

Changlog:
There are some changes from David Ahern's review:
- let the tool to be off-box analysis by getting cpu isa
  from HEADER_CPUID feature and removing max-vcpu related code.

- attach per vcpu record structure to the thread by adding a void pointer
  in "struct thread".

- remove unnecessary tool argument(-v).

The output example is following:
# ./perf kvm-events report --event mmio --vcpu 3
  Warning: Error: expected type 5 but read 4
  Warning: Error: expected type 5 but read 0
  Warning: unknown op '}'


Analyze events for VCPU 3:

         MMIO Access    Samples  Samples%     Time%         Avg time

        0xfee00380:W      45534    78.00%    84.76%      5.27us ( +-   0.77% )
        0xfee00300:W       4280     7.33%     9.37%      6.20us ( +-   1.91% )
        0xfee00300:R       4280     7.33%     3.34%      2.21us ( +-   1.53% )
        0xfee00310:W       4280     7.33%     2.52%      1.67us ( +-   0.71% )

Total Samples:58374, Total events handled time:283257.68us.


^ permalink raw reply	[flat|nested] 40+ messages in thread
* Re: [PATCH 3/3] KVM: perf: kvm events analysis tool
@ 2012-02-13  5:32 David Ahern
  2012-02-13 10:06 ` Xiao Guangrong
  0 siblings, 1 reply; 40+ messages in thread
From: David Ahern @ 2012-02-13  5:32 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: Avi Kivity, Marcelo Tosatti, Ingo Molnar,
	Arnaldo Carvalho de Melo, LKML, KVM

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 2863 bytes --]

[sorry for the top post - you would think Android would have a better mail client]

If the first patch is needed then kvm-events will not work with older, unpatched kernels. That's a big limitation from a perf perpective.

David

Sent from my ASUS Eee Pad

Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> wrote:

>On 02/13/2012 11:04 AM, David Ahern wrote:
>
>> Compile fails on Fedora 16, x86_64 with latest tip-perf-core branch:
>> 
>> 
>> In file included from builtin-kvm-events.c:19:0:
>> ../../arch/x86/include/asm/svm.h:133:1: error: packed attribute is
>> unnecessary for ‘vmcb_seg’ [-Werror=packed]
>> ../../arch/x86/include/asm/svm.h:178:1: error: packed attribute is
>> unnecessary for ‘vmcb_save_area’ [-Werror=packed]
>> ../../arch/x86/include/asm/svm.h:183:1: error: packed attribute is
>> unnecessary for ‘vmcb’ [-Werror=packed]
>> In file included from builtin-kvm-events.c:20:0:
>> ../../arch/x86/include/asm/vmx.h:334:0: error: "REG_R8" redefined [-Werror]
>> /usr/include/sys/ucontext.h:46:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:335:0: error: "REG_R9" redefined [-Werror]
>> /usr/include/sys/ucontext.h:48:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:336:0: error: "REG_R10" redefined [-Werror]
>> /usr/include/sys/ucontext.h:50:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:337:0: error: "REG_R11" redefined [-Werror]
>> /usr/include/sys/ucontext.h:52:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:338:0: error: "REG_R12" redefined [-Werror]
>> /usr/include/sys/ucontext.h:54:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:339:0: error: "REG_R13" redefined [-Werror]
>> /usr/include/sys/ucontext.h:56:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:340:0: error: "REG_R14" redefined [-Werror]
>> /usr/include/sys/ucontext.h:58:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:341:0: error: "REG_R15" redefined [-Werror]
>> /usr/include/sys/ucontext.h:60:0: note: this is the location of the
>> previous definition
>> ../../arch/x86/include/asm/vmx.h:443:13: error: expected declaration
>> specifiers or ‘...’ before numeric constant
>> In file included from builtin-kvm-events.c:21:0:
>> ../../arch/x86/include/asm/kvm_host.h:15:22: fatal error: linux/mm.h: No
>> such file or directory
>> cc1: all warnings being treated as errors
>> 
>
>
>The first patch(patch 1/3) should be applied!
>
>Thank you, David! :)
>
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 40+ messages in thread
* [PATCH v5 0/3] KVM: perf: kvm events analysis tool
@ 2012-03-06  8:55 Xiao Guangrong
  2012-03-06  8:58 ` [PATCH 3/3] " Xiao Guangrong
  0 siblings, 1 reply; 40+ messages in thread
From: Xiao Guangrong @ 2012-03-06  8:55 UTC (permalink / raw)
  To: Avi Kivity, Arnaldo Carvalho de Melo
  Cc: Marcelo Tosatti, Ingo Molnar, David Ahern, LKML, KVM

Changlong:

Thanks to David's review, there are some changes:
- add kvm-events compile-depend files to tools/perf/MANIFEST

- fix some typos and little clean up

- rebase it on -tip tree

The output example is following:

#./perf kvm-events report --event mmio --vcpu 3


Analyze events for VCPU 3:

         MMIO Access    Samples  Samples%     Time%         Avg time

        0xfee00380:W      29688    61.16%    64.52%      3.37us ( +-   0.86% )
        0xfee00300:W       6285    12.95%    20.06%      4.95us ( +-   2.34% )
        0xfee00300:R       6285    12.95%     8.08%      1.99us ( +-   0.59% )
        0xfee00310:W       6285    12.95%     7.34%      1.81us ( +-   6.76% )

Total Samples:48543, Total events handled time:155156.31us.


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2012-03-06  8:59 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-16  9:30 [RFC][PATCH] KVM: perf: a smart tool to analyse kvm events Xiao Guangrong
2012-01-16  9:31 ` [PATCH 1/3] KVM: trace mmio read event properly Xiao Guangrong
2012-01-16 10:18   ` Avi Kivity
2012-01-17  2:36     ` Xiao Guangrong
2012-01-16  9:32 ` [PATCH 2/3] KVM: improve trace events of vmexit/mmio/ioport Xiao Guangrong
2012-01-16  9:38   ` Avi Kivity
2012-01-17  2:28     ` Xiao Guangrong
2012-01-17 11:55       ` Marcelo Tosatti
2012-01-17 17:31         ` David Ahern
2012-01-18  2:32           ` Xiao Guangrong
2012-01-18  5:34             ` David Ahern
2012-01-24 12:44       ` Avi Kivity
2012-01-16  9:32 ` [PATCH 3/3] KVM: perf: kvm events analysis tool Xiao Guangrong
2012-01-16 10:04   ` Avi Kivity
2012-01-17  2:30     ` Xiao Guangrong
2012-01-24 12:49       ` Avi Kivity
2012-01-16 10:08   ` Stefan Hajnoczi
2012-01-17  2:37     ` Xiao Guangrong
2012-01-17 11:59     ` Marcelo Tosatti
2012-01-24 12:51       ` Avi Kivity
2012-01-16 10:11 ` [RFC][PATCH] KVM: perf: a smart tool to analyse kvm events Avi Kivity
2012-01-17  2:30   ` Xiao Guangrong
2012-01-16 22:53 ` David Ahern
2012-01-17  2:41   ` Xiao Guangrong
2012-01-17  4:49     ` David Ahern
2012-02-09  9:06 [PATCH v4 0/3] KVM: perf: kvm events analysis tool Xiao Guangrong
2012-02-09  9:09 ` [PATCH 3/3] " Xiao Guangrong
2012-02-13  3:04   ` David Ahern
2012-02-13  5:00     ` Xiao Guangrong
2012-02-20 23:47   ` David Ahern
2012-02-21  3:52     ` Xiao Guangrong
2012-02-21  4:58       ` David Ahern
2012-02-27  4:57     ` Xiao Guangrong
2012-02-13  5:32 David Ahern
2012-02-13 10:06 ` Xiao Guangrong
2012-02-13 15:52   ` David Ahern
2012-02-16  4:59     ` Xiao Guangrong
2012-02-16  5:05       ` David Ahern
2012-02-16  5:33         ` Xiao Guangrong
2012-02-16 16:35         ` Arnaldo Carvalho de Melo
2012-03-06  8:55 [PATCH v5 0/3] " Xiao Guangrong
2012-03-06  8:58 ` [PATCH 3/3] " Xiao Guangrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).