linux/tools/perf/util
Xiao Guangrong bcf6edcd6f perf kvm: Events analysis tool
Add 'perf kvm stat' support to analyze kvm vmexit/mmio/ioport smartly

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:* -a

  If many guests are running, we can track the specified guest by using -p or
  --pid, -a is used to track events generated by all guests.

- show the result:
  perf kvm stat report

The output example is following:
13005
13059

total 2 guests are running on the host

Then, track the guest whose pid is 13059:
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.253 MB perf.data.guest (~11065 samples) ]

See the vmexit events:

Analyze events for all VCPUs:

             VM-EXIT    Samples  Samples%     Time%         Avg time

         APIC_ACCESS        460    70.55%     0.01%     22.44us ( +-   1.75% )
                 HLT         93    14.26%    99.98% 832077.26us ( +-  10.42% )
  EXTERNAL_INTERRUPT         64     9.82%     0.00%     35.35us ( +-  14.21% )
   PENDING_INTERRUPT         24     3.68%     0.00%      9.29us ( +-  31.39% )
           CR_ACCESS          7     1.07%     0.00%      8.12us ( +-   5.76% )
      IO_INSTRUCTION          3     0.46%     0.00%     18.00us ( +-  11.79% )
       EXCEPTION_NMI          1     0.15%     0.00%      5.83us ( +-   -nan% )

Total Samples:652, Total events handled time:77396109.80us.

See the mmio events:

Analyze events for all VCPUs:

         MMIO Access    Samples  Samples%     Time%         Avg time

        0xfee00380:W        387    84.31%    79.28%      8.29us ( +-   3.32% )
        0xfee00300:W         24     5.23%     9.96%     16.79us ( +-   1.97% )
        0xfee00300:R         24     5.23%     7.83%     13.20us ( +-   3.00% )
        0xfee00310:W         24     5.23%     2.93%      4.94us ( +-   3.84% )

Total Samples:459, Total events handled time:4044.59us.

See the ioport event:

Analyze events for all VCPUs:

      IO Port Access    Samples  Samples%     Time%         Avg time

         0xc050:POUT          3   100.00%   100.00%     13.75us ( +-  10.83% )

Total Samples:3, Total events handled time:41.26us.

And, --vcpu is used to track the specified vcpu and --key is used to sort the
result:

Analyze events for VCPU 0:

             VM-EXIT    Samples  Samples%     Time%         Avg time

                 HLT         27    13.85%    99.97% 405790.24us ( +-  12.70% )
  EXTERNAL_INTERRUPT         13     6.67%     0.00%     27.94us ( +-  22.26% )
         APIC_ACCESS        146    74.87%     0.03%     21.69us ( +-   2.91% )
      IO_INSTRUCTION          2     1.03%     0.00%     17.77us ( +-  20.56% )
           CR_ACCESS          2     1.03%     0.00%      8.55us ( +-   6.47% )
   PENDING_INTERRUPT          5     2.56%     0.00%      6.27us ( +-   3.94% )

Total Samples:195, Total events handled time:10959950.90us.

