mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

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>
70 lines
1.5 KiB
C
70 lines
1.5 KiB
C
// 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
|