diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-03 20:09:46 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-03 21:24:36 -0500 |
commit | 86bd5e8603b00b06189328c6d7034d2dc434d6bb (patch) | |
tree | 7d6c4fa6c55b367d0ab970835fa2fad4634ae8e4 /tools/perf/util/evsel.c | |
parent | 5c98d466e49267a9221f30958d45cd06f794269a (diff) |
perf evsel: Use {cpu,thread}_map to shorten list of parameters
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 | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e62cc5e050ab..e44be528c09f 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1,6 +1,8 @@ | |||
1 | #include "evsel.h" | 1 | #include "evsel.h" |
2 | #include "../perf.h" | 2 | #include "../perf.h" |
3 | #include "util.h" | 3 | #include "util.h" |
4 | #include "cpumap.h" | ||
5 | #include "thread.h" | ||
4 | 6 | ||
5 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | 7 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
6 | 8 | ||
@@ -123,13 +125,13 @@ int __perf_evsel__read(struct perf_evsel *evsel, | |||
123 | return 0; | 125 | return 0; |
124 | } | 126 | } |
125 | 127 | ||
126 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, int ncpus, int *cpu_map) | 128 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus) |
127 | { | 129 | { |
128 | int cpu; | 130 | int cpu; |
129 | 131 | ||
130 | for (cpu = 0; cpu < ncpus; cpu++) { | 132 | for (cpu = 0; cpu < cpus->nr; cpu++) { |
131 | FD(evsel, cpu, 0) = sys_perf_event_open(&evsel->attr, -1, | 133 | FD(evsel, cpu, 0) = sys_perf_event_open(&evsel->attr, -1, |
132 | cpu_map[cpu], -1, 0); | 134 | cpus->map[cpu], -1, 0); |
133 | if (FD(evsel, cpu, 0) < 0) | 135 | if (FD(evsel, cpu, 0) < 0) |
134 | goto out_close; | 136 | goto out_close; |
135 | } | 137 | } |
@@ -144,13 +146,13 @@ out_close: | |||
144 | return -1; | 146 | return -1; |
145 | } | 147 | } |
146 | 148 | ||
147 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, int nthreads, int *thread_map) | 149 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *threads) |
148 | { | 150 | { |
149 | int thread; | 151 | int thread; |
150 | 152 | ||
151 | for (thread = 0; thread < nthreads; thread++) { | 153 | for (thread = 0; thread < threads->nr; thread++) { |
152 | FD(evsel, 0, thread) = sys_perf_event_open(&evsel->attr, | 154 | FD(evsel, 0, thread) = sys_perf_event_open(&evsel->attr, |
153 | thread_map[thread], -1, -1, 0); | 155 | threads->map[thread], -1, -1, 0); |
154 | if (FD(evsel, 0, thread) < 0) | 156 | if (FD(evsel, 0, thread) < 0) |
155 | goto out_close; | 157 | goto out_close; |
156 | } | 158 | } |
@@ -165,11 +167,11 @@ out_close: | |||
165 | return -1; | 167 | return -1; |
166 | } | 168 | } |
167 | 169 | ||
168 | int perf_evsel__open(struct perf_evsel *evsel, int ncpus, int nthreads, | 170 | int perf_evsel__open(struct perf_evsel *evsel, |
169 | int *cpu_map, int *thread_map) | 171 | struct cpu_map *cpus, struct thread_map *threads) |
170 | { | 172 | { |
171 | if (nthreads < 0) | 173 | if (threads == NULL) |
172 | return perf_evsel__open_per_cpu(evsel, ncpus, cpu_map); | 174 | return perf_evsel__open_per_cpu(evsel, cpus); |
173 | 175 | ||
174 | return perf_evsel__open_per_thread(evsel, nthreads, thread_map); | 176 | return perf_evsel__open_per_thread(evsel, threads); |
175 | } | 177 | } |