From: Dong Hao <haodong@linux.vnet.ibm.com>
To: avi@redhat.com, acme@infradead.org
Cc: mtosatti@redhat.com, mingo@elte.hu, dsahern@gmail.com,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Subject: [PATCH v6 0/3] KVM: perf: kvm events analysis tool
Date: Fri, 10 Aug 2012 11:19:07 +0800 [thread overview]
Message-ID: <1344568750-5147-1-git-send-email-haodong@linux.vnet.ibm.com> (raw)
From: Xiao Guangrong<xiaoguangrong@linux.vnet.ibm.com>
This patchset introduces a perf-based tool (perf kvm stat record/report)
which can analysis kvm events more smartly. This is a presentation on
2012 Japan LinuxCon:
http://events.linuxfoundation.org/images/stories/pdf/lcjp2012_guangrong.pdf
You can get more detail from it. Any question/comment please feel free let
us know.
Patch 1 and patch 3 can be applied to either tip tree or kvm tree, but patch 2
can only be applied to kvm tree. Fortunately, patch 2 is just doing the
"improvement" work, and it can be picked up independently.
Usage:
- kvm stat
run a command and gather performance counter statistics, it is the alias of
perf stat
- trace kvm events:
perf kvm stat record, or, if other tracepoints are interesting as well, we
can append the events like this:
perf kvm stat record -e timer:*
If many guests are running, we can track the specified guest by using -p or
--pid
- show the result:
perf kvm stat report
The output example is following:
# pgrep qemu-kvm
27841
27888
27936
total 3 guests are running on the host
Then, track the guest whose pid is 27936:
# ./perf kvm stat record -p 27936
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.177 MB perf.data.guest (~7742 samples) ]
See the vmexit events:
# ./perf kvm stat report --event=vmexit
Analyze events for all VCPUs:
VM-EXIT Samples Samples% Time% Avg time
APIC_ACCESS 237 80.34% 0.01% 20.86us ( +- 8.03% )
HLT 45 15.25% 99.98% 790874.75us ( +- 16.93% )
EXTERNAL_INTERRUPT 11 3.73% 0.00% 47.70us ( +- 17.45% )
EXCEPTION_NMI 1 0.34% 0.00% 5.11us ( +- -nan% )
CR_ACCESS 1 0.34% 0.00% 6.33us ( +- -nan% )
Total Samples:295, Total events handled time:35594844.34us.
See the mmio events:
# ./perf kvm stat report --event=mmio
Analyze events for all VCPUs:
MMIO Access Samples Samples% Time% Avg time
0xfee00380:W 151 82.07% 76.19% 7.72us ( +- 11.96% )
0xfee00300:W 11 5.98% 18.86% 26.23us ( +- 27.33% )
0xfee00300:R 11 5.98% 2.16% 3.00us ( +- 9.17% )
0xfee00310:W 11 5.98% 2.79% 3.88us ( +- 9.15% )
Total Samples:184, Total events handled time:1529.42us.
See the ioport event:
# ./perf kvm stat report --event=ioport
Analyze events for all VCPUs:
IO Port Access Samples Samples% Time% Avg time
0x5658:PIN 3357 55.22% 92.13% 162.31us ( +- 0.87% )
0xc090:POUT 1221 20.09% 2.10% 10.18us ( +- 4.97% )
0x60:PIN 748 12.30% 3.18% 25.17us ( +- 5.01% )
0x64:PIN 748 12.30% 2.57% 20.35us ( +- 11.81% )
0xc050:POUT 5 0.08% 0.01% 8.79us ( +- 12.88% )
Total Samples:6079, Total events handled time:591405.43us.
And, --vcpu is used to track the specified vcpu and --key is used to sort the
result:
# ./perf kvm stat report --event=ioport --vcpu=0 --key=time
Analyze events for VCPU 0:
IO Port Access Samples Samples% Time% Avg time
0x5658:PIN 145 94.77% 99.67% 133.00us ( +- 2.96% )
0xc090:POUT 8 5.23% 0.33% 7.99us ( +- 16.85% )
Total Samples:153, Total events handled time:19348.87us.
Changelog:
- merge "perf kvm-events" into perf "perf kvm stat" as Ingo's suggestion
- track kvm events for the specified guest
- rename kvm_mmio_done to kvm_io_done
- fix compiling-error on i386
Dong Hao (3):
KVM: x86: export svm/vmx exit code and vector code to userspace
KVM: x86: tracemmio begin and complete
KVM: perf kvm events analysis tool
arch/x86/include/asm/kvm_host.h | 36 +-
arch/x86/include/asm/svm.h | 205 +++++---
arch/x86/include/asm/vmx.h | 126 ++++--
arch/x86/kvm/trace.h | 89 ----
arch/x86/kvm/x86.c | 32 +-
include/trace/events/kvm.h | 37 ++
tools/perf/Documentation/perf-kvm.txt | 30 ++-
tools/perf/MANIFEST | 3 +
tools/perf/builtin-kvm.c | 858 ++++++++++++++++++++++++++++++++-
tools/perf/util/header.c | 55 ++-
tools/perf/util/header.h | 1 +
tools/perf/util/thread.h | 2 +
12 files changed, 1234 insertions(+), 240 deletions(-)
--
1.7.2.5
next reply other threads:[~2012-08-10 3:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 3:19 Dong Hao [this message]
2012-08-10 3:19 ` [PATCH v6 1/3] KVM: x86: export svm/vmx exit code and vector code to userspace Dong Hao
2012-08-10 3:19 ` [PATCH v6 2/3] KVM: x86: tracemmio begin and complete Dong Hao
2012-08-10 3:19 ` [PATCH v6 3/3] KVM: perf kvm events analysis tool Dong Hao
2012-08-10 14:14 ` Arnaldo Carvalho de Melo
2012-08-14 2:08 ` Xiao Guangrong
2012-08-10 20:37 ` David Ahern
2012-08-14 2:12 ` Xiao Guangrong
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=1344568750-5147-1-git-send-email-haodong@linux.vnet.ibm.com \
--to=haodong@linux.vnet.ibm.com \
--cc=acme@infradead.org \
--cc=avi@redhat.com \
--cc=dsahern@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).