diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-11-02 01:50:05 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-05 12:03:58 -0500 |
commit | 9783adf777a445a1e9d0db4857a3a896a9f42d4a (patch) | |
tree | 0d3256acbcdba290afa018cce86456f21febe58b /tools/perf/ui | |
parent | 48ed0ece1b8063313284812ef048b26c3c4250af (diff) |
perf tools: Introduce struct hist_browser_timer
Currently various hist browser functions receive 3 arguments for
refreshing histogram but only used from a few places. Also it's only
for perf top command so that it can be NULL for other (and probably
most) cases. Pack them into a struct in order to reduce number of those
unused arguments.
This is a mechanical change and does not intend a functional change.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1351835406-15208-2-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/annotate.c | 27 | ||||
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 43 | ||||
-rw-r--r-- | tools/perf/ui/gtk/browser.c | 4 |
3 files changed, 32 insertions, 42 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 28f8aab73aee..3eff17f703f3 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -386,9 +386,8 @@ static void annotate_browser__init_asm_mode(struct annotate_browser *browser) | |||
386 | browser->b.nr_entries = browser->nr_asm_entries; | 386 | browser->b.nr_entries = browser->nr_asm_entries; |
387 | } | 387 | } |
388 | 388 | ||
389 | static bool annotate_browser__callq(struct annotate_browser *browser, | 389 | static bool annotate_browser__callq(struct annotate_browser *browser, int evidx, |
390 | int evidx, void (*timer)(void *arg), | 390 | struct hist_browser_timer *hbt) |
391 | void *arg, int delay_secs) | ||
392 | { | 391 | { |
393 | struct map_symbol *ms = browser->b.priv; | 392 | struct map_symbol *ms = browser->b.priv; |
394 | struct disasm_line *dl = browser->selection; | 393 | struct disasm_line *dl = browser->selection; |
@@ -418,7 +417,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, | |||
418 | } | 417 | } |
419 | 418 | ||
420 | pthread_mutex_unlock(¬es->lock); | 419 | pthread_mutex_unlock(¬es->lock); |
421 | symbol__tui_annotate(target, ms->map, evidx, timer, arg, delay_secs); | 420 | symbol__tui_annotate(target, ms->map, evidx, hbt); |
422 | ui_browser__show_title(&browser->b, sym->name); | 421 | ui_browser__show_title(&browser->b, sym->name); |
423 | return true; | 422 | return true; |
424 | } | 423 | } |
@@ -602,13 +601,13 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser | |||
602 | } | 601 | } |
603 | 602 | ||
604 | static int annotate_browser__run(struct annotate_browser *browser, int evidx, | 603 | static int annotate_browser__run(struct annotate_browser *browser, int evidx, |
605 | void(*timer)(void *arg), | 604 | struct hist_browser_timer *hbt) |
606 | void *arg, int delay_secs) | ||
607 | { | 605 | { |
608 | struct rb_node *nd = NULL; | 606 | struct rb_node *nd = NULL; |
609 | struct map_symbol *ms = browser->b.priv; | 607 | struct map_symbol *ms = browser->b.priv; |
610 | struct symbol *sym = ms->sym; | 608 | struct symbol *sym = ms->sym; |
611 | const char *help = "Press 'h' for help on key bindings"; | 609 | const char *help = "Press 'h' for help on key bindings"; |
610 | int delay_secs = hbt ? hbt->refresh : 0; | ||
612 | int key; | 611 | int key; |
613 | 612 | ||
614 | if (ui_browser__show(&browser->b, sym->name, help) < 0) | 613 | if (ui_browser__show(&browser->b, sym->name, help) < 0) |
@@ -639,8 +638,8 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, | |||
639 | 638 | ||
640 | switch (key) { | 639 | switch (key) { |
641 | case K_TIMER: | 640 | case K_TIMER: |
642 | if (timer != NULL) | 641 | if (hbt) |
643 | timer(arg); | 642 | hbt->timer(hbt->arg); |
644 | 643 | ||
645 | if (delay_secs != 0) | 644 | if (delay_secs != 0) |
646 | symbol__annotate_decay_histogram(sym, evidx); | 645 | symbol__annotate_decay_histogram(sym, evidx); |
@@ -740,7 +739,7 @@ show_help: | |||
740 | goto show_sup_ins; | 739 | goto show_sup_ins; |
741 | goto out; | 740 | goto out; |
742 | } else if (!(annotate_browser__jump(browser) || | 741 | } else if (!(annotate_browser__jump(browser) || |
743 | annotate_browser__callq(browser, evidx, timer, arg, delay_secs))) { | 742 | annotate_browser__callq(browser, evidx, hbt))) { |
744 | show_sup_ins: | 743 | show_sup_ins: |
745 | ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); | 744 | ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); |
746 | } | 745 | } |
@@ -763,10 +762,9 @@ out: | |||
763 | } | 762 | } |
764 | 763 | ||
765 | int hist_entry__tui_annotate(struct hist_entry *he, int evidx, | 764 | int hist_entry__tui_annotate(struct hist_entry *he, int evidx, |
766 | void(*timer)(void *arg), void *arg, int delay_secs) | 765 | struct hist_browser_timer *hbt) |
767 | { | 766 | { |
768 | return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, | 767 | return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, hbt); |
769 | timer, arg, delay_secs); | ||
770 | } | 768 | } |
771 | 769 | ||
772 | static void annotate_browser__mark_jump_targets(struct annotate_browser *browser, | 770 | static void annotate_browser__mark_jump_targets(struct annotate_browser *browser, |
@@ -816,8 +814,7 @@ static inline int width_jumps(int n) | |||
816 | } | 814 | } |
817 | 815 | ||
818 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | 816 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, |
819 | void(*timer)(void *arg), void *arg, | 817 | struct hist_browser_timer *hbt) |
820 | int delay_secs) | ||
821 | { | 818 | { |
822 | struct disasm_line *pos, *n; | 819 | struct disasm_line *pos, *n; |
823 | struct annotation *notes; | 820 | struct annotation *notes; |
@@ -899,7 +896,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
899 | 896 | ||
900 | annotate_browser__update_addr_width(&browser); | 897 | annotate_browser__update_addr_width(&browser); |
901 | 898 | ||
902 | ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); | 899 | ret = annotate_browser__run(&browser, evidx, hbt); |
903 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { | 900 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { |
904 | list_del(&pos->node); | 901 | list_del(&pos->node); |
905 | disasm_line__free(pos); | 902 | disasm_line__free(pos); |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 082078ae9a6b..c7d32edb8057 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -310,10 +310,11 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser) | |||
310 | } | 310 | } |
311 | 311 | ||
312 | static int hist_browser__run(struct hist_browser *browser, const char *ev_name, | 312 | static int hist_browser__run(struct hist_browser *browser, const char *ev_name, |
313 | void(*timer)(void *arg), void *arg, int delay_secs) | 313 | struct hist_browser_timer *hbt) |
314 | { | 314 | { |
315 | int key; | 315 | int key; |
316 | char title[160]; | 316 | char title[160]; |
317 | int delay_secs = hbt ? hbt->refresh : 0; | ||
317 | 318 | ||
318 | browser->b.entries = &browser->hists->entries; | 319 | browser->b.entries = &browser->hists->entries; |
319 | browser->b.nr_entries = browser->hists->nr_entries; | 320 | browser->b.nr_entries = browser->hists->nr_entries; |
@@ -330,7 +331,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name, | |||
330 | 331 | ||
331 | switch (key) { | 332 | switch (key) { |
332 | case K_TIMER: | 333 | case K_TIMER: |
333 | timer(arg); | 334 | hbt->timer(hbt->arg); |
334 | ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); | 335 | ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); |
335 | 336 | ||
336 | if (browser->hists->stats.nr_lost_warned != | 337 | if (browser->hists->stats.nr_lost_warned != |
@@ -1136,8 +1137,7 @@ static inline bool is_report_browser(void *timer) | |||
1136 | static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | 1137 | static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, |
1137 | const char *helpline, const char *ev_name, | 1138 | const char *helpline, const char *ev_name, |
1138 | bool left_exits, | 1139 | bool left_exits, |
1139 | void(*timer)(void *arg), void *arg, | 1140 | struct hist_browser_timer *hbt) |
1140 | int delay_secs) | ||
1141 | { | 1141 | { |
1142 | struct hists *hists = &evsel->hists; | 1142 | struct hists *hists = &evsel->hists; |
1143 | struct hist_browser *browser = hist_browser__new(hists); | 1143 | struct hist_browser *browser = hist_browser__new(hists); |
@@ -1148,6 +1148,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1148 | int key = -1; | 1148 | int key = -1; |
1149 | char buf[64]; | 1149 | char buf[64]; |
1150 | char script_opt[64]; | 1150 | char script_opt[64]; |
1151 | int delay_secs = hbt ? hbt->refresh : 0; | ||
1151 | 1152 | ||
1152 | if (browser == NULL) | 1153 | if (browser == NULL) |
1153 | return -1; | 1154 | return -1; |
@@ -1170,7 +1171,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1170 | 1171 | ||
1171 | nr_options = 0; | 1172 | nr_options = 0; |
1172 | 1173 | ||
1173 | key = hist_browser__run(browser, ev_name, timer, arg, delay_secs); | 1174 | key = hist_browser__run(browser, ev_name, hbt); |
1174 | 1175 | ||
1175 | if (browser->he_selection != NULL) { | 1176 | if (browser->he_selection != NULL) { |
1176 | thread = hist_browser__selected_thread(browser); | 1177 | thread = hist_browser__selected_thread(browser); |
@@ -1220,7 +1221,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1220 | } | 1221 | } |
1221 | continue; | 1222 | continue; |
1222 | case 'r': | 1223 | case 'r': |
1223 | if (is_report_browser(timer)) | 1224 | if (is_report_browser(hbt)) |
1224 | goto do_scripts; | 1225 | goto do_scripts; |
1225 | continue; | 1226 | continue; |
1226 | case K_F1: | 1227 | case K_F1: |
@@ -1388,8 +1389,7 @@ do_annotate: | |||
1388 | * Don't let this be freed, say, by hists__decay_entry. | 1389 | * Don't let this be freed, say, by hists__decay_entry. |
1389 | */ | 1390 | */ |
1390 | he->used = true; | 1391 | he->used = true; |
1391 | err = hist_entry__tui_annotate(he, evsel->idx, | 1392 | err = hist_entry__tui_annotate(he, evsel->idx, hbt); |
1392 | timer, arg, delay_secs); | ||
1393 | he->used = false; | 1393 | he->used = false; |
1394 | /* | 1394 | /* |
1395 | * offer option to annotate the other branch source or target | 1395 | * offer option to annotate the other branch source or target |
@@ -1512,11 +1512,12 @@ static void perf_evsel_menu__write(struct ui_browser *browser, | |||
1512 | 1512 | ||
1513 | static int perf_evsel_menu__run(struct perf_evsel_menu *menu, | 1513 | static int perf_evsel_menu__run(struct perf_evsel_menu *menu, |
1514 | int nr_events, const char *help, | 1514 | int nr_events, const char *help, |
1515 | void(*timer)(void *arg), void *arg, int delay_secs) | 1515 | struct hist_browser_timer *hbt) |
1516 | { | 1516 | { |
1517 | struct perf_evlist *evlist = menu->b.priv; | 1517 | struct perf_evlist *evlist = menu->b.priv; |
1518 | struct perf_evsel *pos; | 1518 | struct perf_evsel *pos; |
1519 | const char *ev_name, *title = "Available samples"; | 1519 | const char *ev_name, *title = "Available samples"; |
1520 | int delay_secs = hbt ? hbt->refresh : 0; | ||
1520 | int key; | 1521 | int key; |
1521 | 1522 | ||
1522 | if (ui_browser__show(&menu->b, title, | 1523 | if (ui_browser__show(&menu->b, title, |
@@ -1528,7 +1529,7 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, | |||
1528 | 1529 | ||
1529 | switch (key) { | 1530 | switch (key) { |
1530 | case K_TIMER: | 1531 | case K_TIMER: |
1531 | timer(arg); | 1532 | hbt->timer(hbt->arg); |
1532 | 1533 | ||
1533 | if (!menu->lost_events_warned && menu->lost_events) { | 1534 | if (!menu->lost_events_warned && menu->lost_events) { |
1534 | ui_browser__warn_lost_events(&menu->b); | 1535 | ui_browser__warn_lost_events(&menu->b); |
@@ -1546,12 +1547,11 @@ browse_hists: | |||
1546 | * Give the calling tool a chance to populate the non | 1547 | * Give the calling tool a chance to populate the non |
1547 | * default evsel resorted hists tree. | 1548 | * default evsel resorted hists tree. |
1548 | */ | 1549 | */ |
1549 | if (timer) | 1550 | if (hbt) |
1550 | timer(arg); | 1551 | hbt->timer(hbt->arg); |
1551 | ev_name = perf_evsel__name(pos); | 1552 | ev_name = perf_evsel__name(pos); |
1552 | key = perf_evsel__hists_browse(pos, nr_events, help, | 1553 | key = perf_evsel__hists_browse(pos, nr_events, help, |
1553 | ev_name, true, timer, | 1554 | ev_name, true, hbt); |
1554 | arg, delay_secs); | ||
1555 | ui_browser__show_title(&menu->b, title); | 1555 | ui_browser__show_title(&menu->b, title); |
1556 | switch (key) { | 1556 | switch (key) { |
1557 | case K_TAB: | 1557 | case K_TAB: |
@@ -1599,8 +1599,7 @@ out: | |||
1599 | 1599 | ||
1600 | static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | 1600 | static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, |
1601 | const char *help, | 1601 | const char *help, |
1602 | void(*timer)(void *arg), void *arg, | 1602 | struct hist_browser_timer *hbt) |
1603 | int delay_secs) | ||
1604 | { | 1603 | { |
1605 | struct perf_evsel *pos; | 1604 | struct perf_evsel *pos; |
1606 | struct perf_evsel_menu menu = { | 1605 | struct perf_evsel_menu menu = { |
@@ -1624,23 +1623,19 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
1624 | menu.b.width = line_len; | 1623 | menu.b.width = line_len; |
1625 | } | 1624 | } |
1626 | 1625 | ||
1627 | return perf_evsel_menu__run(&menu, evlist->nr_entries, help, timer, | 1626 | return perf_evsel_menu__run(&menu, evlist->nr_entries, help, hbt); |
1628 | arg, delay_secs); | ||
1629 | } | 1627 | } |
1630 | 1628 | ||
1631 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 1629 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
1632 | void(*timer)(void *arg), void *arg, | 1630 | struct hist_browser_timer *hbt) |
1633 | int delay_secs) | ||
1634 | { | 1631 | { |
1635 | if (evlist->nr_entries == 1) { | 1632 | if (evlist->nr_entries == 1) { |
1636 | struct perf_evsel *first = list_entry(evlist->entries.next, | 1633 | struct perf_evsel *first = list_entry(evlist->entries.next, |
1637 | struct perf_evsel, node); | 1634 | struct perf_evsel, node); |
1638 | const char *ev_name = perf_evsel__name(first); | 1635 | const char *ev_name = perf_evsel__name(first); |
1639 | return perf_evsel__hists_browse(first, evlist->nr_entries, help, | 1636 | return perf_evsel__hists_browse(first, evlist->nr_entries, help, |
1640 | ev_name, false, timer, arg, | 1637 | ev_name, false, hbt); |
1641 | delay_secs); | ||
1642 | } | 1638 | } |
1643 | 1639 | ||
1644 | return __perf_evlist__tui_browse_hists(evlist, help, | 1640 | return __perf_evlist__tui_browse_hists(evlist, help, hbt); |
1645 | timer, arg, delay_secs); | ||
1646 | } | 1641 | } |
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c index 4125c6284114..253b6219a39e 100644 --- a/tools/perf/ui/gtk/browser.c +++ b/tools/perf/ui/gtk/browser.c | |||
@@ -237,9 +237,7 @@ static GtkWidget *perf_gtk__setup_statusbar(void) | |||
237 | 237 | ||
238 | int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, | 238 | int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, |
239 | const char *help, | 239 | const char *help, |
240 | void (*timer) (void *arg)__maybe_unused, | 240 | struct hist_browser_timer *hbt __maybe_unused) |
241 | void *arg __maybe_unused, | ||
242 | int delay_secs __maybe_unused) | ||
243 | { | 241 | { |
244 | struct perf_evsel *pos; | 242 | struct perf_evsel *pos; |
245 | GtkWidget *vbox; | 243 | GtkWidget *vbox; |