aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorAlexander Yarygin <yarygin@linux.vnet.ibm.com>2014-07-03 10:29:05 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-07-16 16:57:32 -0400
commit9daa81239e60c162153fb2a365b8492c9a9bf632 (patch)
treea3f2fda3d42857f6c2d5188c308e02474d641eef /tools/perf/util
parent44b3802122174ba499613bac3aab2e66e948ce1e (diff)
perf kvm: Move arch specific code into arch/
Parts of a 'perf kvm stat' code make sense only for x86. Let's move this code into the arch/x86/kvm-stat.c file and add util/kvm-stat.h for generic structure definitions. Add a global array 'kvm_reg_events_ops' for accessing the arch-specific 'kvm_events_ops' from generic code. Since the several global arrays (i.e. 'kvm_events_tp') have been moved to arch/*, we can not know their sizes and use them directly in builtin-kvm.c. This patch fixes that problem by adding trimming NULL element to each array and changing the behavior of their handlers in generic code. Reviewed-by: David Ahern <dsahern@gmail.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1404397747-20939-3-git-send-email-yarygin@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/kvm-stat.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h
new file mode 100644
index 000000000000..d0d9fb1ae52a
--- /dev/null
+++ b/tools/perf/util/kvm-stat.h
@@ -0,0 +1,130 @@
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
11struct event_key {
12 #define INVALID_KEY (~0ULL)
13 u64 key;
14 int info;
15};
16
17struct kvm_event_stats {
18 u64 time;
19 struct stats stats;
20};
21
22struct 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
35typedef int (*key_cmp_fun)(struct kvm_event*, struct kvm_event*, int);
36
37struct kvm_event_key {
38 const char *name;
39 key_cmp_fun key;
40};
41
42struct perf_kvm_stat;
43
44struct 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
55struct 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
63struct 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
96struct kvm_reg_events_ops {
97 const char *name;
98 struct kvm_events_ops *ops;
99};
100
101void exit_event_get_key(struct perf_evsel *evsel,
102 struct perf_sample *sample,
103 struct event_key *key);
104bool exit_event_begin(struct perf_evsel *evsel,
105 struct perf_sample *sample,
106 struct event_key *key);
107bool exit_event_end(struct perf_evsel *evsel,
108 struct perf_sample *sample,
109 struct event_key *key);
110void exit_event_decode_key(struct perf_kvm_stat *kvm,
111 struct event_key *key,
112 char *decode);
113
114bool kvm_exit_event(struct perf_evsel *evsel);
115bool 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 */
125int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid);
126
127extern const char * const kvm_events_tp[];
128extern struct kvm_reg_events_ops kvm_reg_events_ops[];
129
130#endif /* __PERF_KVM_STAT_H */