aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c61
1 files changed, 28 insertions, 33 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5a11f13e56f9..9acca8856ccb 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -246,10 +246,10 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
246 struct hist_entry *he; 246 struct hist_entry *he;
247 247
248 pthread_mutex_lock(&evsel->hists.lock); 248 pthread_mutex_lock(&evsel->hists.lock);
249 he = __hists__add_entry(&evsel->hists, al, NULL, sample->period, 249 he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL,
250 sample->weight); 250 sample->period, sample->weight,
251 sample->transaction);
251 pthread_mutex_unlock(&evsel->hists.lock); 252 pthread_mutex_unlock(&evsel->hists.lock);
252
253 if (he == NULL) 253 if (he == NULL)
254 return NULL; 254 return NULL;
255 255
@@ -287,7 +287,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
287 return; 287 return;
288 } 288 }
289 289
290 hists__collapse_resort(&top->sym_evsel->hists); 290 hists__collapse_resort(&top->sym_evsel->hists, NULL);
291 hists__output_resort(&top->sym_evsel->hists); 291 hists__output_resort(&top->sym_evsel->hists);
292 hists__decay_entries(&top->sym_evsel->hists, 292 hists__decay_entries(&top->sym_evsel->hists,
293 top->hide_user_symbols, 293 top->hide_user_symbols,
@@ -553,7 +553,7 @@ static void perf_top__sort_new_samples(void *arg)
553 if (t->evlist->selected != NULL) 553 if (t->evlist->selected != NULL)
554 t->sym_evsel = t->evlist->selected; 554 t->sym_evsel = t->evlist->selected;
555 555
556 hists__collapse_resort(&t->sym_evsel->hists); 556 hists__collapse_resort(&t->sym_evsel->hists, NULL);
557 hists__output_resort(&t->sym_evsel->hists); 557 hists__output_resort(&t->sym_evsel->hists);
558 hists__decay_entries(&t->sym_evsel->hists, 558 hists__decay_entries(&t->sym_evsel->hists,
559 t->hide_user_symbols, 559 t->hide_user_symbols,
@@ -771,7 +771,8 @@ static void perf_event__process_sample(struct perf_tool *tool,
771 sample->callchain) { 771 sample->callchain) {
772 err = machine__resolve_callchain(machine, evsel, 772 err = machine__resolve_callchain(machine, evsel,
773 al.thread, sample, 773 al.thread, sample,
774 &parent, &al); 774 &parent, &al,
775 top->max_stack);
775 if (err) 776 if (err)
776 return; 777 return;
777 } 778 }
@@ -856,7 +857,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
856 &sample, machine); 857 &sample, machine);
857 } else if (event->header.type < PERF_RECORD_MAX) { 858 } else if (event->header.type < PERF_RECORD_MAX) {
858 hists__inc_nr_events(&evsel->hists, event->header.type); 859 hists__inc_nr_events(&evsel->hists, event->header.type);
859 machine__process_event(machine, event); 860 machine__process_event(machine, event, &sample);
860 } else 861 } else
861 ++session->stats.nr_unknown_events; 862 ++session->stats.nr_unknown_events;
862next_event: 863next_event:
@@ -932,11 +933,8 @@ static int __cmd_top(struct perf_top *top)
932 struct perf_record_opts *opts = &top->record_opts; 933 struct perf_record_opts *opts = &top->record_opts;
933 pthread_t thread; 934 pthread_t thread;
934 int ret; 935 int ret;
935 /* 936
936 * FIXME: perf_session__new should allow passing a O_MMAP, so that all this 937 top->session = perf_session__new(NULL, false, NULL);
937 * mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
938 */
939 top->session = perf_session__new(NULL, O_WRONLY, false, false, NULL);
940 if (top->session == NULL) 938 if (top->session == NULL)
941 return -ENOMEM; 939 return -ENOMEM;
942 940
@@ -1043,7 +1041,7 @@ parse_percent_limit(const struct option *opt, const char *arg,
1043 1041
1044int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) 1042int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1045{ 1043{
1046 int status; 1044 int status = -1;
1047 char errbuf[BUFSIZ]; 1045 char errbuf[BUFSIZ];
1048 struct perf_top top = { 1046 struct perf_top top = {
1049 .count_filter = 5, 1047 .count_filter = 5,
@@ -1053,10 +1051,11 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1053 .user_freq = UINT_MAX, 1051 .user_freq = UINT_MAX,
1054 .user_interval = ULLONG_MAX, 1052 .user_interval = ULLONG_MAX,
1055 .freq = 4000, /* 4 KHz */ 1053 .freq = 4000, /* 4 KHz */
1056 .target = { 1054 .target = {
1057 .uses_mmap = true, 1055 .uses_mmap = true,
1058 }, 1056 },
1059 }, 1057 },
1058 .max_stack = PERF_MAX_STACK_DEPTH,
1060 .sym_pcnt_filter = 5, 1059 .sym_pcnt_filter = 5,
1061 }; 1060 };
1062 struct perf_record_opts *opts = &top.record_opts; 1061 struct perf_record_opts *opts = &top.record_opts;
@@ -1076,10 +1075,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1076 "list of cpus to monitor"), 1075 "list of cpus to monitor"),
1077 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, 1076 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
1078 "file", "vmlinux pathname"), 1077 "file", "vmlinux pathname"),
1078 OPT_BOOLEAN(0, "ignore-vmlinux", &symbol_conf.ignore_vmlinux,
1079 "don't load vmlinux even if found"),
1079 OPT_BOOLEAN('K', "hide_kernel_symbols", &top.hide_kernel_symbols, 1080 OPT_BOOLEAN('K', "hide_kernel_symbols", &top.hide_kernel_symbols,
1080 "hide kernel symbols"), 1081 "hide kernel symbols"),
1081 OPT_UINTEGER('m', "mmap-pages", &opts->mmap_pages, 1082 OPT_CALLBACK('m', "mmap-pages", &opts->mmap_pages, "pages",
1082 "number of mmap data pages"), 1083 "number of mmap data pages",
1084 perf_evlist__parse_mmap_pages),
1083 OPT_INTEGER('r', "realtime", &top.realtime_prio, 1085 OPT_INTEGER('r', "realtime", &top.realtime_prio,
1084 "collect data with this RT SCHED_FIFO priority"), 1086 "collect data with this RT SCHED_FIFO priority"),
1085 OPT_INTEGER('d', "delay", &top.delay_secs, 1087 OPT_INTEGER('d', "delay", &top.delay_secs,
@@ -1105,7 +1107,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1105 OPT_INCR('v', "verbose", &verbose, 1107 OPT_INCR('v', "verbose", &verbose,
1106 "be more verbose (show counter open errors, etc)"), 1108 "be more verbose (show counter open errors, etc)"),
1107 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 1109 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
1108 "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight"), 1110 "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight,"
1111 " abort, in_tx, transaction"),
1109 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, 1112 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
1110 "Show a column with the number of samples"), 1113 "Show a column with the number of samples"),
1111 OPT_CALLBACK_NOOPT('G', NULL, &top.record_opts, 1114 OPT_CALLBACK_NOOPT('G', NULL, &top.record_opts,
@@ -1114,6 +1117,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1114 OPT_CALLBACK(0, "call-graph", &top.record_opts, 1117 OPT_CALLBACK(0, "call-graph", &top.record_opts,
1115 "mode[,dump_size]", record_callchain_help, 1118 "mode[,dump_size]", record_callchain_help,
1116 &parse_callchain_opt), 1119 &parse_callchain_opt),
1120 OPT_INTEGER(0, "max-stack", &top.max_stack,
1121 "Set the maximum stack depth when parsing the callchain. "
1122 "Default: " __stringify(PERF_MAX_STACK_DEPTH)),
1117 OPT_CALLBACK(0, "ignore-callees", NULL, "regex", 1123 OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
1118 "ignore callees of these functions in call graphs", 1124 "ignore callees of these functions in call graphs",
1119 report_parse_ignore_callees_opt), 1125 report_parse_ignore_callees_opt),
@@ -1154,8 +1160,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1154 if (sort_order == default_sort_order) 1160 if (sort_order == default_sort_order)
1155 sort_order = "dso,symbol"; 1161 sort_order = "dso,symbol";
1156 1162
1157 if (setup_sorting() < 0) 1163 if (setup_sorting() < 0) {
1158 usage_with_options(top_usage, options); 1164 parse_options_usage(top_usage, options, "s", 1);
1165 goto out_delete_evlist;
1166 }
1159 1167
1160 /* display thread wants entries to be collapsed in a different tree */ 1168 /* display thread wants entries to be collapsed in a different tree */
1161 sort__need_collapse = 1; 1169 sort__need_collapse = 1;
@@ -1201,20 +1209,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1201 if (top.delay_secs < 1) 1209 if (top.delay_secs < 1)
1202 top.delay_secs = 1; 1210 top.delay_secs = 1;
1203 1211
1204 if (opts->user_interval != ULLONG_MAX) 1212 if (perf_record_opts__config(opts)) {
1205 opts->default_interval = opts->user_interval;
1206 if (opts->user_freq != UINT_MAX)
1207 opts->freq = opts->user_freq;
1208
1209 /*
1210 * User specified count overrides default frequency.
1211 */
1212 if (opts->default_interval)
1213 opts->freq = 0;
1214 else if (opts->freq) {
1215 opts->default_interval = opts->freq;
1216 } else {
1217 ui__error("frequency and count are zero, aborting\n");
1218 status = -EINVAL; 1213 status = -EINVAL;
1219 goto out_delete_maps; 1214 goto out_delete_maps;
1220 } 1215 }