diff options
| -rw-r--r-- | tools/perf/Documentation/perf-report.txt | 24 | ||||
| -rw-r--r-- | tools/perf/builtin-report.c | 30 | ||||
| -rw-r--r-- | tools/perf/ui/browsers/hists.c | 35 | ||||
| -rw-r--r-- | tools/perf/ui/gtk/hists.c | 11 | ||||
| -rw-r--r-- | tools/perf/ui/hist.c | 8 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 39 | ||||
| -rw-r--r-- | tools/perf/util/hist.h | 1 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 1 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 3 |
9 files changed, 106 insertions, 46 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 8eab8a4bdeb8..09af66298564 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt | |||
| @@ -25,10 +25,6 @@ OPTIONS | |||
| 25 | --verbose:: | 25 | --verbose:: |
| 26 | Be more verbose. (show symbol address, etc) | 26 | Be more verbose. (show symbol address, etc) |
| 27 | 27 | ||
| 28 | -d:: | ||
| 29 | --dsos=:: | ||
| 30 | Only consider symbols in these dsos. CSV that understands | ||
| 31 | file://filename entries. | ||
| 32 | -n:: | 28 | -n:: |
| 33 | --show-nr-samples:: | 29 | --show-nr-samples:: |
| 34 | Show the number of samples for each symbol | 30 | Show the number of samples for each symbol |
| @@ -42,11 +38,18 @@ OPTIONS | |||
| 42 | -c:: | 38 | -c:: |
| 43 | --comms=:: | 39 | --comms=:: |
| 44 | Only consider symbols in these comms. CSV that understands | 40 | Only consider symbols in these comms. CSV that understands |
| 45 | file://filename entries. | 41 | file://filename entries. This option will affect the percentage of |
| 42 | the overhead column. See --percentage for more info. | ||
| 43 | -d:: | ||
| 44 | --dsos=:: | ||
| 45 | Only consider symbols in these dsos. CSV that understands | ||
| 46 | file://filename entries. This option will affect the percentage of | ||
| 47 | the overhead column. See --percentage for more info. | ||
| 46 | -S:: | 48 | -S:: |
| 47 | --symbols=:: | 49 | --symbols=:: |
| 48 | Only consider these symbols. CSV that understands | 50 | Only consider these symbols. CSV that understands |
| 49 | file://filename entries. | 51 | file://filename entries. This option will affect the percentage of |
| 52 | the overhead column. See --percentage for more info. | ||
| 50 | 53 | ||
| 51 | --symbol-filter=:: | 54 | --symbol-filter=:: |
| 52 | Only show symbols that match (partially) with this filter. | 55 | Only show symbols that match (partially) with this filter. |
| @@ -237,6 +240,15 @@ OPTIONS | |||
| 237 | Do not show entries which have an overhead under that percent. | 240 | Do not show entries which have an overhead under that percent. |
| 238 | (Default: 0). | 241 | (Default: 0). |
| 239 | 242 | ||
| 243 | --percentage:: | ||
| 244 | Determine how to display the overhead percentage of filtered entries. | ||
| 245 | Filters can be applied by --comms, --dsos and/or --symbols options and | ||
| 246 | Zoom operations on the TUI (thread, dso, etc). | ||
| 247 | |||
| 248 | "relative" means it's relative to filtered entries only so that the | ||
| 249 | sum of shown entries will be always 100%. "absolute" means it retains | ||
| 250 | the original value before and after the filter is applied. | ||
| 251 | |||
| 240 | --header:: | 252 | --header:: |
| 241 | Show header information in the perf.data file. This includes | 253 | Show header information in the perf.data file. This includes |
| 242 | various information like hostname, OS and perf version, cpu/mem | 254 | various information like hostname, OS and perf version, cpu/mem |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 2fca56c9d68a..7ec351bda833 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -343,6 +343,11 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report | |||
| 343 | char buf[512]; | 343 | char buf[512]; |
| 344 | size_t size = sizeof(buf); | 344 | size_t size = sizeof(buf); |
| 345 | 345 | ||
| 346 | if (symbol_conf.filter_relative) { | ||
| 347 | nr_samples = hists->stats.nr_non_filtered_samples; | ||
| 348 | nr_events = hists->stats.total_non_filtered_period; | ||
| 349 | } | ||
| 350 | |||
| 346 | if (perf_evsel__is_group_event(evsel)) { | 351 | if (perf_evsel__is_group_event(evsel)) { |
| 347 | struct perf_evsel *pos; | 352 | struct perf_evsel *pos; |
| 348 | 353 | ||
| @@ -350,8 +355,13 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report | |||
| 350 | evname = buf; | 355 | evname = buf; |
| 351 | 356 | ||
| 352 | for_each_group_member(pos, evsel) { | 357 | for_each_group_member(pos, evsel) { |
| 353 | nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; | 358 | if (symbol_conf.filter_relative) { |
| 354 | nr_events += pos->hists.stats.total_period; | 359 | nr_samples += pos->hists.stats.nr_non_filtered_samples; |
| 360 | nr_events += pos->hists.stats.total_non_filtered_period; | ||
| 361 | } else { | ||
| 362 | nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; | ||
| 363 | nr_events += pos->hists.stats.total_period; | ||
| 364 | } | ||
| 355 | } | 365 | } |
| 356 | } | 366 | } |
| 357 | 367 | ||
| @@ -707,6 +717,20 @@ parse_percent_limit(const struct option *opt, const char *str, | |||
| 707 | return 0; | 717 | return 0; |
| 708 | } | 718 | } |
| 709 | 719 | ||
| 720 | static int | ||
| 721 | parse_percentage(const struct option *opt __maybe_unused, const char *str, | ||
| 722 | int unset __maybe_unused) | ||
| 723 | { | ||
| 724 | if (!strcmp(str, "relative")) | ||
| 725 | symbol_conf.filter_relative = true; | ||
| 726 | else if (!strcmp(str, "absolute")) | ||
| 727 | symbol_conf.filter_relative = false; | ||
| 728 | else | ||
| 729 | return -1; | ||
| 730 | |||
| 731 | return 0; | ||
| 732 | } | ||
| 733 | |||
| 710 | int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) | 734 | int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) |
| 711 | { | 735 | { |
| 712 | struct perf_session *session; | 736 | struct perf_session *session; |
| @@ -829,6 +853,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) | |||
| 829 | OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"), | 853 | OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"), |
| 830 | OPT_CALLBACK(0, "percent-limit", &report, "percent", | 854 | OPT_CALLBACK(0, "percent-limit", &report, "percent", |
| 831 | "Don't show entries under that percent", parse_percent_limit), | 855 | "Don't show entries under that percent", parse_percent_limit), |
| 856 | OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", | ||
| 857 | "how to display percentage of filtered entries", parse_percentage), | ||
| 832 | OPT_END() | 858 | OPT_END() |
| 833 | }; | 859 | }; |
| 834 | struct perf_data_file file = { | 860 | struct perf_data_file file = { |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 7ec871af3f6f..7ad11477a0f5 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
| @@ -769,12 +769,15 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) | |||
| 769 | 769 | ||
| 770 | for (nd = browser->top; nd; nd = rb_next(nd)) { | 770 | for (nd = browser->top; nd; nd = rb_next(nd)) { |
| 771 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 771 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
| 772 | float percent = h->stat.period * 100.0 / | 772 | u64 total = hists__total_period(h->hists); |
| 773 | hb->hists->stats.total_period; | 773 | float percent = 0.0; |
| 774 | 774 | ||
| 775 | if (h->filtered) | 775 | if (h->filtered) |
| 776 | continue; | 776 | continue; |
| 777 | 777 | ||
| 778 | if (total) | ||
| 779 | percent = h->stat.period * 100.0 / total; | ||
| 780 | |||
| 778 | if (percent < hb->min_pcnt) | 781 | if (percent < hb->min_pcnt) |
| 779 | continue; | 782 | continue; |
| 780 | 783 | ||
| @@ -792,8 +795,11 @@ static struct rb_node *hists__filter_entries(struct rb_node *nd, | |||
| 792 | { | 795 | { |
| 793 | while (nd != NULL) { | 796 | while (nd != NULL) { |
| 794 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 797 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
| 795 | float percent = h->stat.period * 100.0 / | 798 | u64 total = hists__total_period(hists); |
| 796 | hists->stats.total_period; | 799 | float percent = 0.0; |
| 800 | |||
| 801 | if (total) | ||
| 802 | percent = h->stat.period * 100.0 / total; | ||
| 797 | 803 | ||
| 798 | if (percent < min_pcnt) | 804 | if (percent < min_pcnt) |
| 799 | return NULL; | 805 | return NULL; |
| @@ -813,8 +819,11 @@ static struct rb_node *hists__filter_prev_entries(struct rb_node *nd, | |||
| 813 | { | 819 | { |
| 814 | while (nd != NULL) { | 820 | while (nd != NULL) { |
| 815 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 821 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
| 816 | float percent = h->stat.period * 100.0 / | 822 | u64 total = hists__total_period(hists); |
| 817 | hists->stats.total_period; | 823 | float percent = 0.0; |
| 824 | |||
| 825 | if (total) | ||
| 826 | percent = h->stat.period * 100.0 / total; | ||
