perf kvm: Move arch specific code into arch/
[deliverable/linux.git] / tools / perf / util / kvm-stat.h
1 #ifndef __PERF_KVM_STAT_H
2 #define __PERF_KVM_STAT_H
3
4 #include "../perf.h"
5 #include "evsel.h"
6 #include "evlist.h"
7 #include "session.h"
8 #include "tool.h"
9 #include "stat.h"
10
11 struct event_key {
12 #define INVALID_KEY (~0ULL)
13 u64 key;
14 int info;
15 };
16
17 struct kvm_event_stats {
18 u64 time;
19 struct stats stats;
20 };
21
22 struct kvm_event {
23 struct list_head hash_entry;
24 struct rb_node rb;
25
26 struct event_key key;
27
28 struct kvm_event_stats total;
29
30 #define DEFAULT_VCPU_NUM 8
31 int max_vcpu;
32 struct kvm_event_stats *vcpu;
33 };
34
35 typedef int (*key_cmp_fun)(struct kvm_event*, struct kvm_event*, int);
36
37 struct kvm_event_key {
38 const char *name;
39 key_cmp_fun key;
40 };
41
42 struct perf_kvm_stat;
43
44 struct kvm_events_ops {
45 bool (*is_begin_event)(struct perf_evsel *evsel,
46 struct perf_sample *sample,
47 struct event_key *key);
48 bool (*is_end_event)(struct perf_evsel *evsel,
49 struct perf_sample *sample, struct event_key *key);
50 void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
51 char *decode);
52 const char *name;
53 };
54
55 struct exit_reasons_table {
56 unsigned long exit_code;
57 const char *reason;
58 };
59
60 #define EVENTS_BITS 12
61 #define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS)
62
63 struct perf_kvm_stat {
64 struct perf_tool tool;
65 struct record_opts opts;
66 struct perf_evlist *evlist;
67 struct perf_session *session;
68
69 const char *file_name;
70 const char *report_event;
71 const char *sort_key;
72 int trace_vcpu;
73
74 struct exit_reasons_table *exit_reasons;
75 const char *exit_reasons_isa;
76
77 struct kvm_events_ops *events_ops;
78 key_cmp_fun compare;
79 struct list_head kvm_events_cache[EVENTS_CACHE_SIZE];
80
81 u64 total_time;
82 u64 total_count;
83 u64 lost_events;
84 u64 duration;
85
86 const char *pid_str;
87 struct intlist *pid_list;
88
89 struct rb_root result;
90
91 int timerfd;
92 unsigned int display_time;
93 bool live;
94 };
95
96 struct kvm_reg_events_ops {
97 const char *name;
98 struct kvm_events_ops *ops;
99 };
100
101 void exit_event_get_key(struct perf_evsel *evsel,
102 struct perf_sample *sample,
103 struct event_key *key);
104 bool exit_event_begin(struct perf_evsel *evsel,
105 struct perf_sample *sample,
106 struct event_key *key);
107 bool exit_event_end(struct perf_evsel *evsel,
108 struct perf_sample *sample,
109 struct event_key *key);
110 void exit_event_decode_key(struct perf_kvm_stat *kvm,
111 struct event_key *key,
112 char *decode);
113
114 bool kvm_exit_event(struct perf_evsel *evsel);
115 bool kvm_entry_event(struct perf_evsel *evsel);
116
117 #define define_exit_reasons_table(name, symbols) \
118 static struct exit_reasons_table name[] = { \
119 symbols, { -1, NULL } \
120 }
121
122 /*
123 * arch specific callbacks and data structures
124 */
125 int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid);
126
127 extern const char * const kvm_events_tp[];
128 extern struct kvm_reg_events_ops kvm_reg_events_ops[];
129
130 #endif /* __PERF_KVM_STAT_H */
This page took 0.050244 seconds and 6 git commands to generate.