1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_KVM_STAT_H
3 #define __PERF_KVM_STAT_H
13 #define INVALID_KEY (~0ULL)
16 struct exit_reasons_table
*exit_reasons
;
19 struct kvm_event_stats
{
25 struct list_head hash_entry
;
30 struct kvm_event_stats total
;
32 #define DEFAULT_VCPU_NUM 8
34 struct kvm_event_stats
*vcpu
;
37 typedef int (*key_cmp_fun
)(struct kvm_event
*, struct kvm_event
*, int);
39 struct kvm_event_key
{
46 struct child_event_ops
{
47 void (*get_key
)(struct perf_evsel
*evsel
,
48 struct perf_sample
*sample
,
49 struct event_key
*key
);
53 struct kvm_events_ops
{
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
);
59 struct child_event_ops
*child_ops
;
60 void (*decode_key
)(struct perf_kvm_stat
*kvm
, struct event_key
*key
,
65 struct exit_reasons_table
{
66 unsigned long exit_code
;
70 #define EVENTS_BITS 12
71 #define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS)
73 struct perf_kvm_stat
{
74 struct perf_tool tool
;
75 struct record_opts opts
;
76 struct perf_evlist
*evlist
;
77 struct perf_session
*session
;
79 const char *file_name
;
80 const char *report_event
;
84 struct exit_reasons_table
*exit_reasons
;
85 const char *exit_reasons_isa
;
87 struct kvm_events_ops
*events_ops
;
89 struct list_head kvm_events_cache
[EVENTS_CACHE_SIZE
];
96 struct intlist
*pid_list
;
98 struct rb_root result
;
101 unsigned int display_time
;
106 struct kvm_reg_events_ops
{
108 struct kvm_events_ops
*ops
;
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
,
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
);
128 #define define_exit_reasons_table(name, symbols) \
129 static struct exit_reasons_table name[] = { \
130 symbols, { -1, NULL } \
134 * arch specific callbacks and data structures
136 int cpu_isa_init(struct perf_kvm_stat
*kvm
, const char *cpuid
);
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
;
147 #endif /* __PERF_KVM_STAT_H */