Signed-off-by: Dong Hao <haodong@linux.vnet.ibm.com>
Signed-off-by: Runzhen Wang <runzhen@linux.vnet.ibm.com>
[ Dong Hao <haodong@linux.vnet.ibm.com>
  Runzhen Wang <runzhen@linux.vnet.ibm.com>:
     - rebase it on current acme's tree
     - fix the compiling-error on i386 ]
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Runzhen Wang <runzhen@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1347870675-31495-4-git-send-email-haodong@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-09-21 12:51:22 -03:00
..
include perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
scripting-engines perf tools: Fix a compiling error in trace-event-perl.c for 32 bits machine 2012-09-20 08:30:21 -03:00
abspath.c
alias.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
annotate.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
annotate.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
bitmap.c perf tools: Add bitmap_or function into bitmap object 2012-02-13 23:28:10 -02:00
build-id.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
build-id.h perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
cache.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
callchain.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
callchain.h perf callchain: Make callchain cursors TLS 2012-05-31 10:47:12 -03:00
cgroup.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
cgroup.h perf tool: Add cgroup support 2011-02-16 13:30:48 +01:00
color.c perf tools: Use scnprintf where applicable 2012-03-14 12:36:19 -03:00
color.h
config.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
cpumap.c perf stat: Check PMU cpumask file 2012-09-17 13:12:02 -03:00
cpumap.h perf stat: Check PMU cpumask file 2012-09-17 13:12:02 -03:00
ctype.c perf tools: ctype.c only wants util.h 2012-02-13 23:17:40 -02:00
debug.c perf ui gtk: Add perf_gtk__show_helpline() for pr_* 2012-08-17 12:37:56 -03:00
debug.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
debugfs.c perf tools: Remove unused functions from debugfs object 2012-02-13 23:25:38 -02:00
debugfs.h perf tools: Remove unused functions from debugfs object 2012-02-13 23:25:38 -02:00
dso-test-data.c perf tools: replace mkostemp with mkstemp 2012-09-07 22:10:44 -03:00
dwarf-aux.c perf probe: Filter out redundant inline-instances 2011-08-12 09:34:35 -03:00
dwarf-aux.h perf probe: Search concrete out-of-line instances 2011-08-12 09:32:10 -03:00
environment.c
event.c perf symbols: Filter samples with unresolved symbol when "--symbols" option is used 2012-09-17 13:10:57 -03:00
event.h perf tools: fix ALIGN redefinition in system headers 2012-09-11 11:48:30 -03:00
evlist.c perf evlist: Add fprintf method 2012-09-06 14:54:11 -03:00
evlist.h perf evlist: Add fprintf method 2012-09-06 14:54:11 -03:00
evsel.c perf evsel: Introduce perf_evsel__{str,int}val methods 2012-09-11 19:24:23 -03:00
evsel.h perf stat: Check PMU cpumask file 2012-09-17 13:12:02 -03:00
exec_cmd.c perf tools: Makefile: Remove various and sundry cruft 2011-02-18 07:43:06 -02:00
exec_cmd.h
generate-cmdlist.sh perf symbols: Support minimal build without libelf 2012-08-09 16:26:38 -03:00
header.c perf kvm: Events analysis tool 2012-09-21 12:51:22 -03:00
header.h perf kvm: Events analysis tool 2012-09-21 12:51:22 -03:00
help.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
help.h
hist.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
hist.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
hweight.c
intlist.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
intlist.h perf tools: Introduce intlist 2012-08-03 10:42:25 -03:00
levenshtein.c
levenshtein.h
map.c perf tools: Fix a compiling error in util/map.c 2012-09-20 08:36:34 -03:00
map.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
pager.c perf tools: Fix pager on minimal-install embedded systems 2012-05-30 15:10:39 -03:00
parse-events-test.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
parse-events.c perf stat: Check PMU cpumask file 2012-09-17 13:12:02 -03:00
parse-events.h perf tools: Catch event names from command line 2012-08-22 13:40:49 -03:00
parse-events.l perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
parse-events.y perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
parse-options.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
parse-options.h
path.c
PERF-VERSION-GEN perf tools: Make --version show kernel version instead of pull req tag 2012-05-31 11:20:59 -03:00
perf_regs.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
pmu.c perf stat: Check PMU cpumask file 2012-09-17 13:12:02 -03:00
pmu.h perf stat: Check PMU cpumask file 2012-09-17 13:12:02 -03:00
pmu.l perf tools: Add perf pmu object to access pmu format definition 2012-03-16 14:29:35 -03:00
pmu.y perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
probe-event.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
probe-event.h perf probe: Provide perf interface for uprobes 2012-05-11 13:58:17 -03:00
probe-finder.c perf probe: Add union member access support 2012-09-14 15:48:08 -03:00
probe-finder.h perf tools: Eliminate duplicate code and use PATH_MAX consistently 2011-11-28 10:11:04 -02:00
pstack.c
pstack.h
python-ext-sources perf tools: Add missing files to build the python binding 2012-08-14 14:17:30 -03:00
python.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
quote.c
quote.h
rblist.c perf tools: Introducing rblist 2012-08-03 10:37:21 -03:00
rblist.h perf tools: Introducing rblist 2012-08-03 10:37:21 -03:00
run-command.c
run-command.h
session.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
session.h perf diff: Make diff command work with evsel hists 2012-09-07 21:44:02 -03:00
setup.py perf tools: Fix build dependency of perf python extension 2012-02-13 18:01:25 -02:00
sigchain.c
sigchain.h
sort.c perf tools: Add sort__has_sym 2012-09-17 13:08:59 -03:00
sort.h perf tools: Add sort__has_sym 2012-09-17 13:08:59 -03:00
stat.c perf stat: Move stats related code to util/stat.c 2012-09-17 13:10:03 -03:00
stat.h perf stat: Move stats related code to util/stat.c 2012-09-17 13:10:03 -03:00
strbuf.c perf tools: Use scnprintf where applicable 2012-03-14 12:36:19 -03:00
strbuf.h
strfilter.c perf: Fix missing strndup declaration 2011-03-04 01:17:18 +01:00
strfilter.h perf tools: Add strfilter for general purpose string filter 2011-01-28 09:19:38 -02:00
string.c perf tools: Add memdup function 2012-09-11 12:04:41 -03:00
strlist.c perf tools: Remove the node from rblist in strlist__remove 2012-09-05 17:36:42 -03:00
strlist.h perf tools: Change strlist to use the new rblist 2012-08-03 10:39:51 -03:00
svghelper.c perf timechart: Fix black idle boxes in the title 2011-02-28 08:56:14 +01:00
svghelper.h
symbol-elf.c perf symbols: Fix builds with NO_LIBELF set 2012-08-20 09:35:22 -03:00
symbol-minimal.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
symbol.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
symbol.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
sysfs.c perf tools: Add sysfs mountpoint interface 2012-02-13 23:27:15 -02:00
sysfs.h perf tools: Add sysfs mountpoint interface 2012-02-13 23:27:15 -02:00
target.c perf tools: Replace mempcpy with memcpy 2012-09-05 19:35:21 -03:00
target.h perf target: Add uses_mmap field 2012-05-17 12:32:54 -03:00
thread.c perf session: Move threads to struct machine 2011-11-28 10:35:31 -02:00
thread.h perf kvm: Events analysis tool 2012-09-21 12:51:22 -03:00
thread_map.c perf tools: fix thread_map__new_by_pid_str() memory leak in error path 2012-05-25 11:40:59 -03:00
thread_map.h perf tools: Fix thread map that is type pid_t 2012-04-11 17:38:50 -03:00
tool.h perf tools: Save some loops using perf_evlist__id2evsel 2011-11-28 17:57:40 -02:00
top.c perf evlist: Introduce evsel list accessors 2012-08-15 10:14:18 -03:00
top.h perf tools: fix missing winsize definition 2012-09-07 22:07:32 -03:00
trace-event-info.c perf: Have perf use the new libtraceevent.a library 2012-04-25 13:28:48 +02:00
trace-event-parse.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
trace-event-read.c perf tools: Stop using a global trace events description list 2012-06-27 13:08:42 -03:00
trace-event-scripting.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
trace-event.h perf tools: Support for DWARF CFI unwinding on post processing 2012-08-11 15:06:56 -03:00
types.h perf tools: Add union u64_swap type for swapping u64 data 2012-05-22 12:50:25 -03:00
unwind.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
unwind.h perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
usage.c perf target: Introduce perf_target__parse_uid() 2012-05-07 16:46:48 -03:00
util.c perf tools: add NO_BACKTRACE for application self-debugging 2012-09-07 22:12:30 -03:00
util.h perf tools: include wrapper for magic.h 2012-09-11 11:38:10 -03:00
values.c perf tools: Fix a memory leak on perf_read_values_destroy 2011-12-20 13:41:34 -02:00
values.h
vdso.c perf tools: Back [vdso] DSO with real data 2012-09-11 12:08:30 -03:00
vdso.h perf tools: Back [vdso] DSO with real data 2012-09-11 12:08:30 -03:00
wrapper.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
xyarray.c
xyarray.h