diff options
author | Namhyung Kim <namhyung@kernel.org> | 2013-10-30 21:17:39 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-01 08:35:02 -0400 |
commit | 14135663f1d770bb057f8bf345e5436c985eb29c (patch) | |
tree | 390e9bb413cf8b6fb65375d339ce26b0ea2b5315 /tools | |
parent | b09955b2a3d5fd02ed31d279f8c0ac29b32abe83 (diff) |
perf tools: Apply percent-limit to cumulative percentage
If -g cumulative option is given, it needs to show entries which don't
have self overhead. So apply percent-limit to accumulated overhead
percentage in this case.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arun Sharma <asharma@fb.com>
Tested-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1401335910-16832-14-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 40 | ||||
-rw-r--r-- | tools/perf/ui/gtk/hists.c | 6 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 4 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 17 |
4 files changed, 31 insertions, 36 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 2dcbe3d15a5f..5905acde5f1d 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -37,7 +37,6 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size, | |||
37 | static void hist_browser__update_nr_entries(struct hist_browser *hb); | 37 | static void hist_browser__update_nr_entries(struct hist_browser *hb); |
38 | 38 | ||
39 | static struct rb_node *hists__filter_entries(struct rb_node *nd, | 39 | static struct rb_node *hists__filter_entries(struct rb_node *nd, |
40 | struct hists *hists, | ||
41 | float min_pcnt); | 40 | float min_pcnt); |
42 | 41 | ||
43 | static bool hist_browser__has_filter(struct hist_browser *hb) | 42 | static bool hist_browser__has_filter(struct hist_browser *hb) |
@@ -319,7 +318,7 @@ __hist_browser__set_folding(struct hist_browser *browser, bool unfold) | |||
319 | struct hists *hists = browser->hists; | 318 | struct hists *hists = browser->hists; |
320 | 319 | ||
321 | for (nd = rb_first(&hists->entries); | 320 | for (nd = rb_first(&hists->entries); |
322 | (nd = hists__filter_entries(nd, hists, browser->min_pcnt)) != NULL; | 321 | (nd = hists__filter_entries(nd, browser->min_pcnt)) != NULL; |
323 | nd = rb_next(nd)) { | 322 | nd = rb_next(nd)) { |
324 | struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); | 323 | struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); |
325 | hist_entry__set_folding(he, unfold); | 324 | hist_entry__set_folding(he, unfold); |
@@ -808,15 +807,12 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) | |||
808 | 807 | ||
809 | for (nd = browser->top; nd; nd = rb_next(nd)) { | 808 | for (nd = browser->top; nd; nd = rb_next(nd)) { |
810 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 809 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
811 | u64 total = hists__total_period(h->hists); | 810 | float percent; |
812 | float percent = 0.0; | ||
813 | 811 | ||
814 | if (h->filtered) | 812 | if (h->filtered) |
815 | continue; | 813 | continue; |
816 | 814 | ||
817 | if (total) | 815 | percent = hist_entry__get_percent_limit(h); |
818 | percent = h->stat.period * 100.0 / total; | ||
819 | |||
820 | if (percent < hb->min_pcnt) | 816 | if (percent < hb->min_pcnt) |
821 | continue; | 817 | continue; |
822 | 818 | ||
@@ -829,16 +825,11 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) | |||
829 | } | 825 | } |
830 | 826 | ||
831 | static struct rb_node *hists__filter_entries(struct rb_node *nd, | 827 | static struct rb_node *hists__filter_entries(struct rb_node *nd, |
832 | struct hists *hists, | ||
833 | float min_pcnt) | 828 | float min_pcnt) |
834 | { | 829 | { |
835 | while (nd != NULL) { | 830 | while (nd != NULL) { |
836 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 831 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
837 | u64 total = hists__total_period(hists); | 832 | float percent = hist_entry__get_percent_limit(h); |
838 | float percent = 0.0; | ||
839 | |||
840 | if (total) | ||
841 | percent = h->stat.period * 100.0 / total; | ||
842 | 833 | ||
843 | if (!h->filtered && percent >= min_pcnt) | 834 | if (!h->filtered && percent >= min_pcnt) |
844 | return nd; | 835 | return nd; |
@@ -850,16 +841,11 @@ static struct rb_node *hists__filter_entries(struct rb_node *nd, | |||
850 | } | 841 | } |
851 | 842 | ||
852 | static struct rb_node *hists__filter_prev_entries(struct rb_node *nd, | 843 | static struct rb_node *hists__filter_prev_entries(struct rb_node *nd, |
853 | struct hists *hists, | ||
854 | float min_pcnt) | 844 | float min_pcnt) |
855 | { | 845 | { |
856 | while (nd != NULL) { | 846 | while (nd != NULL) { |
857 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 847 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
858 | u64 total = hists__total_period(hists); | 848 | float percent = hist_entry__get_percent_limit(h); |
859 | float percent = 0.0; | ||
860 | |||
861 | if (total) | ||
862 | percent = h->stat.period * 100.0 / total; | ||
863 | 849 | ||
864 | if (!h->filtered && percent >= min_pcnt) | 850 | if (!h->filtered && percent >= min_pcnt) |
865 | return nd; | 851 | return nd; |
@@ -888,14 +874,14 @@ static void ui_browser__hists_seek(struct ui_browser *browser, | |||
888 | switch (whence) { | 874 | switch (whence) { |
889 | case SEEK_SET: | 875 | case SEEK_SET: |
890 | nd = hists__filter_entries(rb_first(browser->entries), | 876 | nd = hists__filter_entries(rb_first(browser->entries), |
891 | hb->hists, hb->min_pcnt); | 877 | hb->min_pcnt); |
892 | break; | 878 | break; |
893 | case SEEK_CUR: | 879 | case SEEK_CUR: |
894 | nd = browser->top; | 880 | nd = browser->top; |
895 | goto do_offset; | 881 | goto do_offset; |
896 | case SEEK_END: | 882 | case SEEK_END: |
897 | nd = hists__filter_prev_entries(rb_last(browser->entries), | 883 | nd = hists__filter_prev_entries(rb_last(browser->entries), |
898 | hb->hists, hb->min_pcnt); | 884 | hb->min_pcnt); |
899 | first = false; | 885 | first = false; |
900 | break; | 886 | break; |
901 | default: | 887 | default: |
@@ -938,8 +924,7 @@ do_offset: | |||
938 | break; | 924 | break; |
939 | } | 925 | } |
940 | } | 926 | } |
941 | nd = hists__filter_entries(rb_next(nd), hb->hists, | 927 | nd = hists__filter_entries(rb_next(nd), hb->min_pcnt); |
942 | hb->min_pcnt); | ||
943 | if (nd == NULL) | 928 | if (nd == NULL) |
944 | break; | 929 | break; |
945 | --offset; | 930 | --offset; |
@@ -972,7 +957,7 @@ do_offset: | |||
972 | } | 957 | } |
973 | } | 958 | } |
974 | 959 | ||
975 | nd = hists__filter_prev_entries(rb_prev(nd), hb->hists, | 960 | nd = hists__filter_prev_entries(rb_prev(nd), |
976 | hb->min_pcnt); | 961 | hb->min_pcnt); |
977 | if (nd == NULL) | 962 | if (nd == NULL) |
978 | break; | 963 | break; |
@@ -1151,7 +1136,6 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser, | |||
1151 | static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp) | 1136 | static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp) |
1152 | { | 1137 | { |
1153 | struct rb_node *nd = hists__filter_entries(rb_first(browser->b.entries), | 1138 | struct rb_node *nd = hists__filter_entries(rb_first(browser->b.entries), |
1154 | browser->hists, | ||
1155 | browser->min_pcnt); | 1139 | browser->min_pcnt); |
1156 | int printed = 0; | 1140 | int printed = 0; |
1157 | 1141 | ||
@@ -1159,8 +1143,7 @@ static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp) | |||
1159 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 1143 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
1160 | 1144 | ||
1161 | printed += hist_browser__fprintf_entry(browser, h, fp); | 1145 | printed += hist_browser__fprintf_entry(browser, h, fp); |
1162 | nd = hists__filter_entries(rb_next(nd), browser->hists, | 1146 | nd = hists__filter_entries(rb_next(nd), browser->min_pcnt); |
1163 | browser->min_pcnt); | ||
1164 | } | 1147 | } |
1165 | 1148 | ||
1166 | return printed; | 1149 | return printed; |
@@ -1397,8 +1380,7 @@ static void hist_browser__update_nr_entries(struct hist_browser *hb) | |||
1397 | return; | 1380 | return; |
1398 | } | 1381 | } |
1399 | 1382 | ||
1400 | while ((nd = hists__filter_entries(nd, hb->hists, | 1383 | while ((nd = hists__filter_entries(nd, hb->min_pcnt)) != NULL) { |
1401 | hb->min_pcnt)) != NULL) { | ||
1402 | nr_entries++; | 1384 | nr_entries++; |
1403 | nd = rb_next(nd); | 1385 | nd = rb_next(nd); |
1404 | } | 1386 | } |
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 7e5da4af98d8..03d6812d25dd 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -226,14 +226,12 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, | |||
226 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 226 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
227 | GtkTreeIter iter; | 227 | GtkTreeIter iter; |
228 | u64 total = hists__total_period(h->hists); | 228 | u64 total = hists__total_period(h->hists); |
229 | float percent = 0.0; | 229 | float percent; |
230 | 230 | ||
231 | if (h->filtered) | 231 | if (h->filtered) |
232 | continue; | 232 | continue; |
233 | 233 | ||
234 | if (total) | 234 | percent = hist_entry__get_percent_limit(h); |
235 | percent = h->stat.period * 100.0 / total; | ||
236 | |||
237 | if (percent < min_pcnt) | 235 | if (percent < min_pcnt) |
238 | continue; | 236 | continue; |
239 | 237 | ||
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 9f57991025a9..475d2f5c7e16 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -461,12 +461,12 @@ print_entries: | |||
461 | 461 | ||
462 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 462 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
463 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 463 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
464 | float percent = h->stat.period * 100.0 / | 464 | float percent; |
465 | hists->stats.total_period; | ||
466 | 465 | ||
467 | if (h->filtered) | 466 | if (h->filtered) |
468 | continue; | 467 | continue; |
469 | 468 | ||
469 | percent = hist_entry__get_percent_limit(h); | ||
470 | if (percent < min_pcnt) | 470 | if (percent < min_pcnt) |
471 | continue; | 471 | continue; |
472 | 472 | ||
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index c9ffa031becd..426b873e16ff 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #include "parse-options.h" | 21 | #include "parse-options.h" |
22 | #include "parse-events.h" | 22 | #include "parse-events.h" |
23 | 23 | #include "hist.h" | |
24 | #include "thread.h" | 24 | #include "thread.h" |
25 | 25 | ||
26 | extern regex_t parent_regex; | 26 | extern regex_t parent_regex; |
@@ -131,6 +131,21 @@ static inline void hist_entry__add_pair(struct hist_entry *pair, | |||
131 | list_add_tail(&pair->pairs.node, &he->pairs.head); | 131 | list_add_tail(&pair->pairs.node, &he->pairs.head); |
132 | } | 132 | } |
133 | 133 | ||
134 | static inline float hist_entry__get_percent_limit(struct hist_entry *he) | ||
135 | { | ||
136 | u64 period = he->stat.period; | ||
137 | u64 total_period = hists__total_period(he->hists); | ||
138 | |||
139 | if (unlikely(total_period == 0)) | ||
140 | return 0; | ||
141 | |||
142 | if (symbol_conf.cumulate_callchain) | ||
143 | period = he->stat_acc->period; | ||
144 | |||
145 | return period * 100.0 / total_period; | ||
146 | } | ||
147 | |||
148 | |||
134 | enum sort_mode { | 149 | enum sort_mode { |
135 | SORT_MODE__NORMAL, | 150 | SORT_MODE__NORMAL, |
136 | SORT_MODE__BRANCH, | 151 | SORT_MODE__BRANCH, |