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) { | ||
