Linux Perf
kvm-stat.c
Go to the documentation of this file.
1 /*
2  * Arch specific functions for perf kvm stat.
3  *
4  * Copyright 2014 IBM Corp.
5  * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License (version 2 only)
9  * as published by the Free Software Foundation.
10  */
11 
12 #include <errno.h>
13 #include "../../util/kvm-stat.h"
14 #include <asm/sie.h>
15 
16 define_exit_reasons_table(sie_exit_reasons, sie_intercept_code);
17 define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes);
18 define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes);
19 define_exit_reasons_table(sie_diagnose_codes, diagnose_codes);
20 define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes);
21 
22 const char *vcpu_id_str = "id";
23 const int decode_str_len = 40;
24 const char *kvm_exit_reason = "icptcode";
25 const char *kvm_entry_trace = "kvm:kvm_s390_sie_enter";
26 const char *kvm_exit_trace = "kvm:kvm_s390_sie_exit";
27 
28 static void event_icpt_insn_get_key(struct perf_evsel *evsel,
29  struct perf_sample *sample,
30  struct event_key *key)
31 {
32  unsigned long insn;
33 
34  insn = perf_evsel__intval(evsel, sample, "instruction");
35  key->key = icpt_insn_decoder(insn);
36  key->exit_reasons = sie_icpt_insn_codes;
37 }
38 
39 static void event_sigp_get_key(struct perf_evsel *evsel,
40  struct perf_sample *sample,
41  struct event_key *key)
42 {
43  key->key = perf_evsel__intval(evsel, sample, "order_code");
44  key->exit_reasons = sie_sigp_order_codes;
45 }
46 
47 static void event_diag_get_key(struct perf_evsel *evsel,
48  struct perf_sample *sample,
49  struct event_key *key)
50 {
51  key->key = perf_evsel__intval(evsel, sample, "code");
52  key->exit_reasons = sie_diagnose_codes;
53 }
54 
55 static void event_icpt_prog_get_key(struct perf_evsel *evsel,
56  struct perf_sample *sample,
57  struct event_key *key)
58 {
59  key->key = perf_evsel__intval(evsel, sample, "code");
60  key->exit_reasons = sie_icpt_prog_codes;
61 }
62 
63 static struct child_event_ops child_events[] = {
64  { .name = "kvm:kvm_s390_intercept_instruction",
65  .get_key = event_icpt_insn_get_key },
66  { .name = "kvm:kvm_s390_handle_sigp",
67  .get_key = event_sigp_get_key },
68  { .name = "kvm:kvm_s390_handle_diag",
69  .get_key = event_diag_get_key },
70  { .name = "kvm:kvm_s390_intercept_prog",
71  .get_key = event_icpt_prog_get_key },
72  { NULL, NULL },
73 };
74 
75 static struct kvm_events_ops exit_events = {
77  .is_end_event = exit_event_end,
78  .child_ops = child_events,
79  .decode_key = exit_event_decode_key,
80  .name = "VM-EXIT"
81 };
82 
83 const char *kvm_events_tp[] = {
84  "kvm:kvm_s390_sie_enter",
85  "kvm:kvm_s390_sie_exit",
86  "kvm:kvm_s390_intercept_instruction",
87  "kvm:kvm_s390_handle_sigp",
88  "kvm:kvm_s390_handle_diag",
89  "kvm:kvm_s390_intercept_prog",
90  NULL,
91 };
92 
94  { .name = "vmexit", .ops = &exit_events },
95  { NULL, NULL },
96 };
97 
98 const char * const kvm_skip_events[] = {
99  "Wait state",
100  NULL,
101 };
102 
103 int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
104 {
105  if (strstr(cpuid, "IBM/S390")) {
106  kvm->exit_reasons = sie_exit_reasons;
107  kvm->exit_reasons_isa = "SIE";
108  } else
109  return -ENOTSUP;
110 
111  return 0;
112 }
Definition: insn.h:36
define_exit_reasons_table(hv_exit_reasons, kvm_trace_symbol_exit)
const int decode_str_len
Definition: kvm-stat.c:13
const char * name
Definition: kvm-stat.h:50
struct exit_reasons_table * exit_reasons
Definition: kvm-stat.h:84
static void event_icpt_prog_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
Definition: kvm-stat.c:55
const char * kvm_events_tp[NR_TPS+1]
Definition: kvm-stat.c:30
const char * vcpu_id_str
Definition: kvm-stat.c:12
const char * key
Definition: bpf-loader.c:196
static struct child_event_ops child_events[]
Definition: kvm-stat.c:63
static struct kvm_events_ops exit_events
Definition: kvm-stat.c:75
int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused)
Definition: kvm-stat.c:161
const char *const kvm_skip_events[]
Definition: kvm-stat.c:102
struct exit_reasons_table * exit_reasons
Definition: kvm-stat.h:16
u64 key
Definition: kvm-stat.h:14
static void event_sigp_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
Definition: kvm-stat.c:39
u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample, const char *name)
Definition: evsel.c:2722
const char * name
Definition: kvm-stat.h:107
bool exit_event_begin(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
static void event_icpt_insn_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
Definition: kvm-stat.c:28
void exit_event_decode_key(struct perf_kvm_stat *kvm, struct event_key *key, char *decode)
bool(* is_begin_event)(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
Definition: kvm-stat.h:54
const char * kvm_exit_reason
Definition: kvm-stat.c:31
static void event_diag_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
Definition: kvm-stat.c:47
static void cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c, unsigned int *d)
Definition: header.c:11
const char * exit_reasons_isa
Definition: kvm-stat.h:85
const char * kvm_exit_trace
Definition: kvm-stat.c:15
const char * kvm_entry_trace
Definition: kvm-stat.c:14
bool exit_event_end(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)