aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/hists.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/ui/browsers/hists.c')
-rw-r--r--tools/perf/ui/browsers/hists.c40
1 files changed, 11 insertions, 29 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,
37static void hist_browser__update_nr_entries(struct hist_browser *hb); 37static void hist_browser__update_nr_entries(struct hist_browser *hb);
38 38
39static struct rb_node *hists__filter_entries(struct rb_node *nd, 39static struct rb_node *hists__filter_entries(struct rb_node *nd,
40 struct hists *hists,
41 float min_pcnt); 40 float min_pcnt);
42 41
43static bool hist_browser__has_filter(struct hist_browser *hb) 42static 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
831static struct rb_node *hists__filter_entries(struct rb_node *nd, 827static 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
852static struct rb_node *hists__filter_prev_entries(struct rb_node *nd, 843static 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,
1151static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp) 1136static 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 }