mirror of
https://github.com/torvalds/linux.git
synced 2026-04-28 11:32:28 -04:00
`perf kvm stat` supports record and report options. By using the arch directory a report for a different machine type cannot be supported. Move the kvm-stat code out of the arch directory and into util/kvm-stat-arch following the pattern of perf-regs and dwarf-regs. Avoid duplicate symbols by renaming functions to have the architecture name within them. For global variables, wrap them in an architecture specific function. Selecting the architecture to use with `perf kvm stat` is selected by EM_HOST, ie no different than before the change. Later the ELF machine can be determined from the session or a header feature (ie EM_HOST at the time of the record). The build and #define HAVE_KVM_STAT_SUPPORT is now redundant so remove across Makefiles and in the build. Opportunistically constify architectural structs and arrays. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrew Jones <ajones@ventanamicro.com> Cc: Anubhav Shelat <ashelat@redhat.com> Cc: Anup Patel <anup@brainfault.org> Cc: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Blake Jones <blakejones@google.com> Cc: Chun-Tse Shao <ctshao@google.com> Cc: Dapeng Mi <dapeng1.mi@linux.intel.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Howard Chu <howardchu95@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Leo Yan <leo.yan@linux.dev> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <pjw@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quan Zhou <zhouquan@iscas.ac.cn> Cc: Shimin Guo <shimin.guo@skydio.com> Cc: Swapnil Sapkal <swapnil.sapkal@amd.com> Cc: Thomas Falcon <thomas.falcon@intel.com> Cc: Will Deacon <will@kernel.org> Cc: Yunseong Kim <ysk@kzalloc.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
121 lines
3.0 KiB
C
121 lines
3.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Arch specific functions for perf kvm stat.
|
|
*
|
|
* Copyright 2014 IBM Corp.
|
|
* Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
|
|
*/
|
|
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include "../kvm-stat.h"
|
|
#include "../evsel.h"
|
|
#include "../../../arch/s390/include/uapi/asm/sie.h"
|
|
|
|
define_exit_reasons_table(sie_exit_reasons, sie_intercept_code);
|
|
define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes);
|
|
define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes);
|
|
define_exit_reasons_table(sie_diagnose_codes, diagnose_codes);
|
|
define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes);
|
|
|
|
static void event_icpt_insn_get_key(struct evsel *evsel,
|
|
struct perf_sample *sample,
|
|
struct event_key *key)
|
|
{
|
|
u64 insn;
|
|
|
|
insn = evsel__intval(evsel, sample, "instruction");
|
|
key->key = icpt_insn_decoder(insn);
|
|
key->exit_reasons = sie_icpt_insn_codes;
|
|
}
|
|
|
|
static void event_sigp_get_key(struct evsel *evsel,
|
|
struct perf_sample *sample,
|
|
struct event_key *key)
|
|
{
|
|
key->key = evsel__intval(evsel, sample, "order_code");
|
|
key->exit_reasons = sie_sigp_order_codes;
|
|
}
|
|
|
|
static void event_diag_get_key(struct evsel *evsel,
|
|
struct perf_sample *sample,
|
|
struct event_key *key)
|
|
{
|
|
key->key = evsel__intval(evsel, sample, "code");
|
|
key->exit_reasons = sie_diagnose_codes;
|
|
}
|
|
|
|
static void event_icpt_prog_get_key(struct evsel *evsel,
|
|
struct perf_sample *sample,
|
|
struct event_key *key)
|
|
{
|
|
key->key = evsel__intval(evsel, sample, "code");
|
|
key->exit_reasons = sie_icpt_prog_codes;
|
|
}
|
|
|
|
static const struct child_event_ops child_events[] = {
|
|
{ .name = "kvm:kvm_s390_intercept_instruction",
|
|
.get_key = event_icpt_insn_get_key },
|
|
{ .name = "kvm:kvm_s390_handle_sigp",
|
|
.get_key = event_sigp_get_key },
|
|
{ .name = "kvm:kvm_s390_handle_diag",
|
|
.get_key = event_diag_get_key },
|
|
{ .name = "kvm:kvm_s390_intercept_prog",
|
|
.get_key = event_icpt_prog_get_key },
|
|
{ NULL, NULL },
|
|
};
|
|
|
|
static const struct kvm_events_ops exit_events = {
|
|
.is_begin_event = exit_event_begin,
|
|
.is_end_event = exit_event_end,
|
|
.child_ops = child_events,
|
|
.decode_key = exit_event_decode_key,
|
|
.name = "VM-EXIT"
|
|
};
|
|
|
|
static const char * const __kvm_events_tp[] = {
|
|
"kvm:kvm_s390_sie_enter",
|
|
"kvm:kvm_s390_sie_exit",
|
|
"kvm:kvm_s390_intercept_instruction",
|
|
"kvm:kvm_s390_handle_sigp",
|
|
"kvm:kvm_s390_handle_diag",
|
|
"kvm:kvm_s390_intercept_prog",
|
|
NULL,
|
|
};
|
|
|
|
static const struct kvm_reg_events_ops __kvm_reg_events_ops[] = {
|
|
{ .name = "vmexit", .ops = &exit_events },
|
|
{ NULL, NULL },
|
|
};
|
|
|
|
static const char * const __kvm_skip_events[] = {
|
|
"Wait state",
|
|
NULL,
|
|
};
|
|
|
|
int __cpu_isa_init_s390(struct perf_kvm_stat *kvm, const char *cpuid)
|
|
{
|
|
if (strstr(cpuid, "IBM")) {
|
|
kvm->exit_reasons = sie_exit_reasons;
|
|
kvm->exit_reasons_isa = "SIE";
|
|
} else
|
|
return -ENOTSUP;
|
|
|
|
return 0;
|
|
}
|
|
|
|
const char * const *__kvm_events_tp_s390(void)
|
|
{
|
|
return __kvm_events_tp;
|
|
}
|
|
|
|
const struct kvm_reg_events_ops *__kvm_reg_events_ops_s390(void)
|
|
{
|
|
return __kvm_reg_events_ops;
|
|
}
|
|
|
|
const char * const *__kvm_skip_events_s390(void)
|
|
{
|
|
return __kvm_skip_events;
|
|
}
|