mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 15:03:53 +02:00
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>
This commit is contained in:
parent
702c7a4aec
commit
3f1889422a
|
@ -615,67 +615,6 @@ static const char *get_filename_for_perf_kvm(void)
|
|||
|
||||
#if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT)
|
||||
|
||||
void exit_event_get_key(struct evsel *evsel,
|
||||
struct perf_sample *sample,
|
||||
struct event_key *key)
|
||||
{
|
||||
key->info = 0;
|
||||
key->key = evsel__intval(evsel, sample, kvm_exit_reason);
|
||||
}
|
||||
|
||||
bool kvm_exit_event(struct evsel *evsel)
|
||||
{
|
||||
return evsel__name_is(evsel, kvm_exit_trace);
|
||||
}
|
||||
|
||||
bool exit_event_begin(struct evsel *evsel,
|
||||
struct perf_sample *sample, struct event_key *key)
|
||||
{
|
||||
if (kvm_exit_event(evsel)) {
|
||||
exit_event_get_key(evsel, sample, key);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool kvm_entry_event(struct evsel *evsel)
|
||||
{
|
||||
return evsel__name_is(evsel, kvm_entry_trace);
|
||||
}
|
||||
|
||||
bool exit_event_end(struct evsel *evsel,
|
||||
struct perf_sample *sample __maybe_unused,
|
||||
struct event_key *key __maybe_unused)
|
||||
{
|
||||
return kvm_entry_event(evsel);
|
||||
}
|
||||
|
||||
static const char *get_exit_reason(struct perf_kvm_stat *kvm,
|
||||
struct exit_reasons_table *tbl,
|
||||
u64 exit_code)
|
||||
{
|
||||
while (tbl->reason != NULL) {
|
||||
if (tbl->exit_code == exit_code)
|
||||
return tbl->reason;
|
||||
tbl++;
|
||||
}
|
||||
|
||||
pr_err("unknown kvm exit code:%lld on %s\n",
|
||||
(unsigned long long)exit_code, kvm->exit_reasons_isa);
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
void exit_event_decode_key(struct perf_kvm_stat *kvm,
|
||||
struct event_key *key,
|
||||
char *decode)
|
||||
{
|
||||
const char *exit_reason = get_exit_reason(kvm, key->exit_reasons,
|
||||
key->key);
|
||||
|
||||
scnprintf(decode, KVM_EVENT_NAME_LEN, "%s", exit_reason);
|
||||
}
|
||||
|
||||
static bool register_kvm_events_ops(struct perf_kvm_stat *kvm)
|
||||
{
|
||||
struct kvm_reg_events_ops *events_ops = kvm_reg_events_ops;
|
||||
|
|
|
@ -121,6 +121,7 @@ perf-util-y += spark.o
|
|||
perf-util-y += topdown.o
|
||||
perf-util-y += iostat.o
|
||||
perf-util-y += stream.o
|
||||
perf-util-y += kvm-stat.o
|
||||
perf-util-$(CONFIG_AUXTRACE) += auxtrace.o
|
||||
perf-util-$(CONFIG_AUXTRACE) += intel-pt-decoder/
|
||||
perf-util-$(CONFIG_AUXTRACE) += intel-pt.o
|
||||
|
|
70
tools/perf/util/kvm-stat.c
Normal file
70
tools/perf/util/kvm-stat.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "debug.h"
|
||||
#include "evsel.h"
|
||||
#include "kvm-stat.h"
|
||||
|
||||
#if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT)
|
||||
|
||||
bool kvm_exit_event(struct evsel *evsel)
|
||||
{
|
||||
return evsel__name_is(evsel, kvm_exit_trace);
|
||||
}
|
||||
|
||||
void exit_event_get_key(struct evsel *evsel,
|
||||
struct perf_sample *sample,
|
||||
struct event_key *key)
|
||||
{
|
||||
key->info = 0;
|
||||
key->key = evsel__intval(evsel, sample, kvm_exit_reason);
|
||||
}
|
||||
|
||||
|
||||
bool exit_event_begin(struct evsel *evsel,
|
||||
struct perf_sample *sample, struct event_key *key)
|
||||
{
|
||||
if (kvm_exit_event(evsel)) {
|
||||
exit_event_get_key(evsel, sample, key);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool kvm_entry_event(struct evsel *evsel)
|
||||
{
|
||||
return evsel__name_is(evsel, kvm_entry_trace);
|
||||
}
|
||||
|
||||
bool exit_event_end(struct evsel *evsel,
|
||||
struct perf_sample *sample __maybe_unused,
|
||||
struct event_key *key __maybe_unused)
|
||||
{
|
||||
return kvm_entry_event(evsel);
|
||||
}
|
||||
|
||||
static const char *get_exit_reason(struct perf_kvm_stat *kvm,
|
||||
struct exit_reasons_table *tbl,
|
||||
u64 exit_code)
|
||||
{
|
||||
while (tbl->reason != NULL) {
|
||||
if (tbl->exit_code == exit_code)
|
||||
return tbl->reason;
|
||||
tbl++;
|
||||
}
|
||||
|
||||
pr_err("unknown kvm exit code:%lld on %s\n",
|
||||
(unsigned long long)exit_code, kvm->exit_reasons_isa);
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
void exit_event_decode_key(struct perf_kvm_stat *kvm,
|
||||
struct event_key *key,
|
||||
char *decode)
|
||||
{
|
||||
const char *exit_reason = get_exit_reason(kvm, key->exit_reasons,
|
||||
key->key);
|
||||
|
||||
scnprintf(decode, KVM_EVENT_NAME_LEN, "%s", exit_reason);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -115,6 +115,8 @@ struct kvm_reg_events_ops {
|
|||
struct kvm_events_ops *ops;
|
||||
};
|
||||
|
||||
#if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT)
|
||||
|
||||
void exit_event_get_key(struct evsel *evsel,
|
||||
struct perf_sample *sample,
|
||||
struct event_key *key);
|
||||
|
@ -127,6 +129,7 @@ bool exit_event_end(struct evsel *evsel,
|
|||
void exit_event_decode_key(struct perf_kvm_stat *kvm,
|
||||
struct event_key *key,
|
||||
char *decode);
|
||||
#endif
|
||||
|
||||
bool kvm_exit_event(struct evsel *evsel);
|
||||
bool kvm_entry_event(struct evsel *evsel);
|
||||
|
|
|
@ -1307,38 +1307,6 @@ error:
|
|||
/* The following are stubs to avoid dragging in builtin-* objects. */
|
||||
/* TODO: move the code out of the builtin-* file into util. */
|
||||
|
||||
#ifdef HAVE_KVM_STAT_SUPPORT
|
||||
bool kvm_entry_event(struct evsel *evsel __maybe_unused)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool kvm_exit_event(struct evsel *evsel __maybe_unused)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool exit_event_begin(struct evsel *evsel __maybe_unused,
|
||||
struct perf_sample *sample __maybe_unused,
|
||||
struct event_key *key __maybe_unused)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool exit_event_end(struct evsel *evsel __maybe_unused,
|
||||
struct perf_sample *sample __maybe_unused,
|
||||
struct event_key *key __maybe_unused)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void exit_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
|
||||
struct event_key *key __maybe_unused,
|
||||
char *decode __maybe_unused)
|
||||
{
|
||||
}
|
||||
#endif // HAVE_KVM_STAT_SUPPORT
|
||||
|
||||
int find_scripts(char **scripts_array __maybe_unused, char **scripts_path_array __maybe_unused,
|
||||
int num __maybe_unused, int pathlen __maybe_unused)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user