diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2011-02-25 22:51:54 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2011-03-02 10:05:51 -0500 |
commit | 0a10247914a5cad3caf7ef8a255c54c4d3ed2062 (patch) | |
tree | 1d206b0c3e1ef18164d049c15436d566aa3176cf /tools/perf/util/evlist.c | |
parent | 5807806a92450fd57f8063868efae9d4af74db02 (diff) |
perf: Set filters before mmaping events
We currently set the filters after we mmap the events, this is a
race that let undesired events record themselves in the buffer before
we had the time to set the filters.
So set the filters before they can be recorded. That also librarizes
the filters setting so that filtering can be done more easily
from other tools than perf record later.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r-- | tools/perf/util/evlist.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 95b21fece2ce..030ae7f05e03 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -348,3 +348,31 @@ void perf_evlist__delete_maps(struct perf_evlist *evlist) | |||
348 | evlist->cpus = NULL; | 348 | evlist->cpus = NULL; |
349 | evlist->threads = NULL; | 349 | evlist->threads = NULL; |
350 | } | 350 | } |
351 | |||
352 | int perf_evlist__set_filters(struct perf_evlist *evlist) | ||
353 | { | ||
354 | const struct thread_map *threads = evlist->threads; | ||
355 | const struct cpu_map *cpus = evlist->cpus; | ||
356 | struct perf_evsel *evsel; | ||
357 | char *filter; | ||
358 | int thread; | ||
359 | int cpu; | ||
360 | int err; | ||
361 | int fd; | ||
362 | |||
363 | list_for_each_entry(evsel, &evlist->entries, node) { | ||
364 | filter = evsel->filter; | ||
365 | if (!filter) | ||
366 | continue; | ||
367 | for (cpu = 0; cpu < cpus->nr; cpu++) { | ||
368 | for (thread = 0; thread < threads->nr; thread++) { | ||
369 | fd = FD(evsel, cpu, thread); | ||
370 | err = ioctl(fd, PERF_EVENT_IOC_SET_FILTER, filter); | ||
371 | if (err) | ||
372 | return err; | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | |||
377 | return 0; | ||
378 | } | ||