Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf kvm/{x86,s390}: Remove dependency on uapi/kvm_perf.h

Its better to remove the dependency on uapi/kvm_perf.h to allow dynamic
discovery of kvm events (if its needed). To do this, some extern
variables have been introduced with which we can keep the generic
functions generic.

Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Acked-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Acked-by: 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-1-git-send-email-hemant@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Hemant Kumar and committed by
Arnaldo Carvalho de Melo
162607ea d2db9a98

+33 -14
+7 -1
tools/perf/arch/s390/util/kvm-stat.c
··· 10 10 */ 11 11 12 12 #include "../../util/kvm-stat.h" 13 - #include <asm/kvm_perf.h> 13 + #include <asm/sie.h> 14 14 15 15 define_exit_reasons_table(sie_exit_reasons, sie_intercept_code); 16 16 define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes); 17 17 define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes); 18 18 define_exit_reasons_table(sie_diagnose_codes, diagnose_codes); 19 19 define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes); 20 + 21 + const char *vcpu_id_str = "id"; 22 + const int decode_str_len = 40; 23 + const char *kvm_exit_reason = "icptcode"; 24 + const char *kvm_entry_trace = "kvm:kvm_s390_sie_enter"; 25 + const char *kvm_exit_trace = "kvm:kvm_s390_sie_exit"; 20 26 21 27 static void event_icpt_insn_get_key(struct perf_evsel *evsel, 22 28 struct perf_sample *sample,
+11 -3
tools/perf/arch/x86/util/kvm-stat.c
··· 1 1 #include "../../util/kvm-stat.h" 2 - #include <asm/kvm_perf.h> 2 + #include <asm/svm.h> 3 + #include <asm/vmx.h> 4 + #include <asm/kvm.h> 3 5 4 6 define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS); 5 7 define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS); ··· 12 10 .decode_key = exit_event_decode_key, 13 11 .name = "VM-EXIT" 14 12 }; 13 + 14 + const char *vcpu_id_str = "vcpu_id"; 15 + const int decode_str_len = 20; 16 + const char *kvm_exit_reason = "exit_reason"; 17 + const char *kvm_entry_trace = "kvm:kvm_entry"; 18 + const char *kvm_exit_trace = "kvm:kvm_exit"; 15 19 16 20 /* 17 21 * For the mmio events, we treat: ··· 73 65 struct event_key *key, 74 66 char *decode) 75 67 { 76 - scnprintf(decode, DECODE_STR_LEN, "%#lx:%s", 68 + scnprintf(decode, decode_str_len, "%#lx:%s", 77 69 (unsigned long)key->key, 78 70 key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R"); 79 71 } ··· 117 109 struct event_key *key, 118 110 char *decode) 119 111 { 120 - scnprintf(decode, DECODE_STR_LEN, "%#llx:%s", 112 + scnprintf(decode, decode_str_len, "%#llx:%s", 121 113 (unsigned long long)key->key, 122 114 key->info ? "POUT" : "PIN"); 123 115 }
+10 -10
tools/perf/builtin-kvm.c
··· 30 30 #include <math.h> 31 31 32 32 #ifdef HAVE_KVM_STAT_SUPPORT 33 - #include <asm/kvm_perf.h> 34 33 #include "util/kvm-stat.h" 35 34 36 35 void exit_event_get_key(struct perf_evsel *evsel, ··· 37 38 struct event_key *key) 38 39 { 39 40 key->info = 0; 40 - key->key = perf_evsel__intval(evsel, sample, KVM_EXIT_REASON); 41 + key->key = perf_evsel__intval(evsel, sample, kvm_exit_reason); 41 42 } 42 43 43 44 bool kvm_exit_event(struct perf_evsel *evsel) 44 45 { 45 - return !strcmp(evsel->name, KVM_EXIT_TRACE); 46 + return !strcmp(evsel->name, kvm_exit_trace); 46 47 } 47 48 48 49 bool exit_event_begin(struct perf_evsel *evsel, ··· 58 59 59 60 bool kvm_entry_event(struct perf_evsel *evsel) 60 61 { 61 - return !strcmp(evsel->name, KVM_ENTRY_TRACE); 62 + return !strcmp(evsel->name, kvm_entry_trace); 62 63 } 63 64 64 65 bool exit_event_end(struct perf_evsel *evsel, ··· 90 91 const char *exit_reason = get_exit_reason(kvm, key->exit_reasons, 91 92 key->key); 92 93 93 - scnprintf(decode, DECODE_STR_LEN, "%s", exit_reason); 94 + scnprintf(decode, decode_str_len, "%s", exit_reason); 94 95 } 95 96 96 97 static bool register_kvm_events_ops(struct perf_kvm_stat *kvm) ··· 356 357 time_diff = sample->time - time_begin; 357 358 358 359 if (kvm->duration && time_diff > kvm->duration) { 359 - char decode[DECODE_STR_LEN]; 360 + char decode[decode_str_len]; 360 361 361 362 kvm->events_ops->decode_key(kvm, &event->key, decode); 362 363 if (!skip_event(decode)) { ··· 384 385 return NULL; 385 386 } 386 387 387 - vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, VCPU_ID); 388 + vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, 389 + vcpu_id_str); 388 390 thread__set_priv(thread, vcpu_record); 389 391 } 390 392 ··· 574 574 575 575 static void print_result(struct perf_kvm_stat *kvm) 576 576 { 577 - char decode[DECODE_STR_LEN]; 577 + char decode[decode_str_len]; 578 578 struct kvm_event *event; 579 579 int vcpu = kvm->trace_vcpu; 580 580 ··· 585 585 586 586 pr_info("\n\n"); 587 587 print_vcpu_info(kvm); 588 - pr_info("%*s ", DECODE_STR_LEN, kvm->events_ops->name); 588 + pr_info("%*s ", decode_str_len, kvm->events_ops->name); 589 589 pr_info("%10s ", "Samples"); 590 590 pr_info("%9s ", "Samples%"); 591 591 ··· 604 604 min = get_event_min(event, vcpu); 605 605 606 606 kvm->events_ops->decode_key(kvm, &event->key, decode); 607 - pr_info("%*s ", DECODE_STR_LEN, decode); 607 + pr_info("%*s ", decode_str_len, decode); 608 608 pr_info("%10llu ", (unsigned long long)ecount); 609 609 pr_info("%8.2f%% ", (double)ecount / kvm->total_count * 100); 610 610 pr_info("%8.2f%% ", (double)etime / kvm->total_time * 100);
+5
tools/perf/util/kvm-stat.h
··· 136 136 extern const char * const kvm_events_tp[]; 137 137 extern struct kvm_reg_events_ops kvm_reg_events_ops[]; 138 138 extern const char * const kvm_skip_events[]; 139 + extern const char *vcpu_id_str; 140 + extern const int decode_str_len; 141 + extern const char *kvm_exit_reason; 142 + extern const char *kvm_entry_trace; 143 + extern const char *kvm_exit_trace; 139 144 140 145 #endif /* __PERF_KVM_STAT_H */