diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /tools/perf/builtin-top.c | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 89 |
1 files changed, 50 insertions, 39 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 71e6402..5a11f13 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, struct hist_entry *he; pthread_mutex_lock(&evsel->hists.lock); - he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, - sample->period, sample->weight, - sample->transaction); + he = __hists__add_entry(&evsel->hists, al, NULL, sample->period, + sample->weight); pthread_mutex_unlock(&evsel->hists.lock); + if (he == NULL) return NULL; @@ -287,7 +287,7 @@ static void perf_top__print_sym_table(struct perf_top *top) return; } - hists__collapse_resort(&top->sym_evsel->hists, NULL); + hists__collapse_resort(&top->sym_evsel->hists); hists__output_resort(&top->sym_evsel->hists); hists__decay_entries(&top->sym_evsel->hists, top->hide_user_symbols, @@ -553,7 +553,7 @@ static void perf_top__sort_new_samples(void *arg) if (t->evlist->selected != NULL) t->sym_evsel = t->evlist->selected; - hists__collapse_resort(&t->sym_evsel->hists, NULL); + hists__collapse_resort(&t->sym_evsel->hists); hists__output_resort(&t->sym_evsel->hists); hists__decay_entries(&t->sym_evsel->hists, t->hide_user_symbols, @@ -771,8 +771,7 @@ static void perf_event__process_sample(struct perf_tool *tool, sample->callchain) { err = machine__resolve_callchain(machine, evsel, al.thread, sample, - &parent, &al, - top->max_stack); + &parent, &al); if (err) return; } @@ -857,7 +856,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) &sample, machine); } else if (event->header.type < PERF_RECORD_MAX) { hists__inc_nr_events(&evsel->hists, event->header.type); - machine__process_event(machine, event, &sample); + machine__process_event(machine, event); } else ++session->stats.nr_unknown_events; next_event: @@ -933,8 +932,11 @@ static int __cmd_top(struct perf_top *top) struct perf_record_opts *opts = &top->record_opts; pthread_t thread; int ret; - - top->session = perf_session__new(NULL, false, NULL); + /* + * FIXME: perf_session__new should allow passing a O_MMAP, so that all this + * mmap reading, etc is encapsulated in it. Use O_WRONLY for now. + */ + top->session = perf_session__new(NULL, O_WRONLY, false, false, NULL); if (top->session == NULL) return -ENOMEM; @@ -950,8 +952,14 @@ static int __cmd_top(struct perf_top *top) if (ret) goto out_delete; - machine__synthesize_threads(&top->session->machines.host, &opts->target, - top->evlist->threads, false); + if (perf_target__has_task(&opts->target)) + perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, + perf_event__process, + &top->session->machines.host); + else + perf_event__synthesize_threads(&top->tool, perf_event__process, + &top->session->machines.host); + ret = perf_top__start_counters(top); if (ret) goto out_delete; @@ -967,7 +975,7 @@ static int __cmd_top(struct perf_top *top) * XXX 'top' still doesn't start workloads like record, trace, but should, * so leave the check here. */ - if (!target__none(&opts->target)) + if (!perf_target__none(&opts->target)) perf_evlist__enable(top->evlist); /* Wait for a minimal set of events before starting the snapshot */ @@ -1035,7 +1043,7 @@ parse_percent_limit(const struct option *opt, const char *arg, int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) { - int status = -1; + int status; char errbuf[BUFSIZ]; struct perf_top top = { .count_filter = 5, @@ -1045,15 +1053,14 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) .user_freq = UINT_MAX, .user_interval = ULLONG_MAX, .freq = 4000, /* 4 KHz */ - .target = { + .target = { .uses_mmap = true, }, }, - .max_stack = PERF_MAX_STACK_DEPTH, .sym_pcnt_filter = 5, }; struct perf_record_opts *opts = &top.record_opts; - struct target *target = &opts->target; + struct perf_target *target = &opts->target; const struct option options[] = { OPT_CALLBACK('e', "event", &top.evlist, "event", "event selector. use 'perf list' to list available events", @@ -1069,13 +1076,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) "list of cpus to monitor"), OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, "file", "vmlinux pathname"), - OPT_BOOLEAN(0, "ignore-vmlinux", &symbol_conf.ignore_vmlinux, - "don't load vmlinux even if found"), OPT_BOOLEAN('K', "hide_kernel_symbols", &top.hide_kernel_symbols, "hide kernel symbols"), - OPT_CALLBACK('m', "mmap-pages", &opts->mmap_pages, "pages", - "number of mmap data pages", - perf_evlist__parse_mmap_pages), + OPT_UINTEGER('m', "mmap-pages", &opts->mmap_pages, + "number of mmap data pages"), OPT_INTEGER('r', "realtime", &top.realtime_prio, "collect data with this RT SCHED_FIFO priority"), OPT_INTEGER('d', "delay", &top.delay_secs, @@ -1101,8 +1105,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) OPT_INCR('v', "verbose", &verbose, "be more verbose (show counter open errors, etc)"), OPT_STRING('s', "sort", &sort_order, "key[,key2...]", - "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight," - " abort, in_tx, transaction"), + "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight"), OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, "Show a column with the number of samples"), OPT_CALLBACK_NOOPT('G', NULL, &top.record_opts, @@ -1111,9 +1114,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) OPT_CALLBACK(0, "call-graph", &top.record_opts, "mode[,dump_size]", record_callchain_help, &parse_callchain_opt), - OPT_INTEGER(0, "max-stack", &top.max_stack, - "Set the maximum stack depth when parsing the callchain. " - "Default: " __stringify(PERF_MAX_STACK_DEPTH)), OPT_CALLBACK(0, "ignore-callees", NULL, "regex", "ignore callees of these functions in call graphs", report_parse_ignore_callees_opt), @@ -1154,10 +1154,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (sort_order == default_sort_order) sort_order = "dso,symbol"; - if (setup_sorting() < 0) { - parse_options_usage(top_usage, options, "s", 1); - goto out_delete_evlist; - } + if (setup_sorting() < 0) + usage_with_options(top_usage, options); /* display thread wants entries to be collapsed in a different tree */ sort__need_collapse = 1; @@ -1169,24 +1167,24 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) setup_browser(false); - status = target__validate(target); + status = perf_target__validate(target); if (status) { - target__strerror(target, status, errbuf, BUFSIZ); - ui__warning("%s\n", errbuf); + perf_target__strerror(target, status, errbuf, BUFSIZ); + ui__warning("%s", errbuf); } - status = target__parse_uid(target); + status = perf_target__parse_uid(target); if (status) { int saved_errno = errno; - target__strerror(target, status, errbuf, BUFSIZ); - ui__error("%s\n", errbuf); + perf_target__strerror(target, status, errbuf, BUFSIZ); + ui__error("%s", errbuf); status = -saved_errno; goto out_delete_evlist; } - if (target__none(target)) + if (perf_target__none(target)) target->system_wide = true; if (perf_evlist__create_maps(top.evlist, target) < 0) @@ -1203,7 +1201,20 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (top.delay_secs < 1) top.delay_secs = 1; - if (perf_record_opts__config(opts)) { + if (opts->user_interval != ULLONG_MAX) + opts->default_interval = opts->user_interval; + if (opts->user_freq != UINT_MAX) + opts->freq = opts->user_freq; + + /* + * User specified count overrides default frequency. + */ + if (opts->default_interval) + opts->freq = 0; + else if (opts->freq) { + opts->default_interval = opts->freq; + } else { + ui__error("frequency and count are zero, aborting\n"); status = -EINVAL; goto out_delete_maps; } |