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-report.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-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 124 |
1 files changed, 38 insertions, 86 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 8cf8e66..72eae74 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -33,10 +33,8 @@ #include "util/thread.h" #include "util/sort.h" #include "util/hist.h" -#include "util/data.h" #include "arch/common.h" -#include <dlfcn.h> #include <linux/bitmap.h> struct perf_report { @@ -49,7 +47,6 @@ struct perf_report { bool show_threads; bool inverted_callchain; bool mem_mode; - int max_stack; struct perf_read_values show_threads_values; const char *pretty_printing_style; const char *cpu_list; @@ -91,8 +88,7 @@ static int perf_report__add_mem_hist_entry(struct perf_tool *tool, if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { err = machine__resolve_callchain(machine, evsel, al->thread, - sample, &parent, al, - rep->max_stack); + sample, &parent, al); if (err) return err; } @@ -115,8 +111,7 @@ static int perf_report__add_mem_hist_entry(struct perf_tool *tool, * and this is indirectly achieved by passing period=weight here * and the he_stat__add_period() function. */ - he = __hists__add_entry(&evsel->hists, al, parent, NULL, mi, - cost, cost, 0); + he = __hists__add_mem_entry(&evsel->hists, al, parent, mi, cost, cost); if (!he) return -ENOMEM; @@ -184,8 +179,7 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool, if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { err = machine__resolve_callchain(machine, evsel, al->thread, - sample, &parent, al, - rep->max_stack); + sample, &parent, al); if (err) return err; } @@ -201,16 +195,12 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool, err = -ENOMEM; - /* overwrite the 'al' to branch-to info */ - al->map = bi[i].to.map; - al->sym = bi[i].to.sym; - al->addr = bi[i].to.addr; /* * The report shows the percentage of total branches captured * and not events sampled. Thus we use a pseudo period of 1. */ - he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL, - 1, 1, 0); + he = __hists__add_branch_entry(&evsel->hists, al, parent, + &bi[i], 1, 1); if (he) { struct annotation *notes; bx = he->branch_info; @@ -252,28 +242,24 @@ out: return err; } -static int perf_evsel__add_hist_entry(struct perf_tool *tool, - struct perf_evsel *evsel, +static int perf_evsel__add_hist_entry(struct perf_evsel *evsel, struct addr_location *al, struct perf_sample *sample, struct machine *machine) { - struct perf_report *rep = container_of(tool, struct perf_report, tool); struct symbol *parent = NULL; int err = 0; struct hist_entry *he; if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { err = machine__resolve_callchain(machine, evsel, al->thread, - sample, &parent, al, - rep->max_stack); + sample, &parent, al); if (err) return err; } - he = __hists__add_entry(&evsel->hists, al, parent, NULL, NULL, - sample->period, sample->weight, - sample->transaction); + he = __hists__add_entry(&evsel->hists, al, parent, sample->period, + sample->weight); if (he == NULL) return -ENOMEM; @@ -344,8 +330,7 @@ static int process_sample_event(struct perf_tool *tool, if (al.map != NULL) al.map->dso->hit = 1; - ret = perf_evsel__add_hist_entry(tool, evsel, &al, sample, - machine); + ret = perf_evsel__add_hist_entry(evsel, &al, sample, machine); if (ret < 0) pr_debug("problem incrementing symbol period, skipping event\n"); } @@ -379,11 +364,10 @@ static int process_read_event(struct perf_tool *tool, /* For pipe mode, sample_type is not currently set */ static int perf_report__setup_sample_type(struct perf_report *rep) { - struct perf_session *session = rep->session; - u64 sample_type = perf_evlist__combined_sample_type(session->evlist); - bool is_pipe = perf_data_file__is_pipe(session->file); + struct perf_session *self = rep->session; + u64 sample_type = perf_evlist__combined_sample_type(self->evlist); - if (!is_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) { + if (!self->fd_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) { if (sort__has_parent) { ui__error("Selected --sort parent, but no " "callchain data. Did you call " @@ -406,7 +390,7 @@ static int perf_report__setup_sample_type(struct perf_report *rep) } if (sort__mode == SORT_MODE__BRANCH) { - if (!is_pipe && + if (!self->fd_pipe && !(sample_type & PERF_SAMPLE_BRANCH_STACK)) { ui__error("Selected -b but no branch data. " "Did you call perf record without -b?\n"); @@ -423,14 +407,14 @@ static void sig_handler(int sig __maybe_unused) } static size_t hists__fprintf_nr_sample_events(struct perf_report *rep, - struct hists *hists, + struct hists *self, const char *evname, FILE *fp) { size_t ret; char unit; - unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; - u64 nr_events = hists->stats.total_period; - struct perf_evsel *evsel = hists_to_evsel(hists); + unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE]; + u64 nr_events = self->stats.total_period; + struct perf_evsel *evsel = hists_to_evsel(self); char buf[512]; size_t size = sizeof(buf); @@ -502,8 +486,6 @@ static int __cmd_report(struct perf_report *rep) struct map *kernel_map; struct kmap *kernel_kmap; const char *help = "For a higher level overview, try: perf report --sort comm,dso"; - struct ui_progress prog; - struct perf_data_file *file = session->file; signal(SIGINT, sig_handler); @@ -565,19 +547,13 @@ static int __cmd_report(struct perf_report *rep) } nr_samples = 0; - list_for_each_entry(pos, &session->evlist->entries, node) - nr_samples += pos->hists.nr_entries; - - ui_progress__init(&prog, nr_samples, "Merging related events..."); - - nr_samples = 0; list_for_each_entry(pos, &session->evlist->entries, node) { struct hists *hists = &pos->hists; if (pos->idx == 0) hists->symbol_filter_str = rep->symbol_filter_str; - hists__collapse_resort(hists, &prog); + hists__collapse_resort(hists); nr_samples += hists->stats.nr_events[PERF_RECORD_SAMPLE]; /* Non-group events are considered as leader */ @@ -589,13 +565,12 @@ static int __cmd_report(struct perf_report *rep) hists__link(leader_hists, hists); } } - ui_progress__finish(); if (session_done()) return 0; if (nr_samples == 0) { - ui__error("The %s file has no samples!\n", file->path); + ui__error("The %s file has no samples!\n", session->filename); return 0; } @@ -616,19 +591,8 @@ static int __cmd_report(struct perf_report *rep) ret = 0; } else if (use_browser == 2) { - int (*hist_browser)(struct perf_evlist *, - const char *, - struct hist_browser_timer *, - float min_pcnt); - - hist_browser = dlsym(perf_gtk_handle, - "perf_evlist__gtk_browse_hists"); - if (hist_browser == NULL) { - ui__error("GTK browser not found!\n"); - return ret; - } - hist_browser(session->evlist, help, NULL, - rep->min_percent); + perf_evlist__gtk_browse_hists(session->evlist, help, + NULL, rep->min_percent); } } else perf_evlist__tty_browse_hists(session->evlist, rep, help); @@ -793,7 +757,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) .ordered_samples = true, .ordering_requires_timestamps = true, }, - .max_stack = PERF_MAX_STACK_DEPTH, .pretty_printing_style = "normal", }; const struct option options[] = { @@ -824,7 +787,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline," " dso_to, dso_from, symbol_to, symbol_from, mispredict," " weight, local_weight, mem, symbol_daddr, dso_daddr, tlb, " - "snoop, locked, abort, in_tx, transaction"), + "snoop, locked"), OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, "Show sample percentage for different cpu modes"), OPT_STRING('p', "parent", &parent_pattern, "regex", @@ -834,10 +797,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order", "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address). " "Default: fractal,0.5,callee,function", &parse_callchain_opt, callchain_default_opt), - OPT_INTEGER(0, "max-stack", &report.max_stack, - "Set the maximum stack depth when parsing the callchain, " - "anything beyond the specified depth will be ignored. " - "Default: " __stringify(PERF_MAX_STACK_DEPTH)), OPT_BOOLEAN('G', "inverted", &report.inverted_callchain, "alias for inverted call graph"), OPT_CALLBACK(0, "ignore-callees", NULL, "regex", @@ -886,9 +845,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "Don't show entries under that percent", parse_percent_limit), OPT_END() }; - struct perf_data_file file = { - .mode = PERF_DATA_MODE_READ, - }; perf_config(perf_report_config, &report); @@ -911,11 +867,16 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) input_name = "perf.data"; } - file.path = input_name; - file.force = report.force; + if (strcmp(input_name, "-") != 0) + setup_browser(true); + else { + use_browser = 0; + perf_hpp__init(); + } repeat: - session = perf_session__new(&file, false, &report.tool); + session = perf_session__new(input_name, O_RDONLY, + report.force, false, &report.tool); if (session == NULL) return -ENOMEM; @@ -953,22 +914,8 @@ repeat: sort_order = "local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked"; } - if (setup_sorting() < 0) { - parse_options_usage(report_usage, options, "s", 1); - goto error; - } - - if (parent_pattern != default_parent_pattern) { - if (sort_dimension__add("parent") < 0) - goto error; - } - - if (strcmp(input_name, "-") != 0) - setup_browser(true); - else { - use_browser = 0; - perf_hpp__init(); - } + if (setup_sorting() < 0) + usage_with_options(report_usage, options); /* * Only in the TUI browser we are doing integrated annotation, @@ -999,6 +946,11 @@ repeat: if (symbol__init() < 0) goto error; + if (parent_pattern != default_parent_pattern) { + if (sort_dimension__add("parent") < 0) + goto error; + } + if (argc) { /* * Special case: if there's an argument left then assume that |