diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2011-02-26 04:51:54 +0100 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2011-03-02 16:05:51 +0100 |
commit | 0a10247914a5cad3caf7ef8a255c54c4d3ed2062 (patch) | |
tree | 1d206b0c3e1ef18164d049c15436d566aa3176cf /tools/perf/builtin-record.c | |
parent | 5807806a92450fd57f8063868efae9d4af74db02 (diff) | |
download | lwn-0a10247914a5cad3caf7ef8a255c54c4d3ed2062.tar.gz lwn-0a10247914a5cad3caf7ef8a255c54c4d3ed2062.zip |
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/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index db4cd1e7b51a..d40a81e8cc56 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -180,12 +180,10 @@ static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int n static void create_counter(struct perf_evsel *evsel, int cpu) { - char *filter = evsel->filter; struct perf_event_attr *attr = &evsel->attr; struct perf_header_attr *h_attr; struct perf_sample_id *sid; int thread_index; - int ret; for (thread_index = 0; thread_index < evsel_list->threads->nr; thread_index++) { h_attr = get_header_attr(attr, evsel->idx); @@ -204,16 +202,6 @@ static void create_counter(struct perf_evsel *evsel, int cpu) pr_warning("Not enough memory to add id\n"); exit(-1); } - - if (filter != NULL) { - ret = ioctl(FD(evsel, cpu, thread_index), - PERF_EVENT_IOC_SET_FILTER, filter); - if (ret) { - error("failed to set filter with %d (%s)\n", errno, - strerror(errno)); - exit(-1); - } - } } if (!sample_type) @@ -367,6 +355,12 @@ try_again: } } + if (perf_evlist__set_filters(evlist)) { + error("failed to set filter with %d (%s)\n", errno, + strerror(errno)); + exit(-1); + } + if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) die("failed to mmap with %d (%s)\n", errno, strerror(errno)); |