aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 20:09:46 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 21:24:36 -0500
commit86bd5e8603b00b06189328c6d7034d2dc434d6bb (patch)
tree7d6c4fa6c55b367d0ab970835fa2fad4634ae8e4 /tools/perf
parent5c98d466e49267a9221f30958d45cd06f794269a (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')
-rw-r--r--tools/perf/builtin-stat.c4
-rw-r--r--tools/perf/util/evsel.c24
-rw-r--r--tools/perf/util/evsel.h11
3 files changed, 22 insertions, 17 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 6b9146cd1ea9..02b2d8013a61 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -166,7 +166,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
166 PERF_FORMAT_TOTAL_TIME_RUNNING; 166 PERF_FORMAT_TOTAL_TIME_RUNNING;
167 167
168 if (system_wide) 168 if (system_wide)
169 return perf_evsel__open_per_cpu(evsel, cpus->nr, cpus->map); 169 return perf_evsel__open_per_cpu(evsel, cpus);
170 170
171 attr->inherit = !no_inherit; 171 attr->inherit = !no_inherit;
172 if (target_pid == -1 && target_tid == -1) { 172 if (target_pid == -1 && target_tid == -1) {
@@ -174,7 +174,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
174 attr->enable_on_exec = 1; 174 attr->enable_on_exec = 1;
175 } 175 }
176 176
177 return perf_evsel__open_per_thread(evsel, threads->nr, threads->map); 177 return perf_evsel__open_per_thread(evsel, threads);
178} 178}
179 179
180/* 180/*
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
126int perf_evsel__open_per_cpu(struct perf_evsel *evsel, int ncpus, int *cpu_map) 128int 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
147int perf_evsel__open_per_thread(struct perf_evsel *evsel, int nthreads, int *thread_map) 149int 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
168int perf_evsel__open(struct perf_evsel *evsel, int ncpus, int nthreads, 170int 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}
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index a62fb55cffa7..863d78d5ef1a 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -34,6 +34,9 @@ struct perf_evsel {
34 void *priv; 34 void *priv;
35}; 35};
36 36
37struct cpu_map;
38struct thread_map;
39
37struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx); 40struct perf_evsel *perf_evsel__new(u32 type, u64 config, int idx);
38void perf_evsel__delete(struct perf_evsel *evsel); 41void perf_evsel__delete(struct perf_evsel *evsel);
39 42
@@ -42,10 +45,10 @@ int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
42void perf_evsel__free_fd(struct perf_evsel *evsel); 45void perf_evsel__free_fd(struct perf_evsel *evsel);
43void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 46void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
44 47
45int perf_evsel__open_per_cpu(struct perf_evsel *evsel, int ncpus, int *cpu_map); 48int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus);
46int perf_evsel__open_per_thread(struct perf_evsel *evsel, int nthreads, int *thread_map); 49int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *threads);
47int perf_evsel__open(struct perf_evsel *evsel, int ncpus, int nthreads, 50int perf_evsel__open(struct perf_evsel *evsel,
48 int *cpu_map, int *thread_map); 51 struct cpu_map *cpus, struct thread_map *threads);
49 52
50#define perf_evsel__match(evsel, t, c) \ 53#define perf_evsel__match(evsel, t, c) \
51 (evsel->attr.type == PERF_TYPE_##t && \ 54 (evsel->attr.type == PERF_TYPE_##t && \