Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234477
b: refs/heads/master
c: 0a10247
h: refs/heads/master
i:
  234475: eb59b6d
v: v3
  • Loading branch information
Frederic Weisbecker committed Mar 2, 2011
1 parent 8010e77 commit f1d1cb1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5807806a92450fd57f8063868efae9d4af74db02
refs/heads/master: 0a10247914a5cad3caf7ef8a255c54c4d3ed2062
18 changes: 6 additions & 12 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -367,6 +355,12 @@ static void open_counters(struct perf_evlist *evlist)
}
}

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));

Expand Down
28 changes: 28 additions & 0 deletions trunk/tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,31 @@ void perf_evlist__delete_maps(struct perf_evlist *evlist)
evlist->cpus = NULL;
evlist->threads = NULL;
}

int perf_evlist__set_filters(struct perf_evlist *evlist)
{
const struct thread_map *threads = evlist->threads;
const struct cpu_map *cpus = evlist->cpus;
struct perf_evsel *evsel;
char *filter;
int thread;
int cpu;
int err;
int fd;

list_for_each_entry(evsel, &evlist->entries, node) {
filter = evsel->filter;
if (!filter)
continue;
for (cpu = 0; cpu < cpus->nr; cpu++) {
for (thread = 0; thread < threads->nr; thread++) {
fd = FD(evsel, cpu, thread);
err = ioctl(fd, PERF_EVENT_IOC_SET_FILTER, filter);
if (err)
return err;
}
}
}

return 0;
}
1 change: 1 addition & 0 deletions trunk/tools/perf/util/evlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
int perf_evlist__create_maps(struct perf_evlist *evlist, pid_t target_pid,
pid_t target_tid, const char *cpu_list);
void perf_evlist__delete_maps(struct perf_evlist *evlist);
int perf_evlist__set_filters(struct perf_evlist *evlist);

#endif /* __PERF_EVLIST_H */

0 comments on commit f1d1cb1

Please sign in to comment.