Linux Perf
kvm-stat.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_KVM_STAT_H
3 #define __PERF_KVM_STAT_H
4 
5 #include "../perf.h"
6 #include "evsel.h"
7 #include "evlist.h"
8 #include "session.h"
9 #include "tool.h"
10 #include "stat.h"
11 
12 struct event_key {
13  #define INVALID_KEY (~0ULL)
14  u64 key;
15  int info;
17 };
18 
20  u64 time;
21  struct stats stats;
22 };
23 
24 struct kvm_event {
25  struct list_head hash_entry;
26  struct rb_node rb;
27 
28  struct event_key key;
29 
30  struct kvm_event_stats total;
31 
32  #define DEFAULT_VCPU_NUM 8
33  int max_vcpu;
35 };
36 
37 typedef int (*key_cmp_fun)(struct kvm_event*, struct kvm_event*, int);
38 
39 struct kvm_event_key {
40  const char *name;
42 };
43 
44 struct perf_kvm_stat;
45 
47  void (*get_key)(struct perf_evsel *evsel,
48  struct perf_sample *sample,
49  struct event_key *key);
50  const char *name;
51 };
52 
54  bool (*is_begin_event)(struct perf_evsel *evsel,
55  struct perf_sample *sample,
56  struct event_key *key);
57  bool (*is_end_event)(struct perf_evsel *evsel,
58  struct perf_sample *sample, struct event_key *key);
60  void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
61  char *decode);
62  const char *name;
63 };
64 
66  unsigned long exit_code;
67  const char *reason;
68 };
69 
70 #define EVENTS_BITS 12
71 #define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS)
72 
73 struct perf_kvm_stat {
74  struct perf_tool tool;
75  struct record_opts opts;
78 
79  const char *file_name;
80  const char *report_event;
81  const char *sort_key;
83 
85  const char *exit_reasons_isa;
86 
89  struct list_head kvm_events_cache[EVENTS_CACHE_SIZE];
90 
94  u64 duration;
95 
96  struct intlist *pid_list;
97 
98  struct rb_root result;
99 
100  int timerfd;
101  unsigned int display_time;
102  bool live;
103  bool force;
104 };
105 
107  const char *name;
109 };
110 
111 void exit_event_get_key(struct perf_evsel *evsel,
112  struct perf_sample *sample,
113  struct event_key *key);
114 bool exit_event_begin(struct perf_evsel *evsel,
115  struct perf_sample *sample,
116  struct event_key *key);
117 bool exit_event_end(struct perf_evsel *evsel,
118  struct perf_sample *sample,
119  struct event_key *key);
120 void exit_event_decode_key(struct perf_kvm_stat *kvm,
121  struct event_key *key,
122  char *decode);
123 
124 bool kvm_exit_event(struct perf_evsel *evsel);
125 bool kvm_entry_event(struct perf_evsel *evsel);
126 int setup_kvm_events_tp(struct perf_kvm_stat *kvm);
127 
128 #define define_exit_reasons_table(name, symbols) \
129  static struct exit_reasons_table name[] = { \
130  symbols, { -1, NULL } \
131  }
132 
133 /*
134  * arch specific callbacks and data structures
135  */
136 int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid);
137 
138 extern const char *kvm_events_tp[];
139 extern struct kvm_reg_events_ops kvm_reg_events_ops[];
140 extern const char * const kvm_skip_events[];
141 extern const char *vcpu_id_str;
142 extern const int decode_str_len;
143 extern const char *kvm_exit_reason;
144 extern const char *kvm_entry_trace;
145 extern const char *kvm_exit_trace;
146 
147 #endif /* __PERF_KVM_STAT_H */
u64 total_time
Definition: kvm-stat.h:91
struct kvm_event_stats * vcpu
Definition: kvm-stat.h:34
u64 lost_events
Definition: kvm-stat.h:93
struct child_event_ops * child_ops
Definition: kvm-stat.h:59
#define EVENTS_CACHE_SIZE
Definition: kvm-stat.h:71
const char * name
Definition: kvm-stat.h:50
struct exit_reasons_table * exit_reasons
Definition: kvm-stat.h:84
u64 total_count
Definition: kvm-stat.h:92
const char * sort_key
Definition: kvm-stat.h:81
struct kvm_events_ops * ops
Definition: kvm-stat.h:108
const char * name
Definition: kvm-stat.h:40
const char *const kvm_skip_events[]
Definition: kvm-stat.c:102
int max_vcpu
Definition: kvm-stat.h:33
const char * report_event
Definition: kvm-stat.h:80
struct kvm_events_ops * events_ops
Definition: kvm-stat.h:87
bool kvm_entry_event(struct perf_evsel *evsel)
int info
Definition: kvm-stat.h:15
int setup_kvm_events_tp(struct perf_kvm_stat *kvm)
Definition: kvm-stat.c:156
Definition: tool.h:44
const char * kvm_events_tp[]
Definition: kvm-stat.c:30
static struct perf_tool tool
Definition: builtin-diff.c:362
struct exit_reasons_table * exit_reasons
Definition: kvm-stat.h:16
u64 key
Definition: kvm-stat.h:14
const char * reason
Definition: kvm-stat.h:67
const char * name
Definition: kvm-stat.h:107
def get_key(time, event, cpu, thread)
Definition: stat-cpi.py:9
unsigned long exit_code
Definition: kvm-stat.h:66
int(* key_cmp_fun)(struct kvm_event *, struct kvm_event *, int)
Definition: kvm-stat.h:37
bool exit_event_begin(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
void exit_event_decode_key(struct perf_kvm_stat *kvm, struct event_key *key, char *decode)
key_cmp_fun compare
Definition: kvm-stat.h:88
bool kvm_exit_event(struct perf_evsel *evsel)
unsigned int display_time
Definition: kvm-stat.h:101
Definition: stat.h:10
u64 duration
Definition: kvm-stat.h:94
void exit_event_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
const char * kvm_exit_trace
Definition: kvm-stat.c:15
key_cmp_fun key
Definition: kvm-stat.h:41
static void cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c, unsigned int *d)
Definition: header.c:11
const char * kvm_exit_reason
Definition: kvm-stat.c:31
const char * exit_reasons_isa
Definition: kvm-stat.h:85
struct perf_session * session
Definition: kvm-stat.h:77
const char * file_name
Definition: kvm-stat.h:79
int trace_vcpu
Definition: kvm-stat.h:82
const char * vcpu_id_str
Definition: kvm-stat.c:12
const int decode_str_len
Definition: kvm-stat.c:13
const char * kvm_entry_trace
Definition: kvm-stat.c:14
const char * name
Definition: kvm-stat.h:62
int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
Definition: kvm-stat.c:103
struct perf_evlist * evlist
Definition: kvm-stat.h:76
bool exit_event_end(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key)
struct intlist * pid_list
Definition: kvm-stat.h:96