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

Configure Feed

Select the types of activity you want to include in your feed.

perf kvm: Move functions used in util out of builtin

The util library code is used by the python module but doesn't have
access to the builtin files. Make a util/kvm-stat.c to match the
kvm-stat.h file that declares the functions and move the functions
there.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Link: https://lore.kernel.org/r/20241119011644.971342-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
3f188942 702c7a4a

+74 -93
-61
tools/perf/builtin-kvm.c
··· 615 615 616 616 #if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 617 617 618 - void exit_event_get_key(struct evsel *evsel, 619 - struct perf_sample *sample, 620 - struct event_key *key) 621 - { 622 - key->info = 0; 623 - key->key = evsel__intval(evsel, sample, kvm_exit_reason); 624 - } 625 - 626 - bool kvm_exit_event(struct evsel *evsel) 627 - { 628 - return evsel__name_is(evsel, kvm_exit_trace); 629 - } 630 - 631 - bool exit_event_begin(struct evsel *evsel, 632 - struct perf_sample *sample, struct event_key *key) 633 - { 634 - if (kvm_exit_event(evsel)) { 635 - exit_event_get_key(evsel, sample, key); 636 - return true; 637 - } 638 - 639 - return false; 640 - } 641 - 642 - bool kvm_entry_event(struct evsel *evsel) 643 - { 644 - return evsel__name_is(evsel, kvm_entry_trace); 645 - } 646 - 647 - bool exit_event_end(struct evsel *evsel, 648 - struct perf_sample *sample __maybe_unused, 649 - struct event_key *key __maybe_unused) 650 - { 651 - return kvm_entry_event(evsel); 652 - } 653 - 654 - static const char *get_exit_reason(struct perf_kvm_stat *kvm, 655 - struct exit_reasons_table *tbl, 656 - u64 exit_code) 657 - { 658 - while (tbl->reason != NULL) { 659 - if (tbl->exit_code == exit_code) 660 - return tbl->reason; 661 - tbl++; 662 - } 663 - 664 - pr_err("unknown kvm exit code:%lld on %s\n", 665 - (unsigned long long)exit_code, kvm->exit_reasons_isa); 666 - return "UNKNOWN"; 667 - } 668 - 669 - void exit_event_decode_key(struct perf_kvm_stat *kvm, 670 - struct event_key *key, 671 - char *decode) 672 - { 673 - const char *exit_reason = get_exit_reason(kvm, key->exit_reasons, 674 - key->key); 675 - 676 - scnprintf(decode, KVM_EVENT_NAME_LEN, "%s", exit_reason); 677 - } 678 - 679 618 static bool register_kvm_events_ops(struct perf_kvm_stat *kvm) 680 619 { 681 620 struct kvm_reg_events_ops *events_ops = kvm_reg_events_ops;
+1
tools/perf/util/Build
··· 121 121 perf-util-y += topdown.o 122 122 perf-util-y += iostat.o 123 123 perf-util-y += stream.o 124 + perf-util-y += kvm-stat.o 124 125 perf-util-$(CONFIG_AUXTRACE) += auxtrace.o 125 126 perf-util-$(CONFIG_AUXTRACE) += intel-pt-decoder/ 126 127 perf-util-$(CONFIG_AUXTRACE) += intel-pt.o
+70
tools/perf/util/kvm-stat.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include "debug.h" 3 + #include "evsel.h" 4 + #include "kvm-stat.h" 5 + 6 + #if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 7 + 8 + bool kvm_exit_event(struct evsel *evsel) 9 + { 10 + return evsel__name_is(evsel, kvm_exit_trace); 11 + } 12 + 13 + void exit_event_get_key(struct evsel *evsel, 14 + struct perf_sample *sample, 15 + struct event_key *key) 16 + { 17 + key->info = 0; 18 + key->key = evsel__intval(evsel, sample, kvm_exit_reason); 19 + } 20 + 21 + 22 + bool exit_event_begin(struct evsel *evsel, 23 + struct perf_sample *sample, struct event_key *key) 24 + { 25 + if (kvm_exit_event(evsel)) { 26 + exit_event_get_key(evsel, sample, key); 27 + return true; 28 + } 29 + 30 + return false; 31 + } 32 + 33 + bool kvm_entry_event(struct evsel *evsel) 34 + { 35 + return evsel__name_is(evsel, kvm_entry_trace); 36 + } 37 + 38 + bool exit_event_end(struct evsel *evsel, 39 + struct perf_sample *sample __maybe_unused, 40 + struct event_key *key __maybe_unused) 41 + { 42 + return kvm_entry_event(evsel); 43 + } 44 + 45 + static const char *get_exit_reason(struct perf_kvm_stat *kvm, 46 + struct exit_reasons_table *tbl, 47 + u64 exit_code) 48 + { 49 + while (tbl->reason != NULL) { 50 + if (tbl->exit_code == exit_code) 51 + return tbl->reason; 52 + tbl++; 53 + } 54 + 55 + pr_err("unknown kvm exit code:%lld on %s\n", 56 + (unsigned long long)exit_code, kvm->exit_reasons_isa); 57 + return "UNKNOWN"; 58 + } 59 + 60 + void exit_event_decode_key(struct perf_kvm_stat *kvm, 61 + struct event_key *key, 62 + char *decode) 63 + { 64 + const char *exit_reason = get_exit_reason(kvm, key->exit_reasons, 65 + key->key); 66 + 67 + scnprintf(decode, KVM_EVENT_NAME_LEN, "%s", exit_reason); 68 + } 69 + 70 + #endif
+3
tools/perf/util/kvm-stat.h
··· 115 115 struct kvm_events_ops *ops; 116 116 }; 117 117 118 + #if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 119 + 118 120 void exit_event_get_key(struct evsel *evsel, 119 121 struct perf_sample *sample, 120 122 struct event_key *key); ··· 129 127 void exit_event_decode_key(struct perf_kvm_stat *kvm, 130 128 struct event_key *key, 131 129 char *decode); 130 + #endif 132 131 133 132 bool kvm_exit_event(struct evsel *evsel); 134 133 bool kvm_entry_event(struct evsel *evsel);
-32
tools/perf/util/python.c
··· 1307 1307 /* The following are stubs to avoid dragging in builtin-* objects. */ 1308 1308 /* TODO: move the code out of the builtin-* file into util. */ 1309 1309 1310 - #ifdef HAVE_KVM_STAT_SUPPORT 1311 - bool kvm_entry_event(struct evsel *evsel __maybe_unused) 1312 - { 1313 - return false; 1314 - } 1315 - 1316 - bool kvm_exit_event(struct evsel *evsel __maybe_unused) 1317 - { 1318 - return false; 1319 - } 1320 - 1321 - bool exit_event_begin(struct evsel *evsel __maybe_unused, 1322 - struct perf_sample *sample __maybe_unused, 1323 - struct event_key *key __maybe_unused) 1324 - { 1325 - return false; 1326 - } 1327 - 1328 - bool exit_event_end(struct evsel *evsel __maybe_unused, 1329 - struct perf_sample *sample __maybe_unused, 1330 - struct event_key *key __maybe_unused) 1331 - { 1332 - return false; 1333 - } 1334 - 1335 - void exit_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, 1336 - struct event_key *key __maybe_unused, 1337 - char *decode __maybe_unused) 1338 - { 1339 - } 1340 - #endif // HAVE_KVM_STAT_SUPPORT 1341 - 1342 1310 int find_scripts(char **scripts_array __maybe_unused, char **scripts_path_array __maybe_unused, 1343 1311 int num __maybe_unused, int pathlen __maybe_unused) 1344 1312 {