diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-11 20:42:19 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-22 16:56:28 -0500 |
commit | f08199d314458610d4ca52f8e86e0a4ec7a7bc54 (patch) | |
tree | 80078cf09949aab97d9470f8126dc2b0ecc9656c /tools/perf/util/evsel.c | |
parent | 5c581041cf97aa7980b442de81ddea8273d6dcde (diff) |
perf evsel: Support event groups
The perf_evsel__open now have an extra boolean argument specifying if
event grouping is desired.
The first file descriptor created on a CPU becomes the group leader.
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.c')
-rw-r--r-- | tools/perf/util/evsel.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index f5cfed60af98..da473ec93c75 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -128,7 +128,7 @@ int __perf_evsel__read(struct perf_evsel *evsel, | |||
128 | } | 128 | } |
129 | 129 | ||
130 | static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | 130 | static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, |
131 | struct thread_map *threads) | 131 | struct thread_map *threads, bool group) |
132 | { | 132 | { |
133 | int cpu, thread; | 133 | int cpu, thread; |
134 | 134 | ||
@@ -137,12 +137,18 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | |||
137 | return -1; | 137 | return -1; |
138 | 138 | ||
139 | for (cpu = 0; cpu < cpus->nr; cpu++) { | 139 | for (cpu = 0; cpu < cpus->nr; cpu++) { |
140 | int group_fd = -1; | ||
141 | |||
140 | for (thread = 0; thread < threads->nr; thread++) { | 142 | for (thread = 0; thread < threads->nr; thread++) { |
141 | FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr, | 143 | FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr, |
142 | threads->map[thread], | 144 | threads->map[thread], |
143 | cpus->map[cpu], -1, 0); | 145 | cpus->map[cpu], |
146 | group_fd, 0); | ||
144 | if (FD(evsel, cpu, thread) < 0) | 147 | if (FD(evsel, cpu, thread) < 0) |
145 | goto out_close; | 148 | goto out_close; |
149 | |||
150 | if (group && group_fd == -1) | ||
151 | group_fd = FD(evsel, cpu, thread); | ||
146 | } | 152 | } |
147 | } | 153 | } |
148 | 154 | ||
@@ -175,10 +181,9 @@ static struct { | |||
175 | .threads = { -1, }, | 181 | .threads = { -1, }, |
176 | }; | 182 | }; |
177 | 183 | ||
178 | int perf_evsel__open(struct perf_evsel *evsel, | 184 | int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, |
179 | struct cpu_map *cpus, struct thread_map *threads) | 185 | struct thread_map *threads, bool group) |
180 | { | 186 | { |
181 | |||
182 | if (cpus == NULL) { | 187 | if (cpus == NULL) { |
183 | /* Work around old compiler warnings about strict aliasing */ | 188 | /* Work around old compiler warnings about strict aliasing */ |
184 | cpus = &empty_cpu_map.map; | 189 | cpus = &empty_cpu_map.map; |
@@ -187,15 +192,17 @@ int perf_evsel__open(struct perf_evsel *evsel, | |||
187 | if (threads == NULL) | 192 | if (threads == NULL) |
188 | threads = &empty_thread_map.map; | 193 | threads = &empty_thread_map.map; |
189 | 194 | ||
190 | return __perf_evsel__open(evsel, cpus, threads); | 195 | return __perf_evsel__open(evsel, cpus, threads, group); |
191 | } | 196 | } |
192 | 197 | ||
193 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus) | 198 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, |
199 | struct cpu_map *cpus, bool group) | ||
194 | { | 200 | { |
195 | return __perf_evsel__open(evsel, cpus, &empty_thread_map.map); | 201 | return __perf_evsel__open(evsel, cpus, &empty_thread_map.map, group); |
196 | } | 202 | } |
197 | 203 | ||
198 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *threads) | 204 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, |
205 | struct thread_map *threads, bool group) | ||
199 | { | 206 | { |
200 | return __perf_evsel__open(evsel, &empty_cpu_map.map, threads); | 207 | return __perf_evsel__open(evsel, &empty_cpu_map.map, threads, group); |
201 | } | 208 | } |