aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-11-29 05:05:52 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-11-29 05:05:52 -0500
commit806fb63007447622dd61d9767b4403919737e120 (patch)
treeaa24bf21469afe000a95a4c5a6f810151166be9f /tools/perf/builtin-top.c
parentee29be625bd7b115d45eba4b0526ff3e24bf3ca0 (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>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c19
1 files changed, 4 insertions, 15 deletions
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);
1273out_free_fd: 1262
1274 perf_evlist__delete(top.evlist); 1263 perf_evlist__delete(top.evlist);
1275 1264
1276 return status; 1265 return status;