diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-29 05:05:52 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-29 05:05:52 -0500 |
commit | 806fb63007447622dd61d9767b4403919737e120 (patch) | |
tree | aa24bf21469afe000a95a4c5a6f810151166be9f | |
parent | ee29be625bd7b115d45eba4b0526ff3e24bf3ca0 (diff) |
perf evlist: Always do automatic allocation of pollfd and mmap structures
At first tools were required to do that, but while writing the python
bindings to simplify the API I made them auto-allocate when needed.
This just makes record, stat and top use that auto allocation,
simplifying them a bit.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-iokhcvkzzijr3keioubx8hlq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-record.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 19 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 4 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 2 |
5 files changed, 7 insertions, 27 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 7d4fdaacc8ba..766fa0a91a32 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -778,16 +778,10 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) | |||
778 | usage_with_options(record_usage, record_options); | 778 | usage_with_options(record_usage, record_options); |
779 | 779 | ||
780 | list_for_each_entry(pos, &evsel_list->entries, node) { | 780 | list_for_each_entry(pos, &evsel_list->entries, node) { |
781 | if (perf_evsel__alloc_fd(pos, evsel_list->cpus->nr, | ||
782 | evsel_list->threads->nr) < 0) | ||
783 | goto out_free_fd; | ||
784 | if (perf_header__push_event(pos->attr.config, event_name(pos))) | 781 | if (perf_header__push_event(pos->attr.config, event_name(pos))) |
785 | goto out_free_fd; | 782 | goto out_free_fd; |
786 | } | 783 | } |
787 | 784 | ||
788 | if (perf_evlist__alloc_pollfd(evsel_list) < 0) | ||
789 | goto out_free_fd; | ||
790 | |||
791 | if (rec->opts.user_interval != ULLONG_MAX) | 785 | if (rec->opts.user_interval != ULLONG_MAX) |
792 | rec->opts.default_interval = rec->opts.user_interval; | 786 | rec->opts.default_interval = rec->opts.user_interval; |
793 | if (rec->opts.user_freq != UINT_MAX) | 787 | if (rec->opts.user_freq != UINT_MAX) |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 227befbecec8..4356144f1214 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -1240,8 +1240,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) | |||
1240 | 1240 | ||
1241 | list_for_each_entry(pos, &evsel_list->entries, node) { | 1241 | list_for_each_entry(pos, &evsel_list->entries, node) { |
1242 | if (perf_evsel__alloc_stat_priv(pos) < 0 || | 1242 | if (perf_evsel__alloc_stat_priv(pos) < 0 || |
1243 | perf_evsel__alloc_counts(pos, evsel_list->cpus->nr) < 0 || | 1243 | perf_evsel__alloc_counts(pos, evsel_list->cpus->nr) < 0) |
1244 | perf_evsel__alloc_fd(pos, evsel_list->cpus->nr, evsel_list->threads->nr) < 0) | ||
1245 | goto out_free_fd; | 1244 | goto out_free_fd; |
1246 | } | 1245 | } |
1247 | 1246 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 50ff362ff012..c3836b966ccf 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -1034,9 +1034,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset) | |||
1034 | symbol_conf.use_callchain = false; | 1034 | symbol_conf.use_callchain = false; |
1035 | 1035 | ||
1036 | return 0; | 1036 | return 0; |
1037 | } | 1037 | } else |
1038 | |||
1039 | else | ||
1040 | return -1; | 1038 | return -1; |
1041 | 1039 | ||
1042 | /* get the min percentage */ | 1040 | /* get the min percentage */ |
@@ -1225,22 +1223,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1225 | } | 1223 | } |
1226 | 1224 | ||
1227 | list_for_each_entry(pos, &top.evlist->entries, node) { | 1225 | list_for_each_entry(pos, &top.evlist->entries, node) { |
1228 | if (perf_evsel__alloc_fd(pos, top.evlist->cpus->nr, | ||
1229 | top.evlist->threads->nr) < 0) | ||
1230 | goto out_free_fd; | ||
1231 | /* | 1226 | /* |
1232 | * Fill in the ones not specifically initialized via -c: | 1227 | * Fill in the ones not specifically initialized via -c: |
1233 | */ | 1228 | */ |
1234 | if (pos->attr.sample_period) | 1229 | if (!pos->attr.sample_period) |
1235 | continue; | 1230 | pos->attr.sample_period = top.default_interval; |
1236 | |||
1237 | pos->attr.sample_period = top.default_interval; | ||
1238 | } | 1231 | } |
1239 | 1232 | ||
1240 | if (perf_evlist__alloc_pollfd(top.evlist) < 0 || | ||
1241 | perf_evlist__alloc_mmap(top.evlist) < 0) | ||
1242 | goto out_free_fd; | ||
1243 | |||
1244 | top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node); | 1233 | top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node); |
1245 | 1234 | ||
1246 | symbol_conf.priv_size = sizeof(struct annotation); | 1235 | symbol_conf.priv_size = sizeof(struct annotation); |
@@ -1270,7 +1259,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1270 | } | 1259 | } |
1271 | 1260 | ||
1272 | status = __cmd_top(&top); | 1261 | status = __cmd_top(&top); |
1273 | out_free_fd: | 1262 | |
1274 | perf_evlist__delete(top.evlist); | 1263 | perf_evlist__delete(top.evlist); |
1275 | 1264 | ||
1276 | return status; | 1265 | return status; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index b36f26fe767a..8b19e7a1e881 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -275,7 +275,7 @@ void perf_evlist__enable(struct perf_evlist *evlist) | |||
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) | 278 | static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) |
279 | { | 279 | { |
280 | int nfds = evlist->cpus->nr * evlist->threads->nr * evlist->nr_entries; | 280 | int nfds = evlist->cpus->nr * evlist->threads->nr * evlist->nr_entries; |
281 | evlist->pollfd = malloc(sizeof(struct pollfd) * nfds); | 281 | evlist->pollfd = malloc(sizeof(struct pollfd) * nfds); |
@@ -431,7 +431,7 @@ void perf_evlist__munmap(struct perf_evlist *evlist) | |||
431 | evlist->mmap = NULL; | 431 | evlist->mmap = NULL; |
432 | } | 432 | } |
433 | 433 | ||
434 | int perf_evlist__alloc_mmap(struct perf_evlist *evlist) | 434 | static int perf_evlist__alloc_mmap(struct perf_evlist *evlist) |
435 | { | 435 | { |
436 | evlist->nr_mmaps = evlist->cpus->nr; | 436 | evlist->nr_mmaps = evlist->cpus->nr; |
437 | if (evlist->cpus->map[0] == -1) | 437 | if (evlist->cpus->map[0] == -1) |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index f94ed7e0d987..8922aeed0467 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -72,7 +72,6 @@ int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist, | |||
72 | void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel, | 72 | void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel, |
73 | int cpu, int thread, u64 id); | 73 | int cpu, int thread, u64 id); |
74 | 74 | ||
75 | int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); | ||
76 | void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); | 75 | void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); |
77 | 76 | ||
78 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); | 77 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); |
@@ -89,7 +88,6 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, | |||
89 | const char *argv[]); | 88 | const char *argv[]); |
90 | int perf_evlist__start_workload(struct perf_evlist *evlist); | 89 | int perf_evlist__start_workload(struct perf_evlist *evlist); |
91 | 90 | ||
92 | int perf_evlist__alloc_mmap(struct perf_evlist *evlist); | ||
93 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages, | 91 | int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages, |
94 | bool overwrite); | 92 | bool overwrite); |
95 | void perf_evlist__munmap(struct perf_evlist *evlist); | 93 | void perf_evlist__munmap(struct perf_evlist *evlist); |