1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_KVM_STAT_H
3 #define __PERF_KVM_STAT_H
5 #ifdef HAVE_KVM_STAT_SUPPORT
16 #define INVALID_KEY (~0ULL)
19 struct exit_reasons_table
*exit_reasons
;
22 struct kvm_event_stats
{
28 struct list_head hash_entry
;
33 struct kvm_event_stats total
;
35 #define DEFAULT_VCPU_NUM 8
37 struct kvm_event_stats
*vcpu
;
40 typedef int (*key_cmp_fun
)(struct kvm_event
*, struct kvm_event
*, int);
42 struct kvm_event_key
{
49 struct child_event_ops
{
50 void (*get_key
)(struct evsel
*evsel
,
51 struct perf_sample
*sample
,
52 struct event_key
*key
);
56 struct kvm_events_ops
{
57 bool (*is_begin_event
)(struct evsel
*evsel
,
58 struct perf_sample
*sample
,
59 struct event_key
*key
);
60 bool (*is_end_event
)(struct evsel
*evsel
,
61 struct perf_sample
*sample
, struct event_key
*key
);
62 struct child_event_ops
*child_ops
;
63 void (*decode_key
)(struct perf_kvm_stat
*kvm
, struct event_key
*key
,
68 struct exit_reasons_table
{
69 unsigned long exit_code
;
73 #define EVENTS_BITS 12
74 #define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS)
76 struct perf_kvm_stat
{
77 struct perf_tool tool
;
78 struct record_opts opts
;
79 struct evlist
*evlist
;
80 struct perf_session
*session
;
82 const char *file_name
;
83 const char *report_event
;
87 struct exit_reasons_table
*exit_reasons
;
88 const char *exit_reasons_isa
;
90 struct kvm_events_ops
*events_ops
;
92 struct list_head kvm_events_cache
[EVENTS_CACHE_SIZE
];
99 struct intlist
*pid_list
;
101 struct rb_root result
;
104 unsigned int display_time
;
109 struct kvm_reg_events_ops
{
111 struct kvm_events_ops
*ops
;
114 void exit_event_get_key(struct evsel
*evsel
,
115 struct perf_sample
*sample
,
116 struct event_key
*key
);
117 bool exit_event_begin(struct evsel
*evsel
,
118 struct perf_sample
*sample
,
119 struct event_key
*key
);
120 bool exit_event_end(struct evsel
*evsel
,
121 struct perf_sample
*sample
,
122 struct event_key
*key
);
123 void exit_event_decode_key(struct perf_kvm_stat
*kvm
,
124 struct event_key
*key
,
127 bool kvm_exit_event(struct evsel
*evsel
);
128 bool kvm_entry_event(struct evsel
*evsel
);
129 int setup_kvm_events_tp(struct perf_kvm_stat
*kvm
);
131 #define define_exit_reasons_table(name, symbols) \
132 static struct exit_reasons_table name[] = { \
133 symbols, { -1, NULL } \
137 * arch specific callbacks and data structures
139 int cpu_isa_init(struct perf_kvm_stat
*kvm
, const char *cpuid
);
141 extern const char *kvm_events_tp
[];
142 extern struct kvm_reg_events_ops kvm_reg_events_ops
[];
143 extern const char * const kvm_skip_events
[];
144 extern const char *vcpu_id_str
;
145 extern const int decode_str_len
;
146 extern const char *kvm_exit_reason
;
147 extern const char *kvm_entry_trace
;
148 extern const char *kvm_exit_trace
;
149 #endif /* HAVE_KVM_STAT_SUPPORT */
151 extern int kvm_add_default_arch_event(int *argc
, const char **argv
);
152 #endif /* __PERF_KVM_STAT_H */