diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-03 14:45:52 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-03 21:22:55 -0500 |
commit | c52b12ed2511e6c031a0295fd903ea72b93701fb (patch) | |
tree | 770915627e789401b820a104c1ed23a212e7bd50 /tools/perf/util/evsel.h | |
parent | 70d544d0576775a2b3923a7e68cb49b0313d80c9 (diff) |
perf evsel: Steal the counter reading routines from stat
Making them hopefully generic enough to be used in 'perf test',
well see.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evsel.h')
-rw-r--r-- | tools/perf/util/evsel.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 8a5cfb656674..8b48ef1e672c 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -2,15 +2,34 @@ | |||
2 | #define __PERF_EVSEL_H 1 | 2 | #define __PERF_EVSEL_H 1 |
3 | 3 | ||
4 | #include <linux/list.h> | 4 | #include <linux/list.h> |
5 | #include <stdbool.h> | ||
5 | #include <linux/perf_event.h> | 6 | #include <linux/perf_event.h> |
6 | #include "types.h" | 7 | #include "types.h" |
7 | #include "xyarray.h" | 8 | #include "xyarray.h" |
9 | |||
10 | struct perf_counts_values { | ||
11 | union { | ||
12 | struct { | ||
13 | u64 val; | ||
14 | u64 ena; | ||
15 | u64 run; | ||
16 | }; | ||
17 | u64 values[3]; | ||
18 | }; | ||
19 | }; | ||
20 | |||
21 | struct perf_counts { | ||
22 | s8 scaled; | ||
23 | struct perf_counts_values aggr; | ||
24 | struct perf_counts_values cpu[]; | ||
25 | }; | ||
8 | 26 | ||
9 | struct perf_evsel { | 27 | struct perf_evsel { |
10 | struct list_head node; | 28 | struct list_head node; |
11 | struct perf_event_attr attr; | 29 | struct perf_event_attr attr; |
12 | char *filter; | 30 | char *filter; |
13 | struct xyarray *fd; | 31 | struct xyarray *fd; |
32 | struct perf_counts *counts; | ||
14 | int idx; | 33 | int idx; |
15 | void *priv; | 34 | void *priv; |
16 | }; | 35 | }; |
@@ -19,10 +38,70 @@ struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx); | |||
19 | void perf_evsel__delete(struct perf_evsel *evsel); | 38 | void perf_evsel__delete(struct perf_evsel *evsel); |
20 | 39 | ||
21 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); | 40 | int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); |
41 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus); | ||
22 | void perf_evsel__free_fd(struct perf_evsel *evsel); | 42 | void perf_evsel__free_fd(struct perf_evsel *evsel); |
43 | void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); | ||
23 | 44 | ||
24 | #define perf_evsel__match(evsel, t, c) \ | 45 | #define perf_evsel__match(evsel, t, c) \ |
25 | (evsel->attr.type == PERF_TYPE_##t && \ | 46 | (evsel->attr.type == PERF_TYPE_##t && \ |
26 | evsel->attr.config == PERF_COUNT_##c) | 47 | evsel->attr.config == PERF_COUNT_##c) |
27 | 48 | ||
49 | int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, | ||
50 | int cpu, int thread, bool scale); | ||
51 | |||
52 | /** | ||
53 | * perf_evsel__read_on_cpu - Read out the results on a CPU and thread | ||
54 | * | ||
55 | * @evsel - event selector to read value | ||
56 | * @cpu - CPU of interest | ||
57 | * @thread - thread of interest | ||
58 | */ | ||
59 | static inline int perf_evsel__read_on_cpu(struct perf_evsel *evsel, | ||
60 | int cpu, int thread) | ||
61 | { | ||
62 | return __perf_evsel__read_on_cpu(evsel, cpu, thread, false); | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * perf_evsel__read_on_cpu_scaled - Read out the results on a CPU and thread, scaled | ||
67 | * | ||
68 | * @evsel - event selector to read value | ||
69 | * @cpu - CPU of interest | ||
70 | * @thread - thread of interest | ||
71 | */ | ||
72 | static inline int perf_evsel__read_on_cpu_scaled(struct perf_evsel *evsel, | ||
73 | int cpu, int thread) | ||
74 | { | ||
75 | return __perf_evsel__read_on_cpu(evsel, cpu, thread, true); | ||
76 | } | ||
77 | |||
78 | int __perf_evsel__read(struct perf_evsel *evsel, int ncpus, int nthreads, | ||
79 | bool scale); | ||
80 | |||
81 | /** | ||
82 | * perf_evsel__read - Read the aggregate results on all CPUs | ||
83 | * | ||
84 | * @evsel - event selector to read value | ||
85 | * @ncpus - Number of cpus affected, from zero | ||
86 | * @nthreads - Number of threads affected, from zero | ||
87 | */ | ||
88 | static inline int perf_evsel__read(struct perf_evsel *evsel, | ||
89 | int ncpus, int nthreads) | ||
90 | { | ||
91 | return __perf_evsel__read(evsel, ncpus, nthreads, false); | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * perf_evsel__read_scaled - Read the aggregate results on all CPUs, scaled | ||
96 | * | ||
97 | * @evsel - event selector to read value | ||
98 | * @ncpus - Number of cpus affected, from zero | ||
99 | * @nthreads - Number of threads affected, from zero | ||
100 | */ | ||
101 | static inline int perf_evsel__read_scaled(struct perf_evsel *evsel, | ||
102 | int ncpus, int nthreads) | ||
103 | { | ||
104 | return __perf_evsel__read(evsel, ncpus, nthreads, true); | ||
105 | } | ||
106 | |||
28 | #endif /* __PERF_EVSEL_H */ | 107 | #endif /* __PERF_EVSEL_H */ |