diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-record.c | 18 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 28 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 1 |
3 files changed, 35 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 | |||
180 | 180 | ||
181 | static void create_counter(struct perf_evsel *evsel, int cpu) | 181 | static void create_counter(struct perf_evsel *evsel, int cpu) |
182 | { | 182 | { |
183 | char *filter = evsel->filter; | ||
184 | struct perf_event_attr *attr = &evsel->attr; | 183 | struct perf_event_attr *attr = &evsel->attr; |
185 | struct perf_header_attr *h_attr; | 184 | struct perf_header_attr *h_attr; |
186 | struct perf_sample_id *sid; | 185 | struct perf_sample_id *sid; |
187 | int thread_index; | 186 | int thread_index; |
188 | int ret; | ||
189 | 187 | ||
190 | for (thread_index = 0; thread_index < evsel_list->threads->nr; thread_index++) { | 188 | for (thread_index = 0; thread_index < evsel_list->threads->nr; thread_index++) { |
191 | h_attr = get_header_attr(attr, evsel->idx); | 189 | h_attr = get_header_attr(attr, evsel->idx); |
@@ -204,16 +202,6 @@ static void create_counter(struct perf_evsel *evsel, int cpu) | |||
204 | pr_warning("Not enough memory to add id\n"); | 202 | pr_warning("Not enough memory to add id\n"); |
205 | exit(-1); | 203 | exit(-1); |
206 | } | 204 | } |
207 | |||
208 | if (filter != NULL) { | ||
209 | ret = ioctl(FD(evsel, cpu, thread_index), | ||
210 | PERF_EVENT_IOC_SET_FILTER, filter); | ||
211 | if (ret) { | ||
212 | error("failed to set filter with %d (%s)\n", errno, | ||
213 | strerror(errno)); | ||
214 | exit(-1); | ||
215 | } | ||
216 | } | ||
217 | } | 205 | } |
218 | 206 | ||
219 | if (!sample_type) | 207 | if (!sample_type) |
@@ -367,6 +355,12 @@ try_again: | |||
367 | } | 355 | } |
368 | } | 356 | } |
369 | 357 | ||
358 | if (perf_evlist__set_filters(evlist)) { | ||
359 | error("failed to set filter with %d (%s)\n", errno, | ||
360 | strerror(errno)); | ||
361 | exit(-1); | ||
362 | } | ||
363 | |||
370 | if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) | 364 | if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) |
371 | die("failed to mmap with %d (%s)\n", errno, strerror(errno)); | 365 | die("failed to mmap with %d (%s)\n", errno, strerror(errno)); |
372 | 366 | ||
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 | } | ||
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index c9884056097c..b75805aeb7e4 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -60,5 +60,6 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist, | |||
60 | int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, | 60 | int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid, |
61 | pid_t target_tid, const char *cpu_list); | 61 | pid_t target_tid, const char *cpu_list); |
62 | void perf_evlist__delete_maps(struct perf_evlist *evlist); | 62 | void perf_evlist__delete_maps(struct perf_evlist *evlist); |
63 | int perf_evlist__set_filters(struct perf_evlist *evlist); | ||
63 | 64 | ||
64 | #endif /* __PERF_EVLIST_H */ | 65 | #endif /* __PERF_EVLIST_H */ |