aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2013-05-13 22:09:04 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-05-28 09:24:01 -0400
commit064f19815c4e99e8b22bc3c5f4d7f4e0b96d226a (patch)
tree80630db03ec2432aa9a7a4975fa3a6f6fc3ac32b /tools/perf/ui
parentf3dd19817e5bbcae81e96571a3d42aa30a1581fb (diff)
perf report: Add --percent-limit option
The --percent-limit option is for not showing small overhead entries in the output. Maybe we want to set a certain default value like 0.1. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1368497347-9628-7-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/browsers/hists.c79
-rw-r--r--tools/perf/ui/gtk/hists.c13
-rw-r--r--tools/perf/ui/stdio/hist.c7
3 files changed, 84 insertions, 15 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a4268cab1921..9dfde61505cc 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -25,6 +25,8 @@ struct hist_browser {
25 struct map_symbol *selection; 25 struct map_symbol *selection;
26 int print_seq; 26 int print_seq;
27 bool show_dso; 27 bool show_dso;
28 float min_pcnt;
29 u64 nr_pcnt_entries;
28}; 30};
29 31
30extern void hist_browser__init_hpp(void); 32extern void hist_browser__init_hpp(void);
@@ -317,6 +319,8 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
317 319
318 browser->b.entries = &browser->hists->entries; 320 browser->b.entries = &browser->hists->entries;
319 browser->b.nr_entries = browser->hists->nr_entries; 321 browser->b.nr_entries = browser->hists->nr_entries;
322 if (browser->min_pcnt)
323 browser->b.nr_entries = browser->nr_pcnt_entries;
320 324
321 hist_browser__refresh_dimensions(browser); 325 hist_browser__refresh_dimensions(browser);
322 hists__browser_title(browser->hists, title, sizeof(title), ev_name); 326 hists__browser_title(browser->hists, title, sizeof(title), ev_name);
@@ -795,10 +799,15 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
795 799
796 for (nd = browser->top; nd; nd = rb_next(nd)) { 800 for (nd = browser->top; nd; nd = rb_next(nd)) {
797 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 801 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
802 float percent = h->stat.period * 100.0 /
803 hb->hists->stats.total_period;
798 804
799 if (h->filtered) 805 if (h->filtered)
800 continue; 806 continue;
801 807
808 if (percent < hb->min_pcnt)
809 continue;
810
802 row += hist_browser__show_entry(hb, h, row); 811 row += hist_browser__show_entry(hb, h, row);
803 if (row == browser->height) 812 if (row == browser->height)
804 break; 813 break;
@@ -807,10 +816,18 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
807 return row; 816 return row;
808} 817}
809 818
810static struct rb_node *hists__filter_entries(struct rb_node *nd) 819static struct rb_node *hists__filter_entries(struct rb_node *nd,
820 struct hists *hists,
821 float min_pcnt)
811{ 822{
812 while (nd != NULL) { 823 while (nd != NULL) {
813 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 824 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
825 float percent = h->stat.period * 100.0 /
826 hists->stats.total_period;
827
828 if (percent < min_pcnt)
829 return NULL;
830
814 if (!h->filtered) 831 if (!h->filtered)
815 return nd; 832 return nd;
816 833
@@ -820,11 +837,16 @@ static struct rb_node *hists__filter_entries(struct rb_node *nd)
820 return NULL; 837 return NULL;
821} 838}
822 839
823static struct rb_node *hists__filter_prev_entries(struct rb_node *nd) 840static struct rb_node *hists__filter_prev_entries(struct rb_node *nd,
841 struct hists *hists,
842 float min_pcnt)
824{ 843{
825 while (nd != NULL) { 844 while (nd != NULL) {
826 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 845 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
827 if (!h->filtered) 846 float percent = h->stat.period * 100.0 /
847 hists->stats.total_period;
848
849 if (!h->filtered && percent >= min_pcnt)
828 return nd; 850 return nd;
829 851
830 nd = rb_prev(nd); 852 nd = rb_prev(nd);
@@ -839,6 +861,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,
839 struct hist_entry *h; 861 struct hist_entry *h;
840 struct rb_node *nd; 862 struct rb_node *nd;
841 bool first = true; 863 bool first = true;
864 struct hist_browser *hb;
865
866 hb = container_of(browser, struct hist_browser, b);
842 867
843 if (browser->nr_entries == 0) 868 if (browser->nr_entries == 0)
844 return; 869 return;
@@ -847,13 +872,15 @@ static void ui_browser__hists_seek(struct ui_browser *browser,
847 872
848 switch (whence) { 873 switch (whence) {
849 case SEEK_SET: 874 case SEEK_SET:
850 nd = hists__filter_entries(rb_first(browser->entries)); 875 nd = hists__filter_entries(rb_first(browser->entries),
876 hb->hists, hb->min_pcnt);
851 break; 877 break;
852 case SEEK_CUR: 878 case SEEK_CUR:
853 nd = browser->top; 879 nd = browser->top;
854 goto do_offset; 880 goto do_offset;
855 case SEEK_END: 881 case SEEK_END:
856 nd = hists__filter_prev_entries(rb_last(browser->entries)); 882 nd = hists__filter_prev_entries(rb_last(browser->entries),
883 hb->hists, hb->min_pcnt);
857 first = false; 884 first = false;
858 break; 885 break;
859 default: 886 default:
@@ -896,7 +923,8 @@ do_offset:
896 break; 923 break;
897 } 924 }
898 } 925 }
899 nd = hists__filter_entries(rb_next(nd)); 926 nd = hists__filter_entries(rb_next(nd), hb->hists,
927 hb->min_pcnt);
900 if (nd == NULL) 928 if (nd == NULL)
901 break; 929 break;
902 --offset; 930 --offset;
@@ -929,7 +957,8 @@ do_offset:
929 } 957 }
930 } 958 }
931 959
932 nd = hists__filter_prev_entries(rb_prev(nd)); 960 nd = hists__filter_prev_entries(rb_prev(nd), hb->hists,
961 hb->min_pcnt);
933 if (nd == NULL) 962 if (nd == NULL)
934 break; 963 break;
935 ++offset; 964 ++offset;
@@ -1098,14 +1127,17 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
1098 1127
1099static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp) 1128static int hist_browser__fprintf(struct hist_browser *browser, FILE *fp)
1100{ 1129{
1101 struct rb_node *nd = hists__filter_entries(rb_first(browser->b.entries)); 1130 struct rb_node *nd = hists__filter_entries(rb_first(browser->b.entries),
1131 browser->hists,
1132 browser->min_pcnt);
1102 int printed = 0; 1133 int printed = 0;
1103 1134
1104 while (nd) { 1135 while (nd) {
1105 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 1136 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1106 1137
1107 printed += hist_browser__fprintf_entry(browser, h, fp); 1138 printed += hist_browser__fprintf_entry(browser, h, fp);
1108 nd = hists__filter_entries(rb_next(nd)); 1139 nd = hists__filter_entries(rb_next(nd), browser->hists,
1140 browser->min_pcnt);
1109 } 1141 }
1110 1142
1111 return printed; 1143 return printed;
@@ -1324,11 +1356,25 @@ close_file_and_continue:
1324 return ret; 1356 return ret;
1325} 1357}
1326 1358
1359static void hist_browser__update_pcnt_entries(struct hist_browser *hb)
1360{
1361 u64 nr_entries = 0;
1362 struct rb_node *nd = rb_first(&hb->hists->entries);
1363
1364 while (nd) {
1365 nr_entries++;
1366 nd = hists__filter_entries(rb_next(nd), hb->hists,
1367 hb->min_pcnt);
1368 }
1369
1370 hb->nr_pcnt_entries = nr_entries;
1371}
1327 1372
1328static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, 1373static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1329 const char *helpline, const char *ev_name, 1374 const char *helpline, const char *ev_name,
1330 bool left_exits, 1375 bool left_exits,
1331 struct hist_browser_timer *hbt, 1376 struct hist_browser_timer *hbt,
1377 float min_pcnt,
1332 struct perf_session_env *env) 1378 struct perf_session_env *env)
1333{ 1379{
1334 struct hists *hists = &evsel->hists; 1380 struct hists *hists = &evsel->hists;
@@ -1345,6 +1391,11 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1345 if (browser == NULL) 1391 if (browser == NULL)
1346 return -1; 1392 return -1;
1347 1393
1394 if (min_pcnt) {
1395 browser->min_pcnt = min_pcnt;
1396 hist_browser__update_pcnt_entries(browser);
1397 }
1398
1348 fstack = pstack__new(2); 1399 fstack = pstack__new(2);
1349 if (fstack == NULL) 1400 if (fstack == NULL)
1350 goto out; 1401 goto out;
@@ -1684,6 +1735,7 @@ struct perf_evsel_menu {
1684 struct ui_browser b; 1735 struct ui_browser b;
1685 struct perf_evsel *selection; 1736 struct perf_evsel *selection;
1686 bool lost_events, lost_events_warned; 1737 bool lost_events, lost_events_warned;
1738 float min_pcnt;
1687 struct perf_session_env *env; 1739 struct perf_session_env *env;
1688}; 1740};
1689 1741
@@ -1777,6 +1829,7 @@ browse_hists:
1777 ev_name = perf_evsel__name(pos); 1829 ev_name = perf_evsel__name(pos);
1778 key = perf_evsel__hists_browse(pos, nr_events, help, 1830 key = perf_evsel__hists_browse(pos, nr_events, help,
1779 ev_name, true, hbt, 1831 ev_name, true, hbt,
1832 menu->min_pcnt,
1780 menu->env); 1833 menu->env);
1781 ui_browser__show_title(&menu->b, title); 1834 ui_browser__show_title(&menu->b, title);
1782 switch (key) { 1835 switch (key) {
@@ -1838,6 +1891,7 @@ static bool filter_group_entries(struct ui_browser *self __maybe_unused,
1838static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, 1891static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
1839 int nr_entries, const char *help, 1892 int nr_entries, const char *help,
1840 struct hist_browser_timer *hbt, 1893 struct hist_browser_timer *hbt,
1894 float min_pcnt,
1841 struct perf_session_env *env) 1895 struct perf_session_env *env)
1842{ 1896{
1843 struct perf_evsel *pos; 1897 struct perf_evsel *pos;
@@ -1851,6 +1905,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
1851 .nr_entries = nr_entries, 1905 .nr_entries = nr_entries,
1852 .priv = evlist, 1906 .priv = evlist,
1853 }, 1907 },
1908 .min_pcnt = min_pcnt,
1854 .env = env, 1909 .env = env,
1855 }; 1910 };
1856 1911
@@ -1869,6 +1924,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist,
1869 1924
1870int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, 1925int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
1871 struct hist_browser_timer *hbt, 1926 struct hist_browser_timer *hbt,
1927 float min_pcnt,
1872 struct perf_session_env *env) 1928 struct perf_session_env *env)
1873{ 1929{
1874 int nr_entries = evlist->nr_entries; 1930 int nr_entries = evlist->nr_entries;
@@ -1880,7 +1936,8 @@ single_entry:
1880 const char *ev_name = perf_evsel__name(first); 1936 const char *ev_name = perf_evsel__name(first);
1881 1937
1882 return perf_evsel__hists_browse(first, nr_entries, help, 1938 return perf_evsel__hists_browse(first, nr_entries, help,
1883 ev_name, false, hbt, env); 1939 ev_name, false, hbt, min_pcnt,
1940 env);
1884 } 1941 }
1885 1942
1886 if (symbol_conf.event_group) { 1943 if (symbol_conf.event_group) {
@@ -1896,5 +1953,5 @@ single_entry:
1896 } 1953 }
1897 1954
1898 return __perf_evlist__tui_browse_hists(evlist, nr_entries, help, 1955 return __perf_evlist__tui_browse_hists(evlist, nr_entries, help,
1899 hbt, env); 1956 hbt, min_pcnt, env);
1900} 1957}
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 6f259b3d14e2..9708dd5fb8f3 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -124,7 +124,8 @@ void perf_gtk__init_hpp(void)
124 perf_gtk__hpp_color_overhead_guest_us; 124 perf_gtk__hpp_color_overhead_guest_us;
125} 125}
126 126
127static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists) 127static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
128 float min_pcnt)
128{ 129{
129 struct perf_hpp_fmt *fmt; 130 struct perf_hpp_fmt *fmt;
130 GType col_types[MAX_COLUMNS]; 131 GType col_types[MAX_COLUMNS];
@@ -189,10 +190,15 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)
189 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { 190 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
190 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 191 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
191 GtkTreeIter iter; 192 GtkTreeIter iter;
193 float percent = h->stat.period * 100.0 /
194 hists->stats.total_period;
192 195
193 if (h->filtered) 196 if (h->filtered)
194 continue; 197 continue;
195 198
199 if (percent < min_pcnt)
200 continue;
201
196 gtk_list_store_append(store, &iter); 202 gtk_list_store_append(store, &iter);
197 203
198 col_idx = 0; 204 col_idx = 0;
@@ -222,7 +228,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)
222 228
223int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, 229int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,
224 const char *help, 230 const char *help,
225 struct hist_browser_timer *hbt __maybe_unused) 231 struct hist_browser_timer *hbt __maybe_unused,
232 float min_pcnt)
226{ 233{
227 struct perf_evsel *pos; 234 struct perf_evsel *pos;
228 GtkWidget *vbox; 235 GtkWidget *vbox;
@@ -286,7 +293,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,
286 GTK_POLICY_AUTOMATIC, 293 GTK_POLICY_AUTOMATIC,
287 GTK_POLICY_AUTOMATIC); 294 GTK_POLICY_AUTOMATIC);
288 295
289 perf_gtk__show_hists(scrolled_window, hists); 296 perf_gtk__show_hists(scrolled_window, hists, min_pcnt);
290 297
291 tab_label = gtk_label_new(evname); 298 tab_label = gtk_label_new(evname);
292 299
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index ff1f60cf442e..ae7a75432249 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -334,7 +334,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
334} 334}
335 335
336size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, 336size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
337 int max_cols, FILE *fp) 337 int max_cols, float min_pcnt, FILE *fp)
338{ 338{
339 struct perf_hpp_fmt *fmt; 339 struct perf_hpp_fmt *fmt;
340 struct sort_entry *se; 340 struct sort_entry *se;
@@ -440,10 +440,15 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
440print_entries: 440print_entries:
441 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { 441 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
442 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 442 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
443 float percent = h->stat.period * 100.0 /
444 hists->stats.total_period;
443 445
444 if (h->filtered) 446 if (h->filtered)
445 continue; 447 continue;
446 448
449 if (percent < min_pcnt)
450 continue;
451
447 ret += hist_entry__fprintf(h, max_cols, hists, fp); 452 ret += hist_entry__fprintf(h, max_cols, hists, fp);
448 453
449 if (max_rows && ++nr_rows >= max_rows) 454 if (max_rows && ++nr_rows >= max_rows)