aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-kvm.c
diff options
context:
space:
mode:
authorHemant Kumar <hemant@linux.vnet.ibm.com>2016-01-28 01:33:06 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-01-29 15:49:54 -0500
commit066d3593e1b14690dc1131d50cacbb0b7eb3f160 (patch)
treeb40810eda20172c4d876522ef4abcfc1254326fc /tools/perf/builtin-kvm.c
parent48deaa74fcdad516a94fe38a4af706747d9e4745 (diff)
perf kvm/powerpc: Port perf kvm stat to powerpc
perf kvm can be used to analyze guest exit reasons. This support already exists in x86. Hence, porting it to powerpc. - To trace KVM events : perf kvm stat record If many guests are running, we can track for a specific guest by using --pid as in : perf kvm stat record --pid <pid> - To see the results : perf kvm stat report The result shows the number of exits (from the guest context to host/hypervisor context) grouped by their respective exit reasons with their frequency. Since, different powerpc machines have different KVM tracepoints, this patch discovers the available tracepoints dynamically and accordingly looks for them. If any single tracepoint is not present, this support won't be enabled for reporting. To record, this will fail if any of the events we are looking to record isn't available. Right now, its only supported on PowerPC Book3S_HV architectures. To analyze the different exits, group them and present them (in a slight descriptive way) to the user, we need a mapping between the "exit code" (dumped in the kvm_guest_exit tracepoint data) and to its related Interrupt vector description (exit reason). This patch adds this mapping in book3s_hv_exits.h. It records on two available KVM tracepoints for book3s_hv: "kvm_hv:kvm_guest_exit" and "kvm_hv:kvm_guest_enter". Here is a sample o/p: # pgrep qemu 19378 60515 2 Guests are running on the host. # perf kvm stat record -a ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 4.153 MB perf.data.guest (39624 samples) ] # perf kvm stat report -p 60515 Analyze events for pid(s) 60515, all VCPUs: VM-EXIT Samples Samples% Time% MinTime MaxTime Avg time SYSCALL 9141 63.67% 7.49% 1.26us 5782.39us 9.87us (+- 6.46%) H_DATA_STORAGE 4114 28.66% 5.07% 1.72us 4597.68us 14.84us (+-20.06%) HV_DECREMENTER 418 2.91% 4.26% 0.70us 30002.22us 122.58us (+-70.29%) EXTERNAL 392 2.73% 0.06% 0.64us 104.10us 1.94us (+-18.83%) RETURN_TO_HOST 287 2.00% 83.11% 1.53us 124240.15us 3486.52us (+-16.81%) H_INST_STORAGE 5 0.03% 0.00% 1.88us 3.73us 2.39us (+-14.20%) Total Samples:14357, Total events handled time:1203918.42us. Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Scott Wood <scottwood@freescale.com> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: linuxppc-dev@lists.ozlabs.org Link: http://lkml.kernel.org/r/1453962787-15376-3-git-send-email-hemant@linux.vnet.ibm.com Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-kvm.c')
-rw-r--r--tools/perf/builtin-kvm.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index ab5645cf39d2..bff666458b28 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1132,6 +1132,11 @@ exit:
1132 _p; \ 1132 _p; \
1133 }) 1133 })
1134 1134
1135int __weak setup_kvm_events_tp(struct perf_kvm_stat *kvm __maybe_unused)
1136{
1137 return 0;
1138}
1139
1135static int 1140static int
1136kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv) 1141kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv)
1137{ 1142{
@@ -1148,7 +1153,14 @@ kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv)
1148 NULL 1153 NULL
1149 }; 1154 };
1150 const char * const *events_tp; 1155 const char * const *events_tp;
1156 int ret;
1157
1151 events_tp_size = 0; 1158 events_tp_size = 0;
1159 ret = setup_kvm_events_tp(kvm);
1160 if (ret < 0) {
1161 pr_err("Unable to setup the kvm tracepoints\n");
1162 return ret;
1163 }
1152 1164
1153 for (events_tp = kvm_events_tp; *events_tp; events_tp++) 1165 for (events_tp = kvm_events_tp; *events_tp; events_tp++)
1154 events_tp_size++; 1166 events_tp_size++;
@@ -1377,6 +1389,12 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
1377 /* 1389 /*
1378 * generate the event list 1390 * generate the event list
1379 */ 1391 */
1392 err = setup_kvm_events_tp(kvm);
1393 if (err < 0) {
1394 pr_err("Unable to setup the kvm tracepoints\n");
1395 return err;
1396 }
1397
1380 kvm->evlist = kvm_live_event_list(); 1398 kvm->evlist = kvm_live_event_list();
1381 if (kvm->evlist == NULL) { 1399 if (kvm->evlist == NULL) {
1382 err = -1; 1400 err = -1;