Commit 848a5e50 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo

perf report: Jump to symbol source view from total cycles view

This patch supports jumping from tui total cycles view to symbol source
view.

For example,

  perf record -b ./div
  perf report --total-cycles

In total cycles view, we can select one entry and press 'a' or press
ENTER key to jump to symbol source view.

This patch also sets sort_order to NULL in cmd_report() which will use
the default branch sort order. The percent value in new annotate view
will be consistent with the percent in annotate view switched from perf
report (we observed the original percent gap with previous patches).

 v2:
 ---
 Fix the 'make NO_SLANG=1' error. (set __maybe_unused to
 annotation_opts in block_hists_tui_browse()).
Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20191118140849.20714-2-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5cb456af
...@@ -493,7 +493,9 @@ static int perf_evlist__tui_block_hists_browse(struct evlist *evlist, ...@@ -493,7 +493,9 @@ static int perf_evlist__tui_block_hists_browse(struct evlist *evlist,
evlist__for_each_entry(evlist, pos) { evlist__for_each_entry(evlist, pos) {
ret = report__browse_block_hists(&rep->block_reports[i++].hist, ret = report__browse_block_hists(&rep->block_reports[i++].hist,
rep->min_percent, pos); rep->min_percent, pos,
&rep->session->header.env,
&rep->annotation_opts);
if (ret != 0) if (ret != 0)
return ret; return ret;
} }
...@@ -525,7 +527,8 @@ static int perf_evlist__tty_browse_hists(struct evlist *evlist, ...@@ -525,7 +527,8 @@ static int perf_evlist__tty_browse_hists(struct evlist *evlist,
if (rep->total_cycles_mode) { if (rep->total_cycles_mode) {
report__browse_block_hists(&rep->block_reports[i++].hist, report__browse_block_hists(&rep->block_reports[i++].hist,
rep->min_percent, pos); rep->min_percent, pos,
NULL, NULL);
continue; continue;
} }
...@@ -1418,7 +1421,7 @@ int cmd_report(int argc, const char **argv) ...@@ -1418,7 +1421,7 @@ int cmd_report(int argc, const char **argv)
if (sort__mode != SORT_MODE__BRANCH) if (sort__mode != SORT_MODE__BRANCH)
report.total_cycles_mode = false; report.total_cycles_mode = false;
else else
sort_order = "sym"; sort_order = NULL;
} }
if (strcmp(input_name, "-") != 0) if (strcmp(input_name, "-") != 0)
......
...@@ -2385,7 +2385,11 @@ do_annotate(struct hist_browser *browser, struct popup_action *act) ...@@ -2385,7 +2385,11 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)
if (!notes->src) if (!notes->src)
return 0; return 0;
if (browser->block_evsel)
evsel = browser->block_evsel;
else
evsel = hists_to_evsel(browser->hists); evsel = hists_to_evsel(browser->hists);
err = map_symbol__tui_annotate(&act->ms, evsel, browser->hbt, err = map_symbol__tui_annotate(&act->ms, evsel, browser->hbt,
browser->annotation_opts); browser->annotation_opts);
he = hist_browser__selected_entry(browser); he = hist_browser__selected_entry(browser);
...@@ -3461,11 +3465,13 @@ static int block_hists_browser__title(struct hist_browser *browser, char *bf, ...@@ -3461,11 +3465,13 @@ static int block_hists_browser__title(struct hist_browser *browser, char *bf,
} }
int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
float min_percent) float min_percent, struct perf_env *env,
struct annotation_options *annotation_opts)
{ {
struct hists *hists = &bh->block_hists; struct hists *hists = &bh->block_hists;
struct hist_browser *browser; struct hist_browser *browser;
int key = -1; int key = -1;
struct popup_action action;
static const char help[] = static const char help[] =
" q Quit \n"; " q Quit \n";
...@@ -3476,11 +3482,15 @@ int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, ...@@ -3476,11 +3482,15 @@ int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
browser->block_evsel = evsel; browser->block_evsel = evsel;
browser->title = block_hists_browser__title; browser->title = block_hists_browser__title;
browser->min_pcnt = min_percent; browser->min_pcnt = min_percent;
browser->env = env;
browser->annotation_opts = annotation_opts;
/* reset abort key so that it can get Ctrl-C as a key */ /* reset abort key so that it can get Ctrl-C as a key */
SLang_reset_tty(); SLang_reset_tty();
SLang_init_tty(0, 0, 0); SLang_init_tty(0, 0, 0);
memset(&action, 0, sizeof(action));
while (1) { while (1) {
key = hist_browser__run(browser, "? - help", true); key = hist_browser__run(browser, "? - help", true);
...@@ -3490,6 +3500,17 @@ int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, ...@@ -3490,6 +3500,17 @@ int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
case '?': case '?':
ui_browser__help_window(&browser->b, help); ui_browser__help_window(&browser->b, help);
break; break;
case 'a':
case K_ENTER:
if (!browser->selection ||
!browser->selection->sym) {
continue;
}
action.ms.map = browser->selection->map;
action.ms.sym = browser->selection->sym;
do_annotate(browser, &action);
continue;
default: default:
break; break;
} }
......
...@@ -441,7 +441,8 @@ struct block_report *block_info__create_report(struct evlist *evlist, ...@@ -441,7 +441,8 @@ struct block_report *block_info__create_report(struct evlist *evlist,
} }
int report__browse_block_hists(struct block_hist *bh, float min_percent, int report__browse_block_hists(struct block_hist *bh, float min_percent,
struct evsel *evsel) struct evsel *evsel, struct perf_env *env,
struct annotation_options *annotation_opts)
{ {
int ret; int ret;
...@@ -454,7 +455,8 @@ int report__browse_block_hists(struct block_hist *bh, float min_percent, ...@@ -454,7 +455,8 @@ int report__browse_block_hists(struct block_hist *bh, float min_percent,
return 0; return 0;
case 1: case 1:
symbol_conf.report_individual_block = true; symbol_conf.report_individual_block = true;
ret = block_hists_tui_browse(bh, evsel, min_percent); ret = block_hists_tui_browse(bh, evsel, min_percent,
env, annotation_opts);
hists__delete_entries(&bh->block_hists); hists__delete_entries(&bh->block_hists);
return ret; return ret;
default: default:
......
...@@ -71,7 +71,8 @@ struct block_report *block_info__create_report(struct evlist *evlist, ...@@ -71,7 +71,8 @@ struct block_report *block_info__create_report(struct evlist *evlist,
u64 total_cycles); u64 total_cycles);
int report__browse_block_hists(struct block_hist *bh, float min_percent, int report__browse_block_hists(struct block_hist *bh, float min_percent,
struct evsel *evsel); struct evsel *evsel, struct perf_env *env,
struct annotation_options *annotation_opts);
float block_info__total_cycles_percent(struct hist_entry *he); float block_info__total_cycles_percent(struct hist_entry *he);
......
...@@ -478,7 +478,8 @@ int res_sample_browse(struct res_sample *res_samples, int num_res, ...@@ -478,7 +478,8 @@ int res_sample_browse(struct res_sample *res_samples, int num_res,
void res_sample_init(void); void res_sample_init(void);
int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
float min_percent); float min_percent, struct perf_env *env,
struct annotation_options *annotation_opts);
#else #else
static inline static inline
int perf_evlist__tui_browse_hists(struct evlist *evlist __maybe_unused, int perf_evlist__tui_browse_hists(struct evlist *evlist __maybe_unused,
...@@ -525,7 +526,9 @@ static inline void res_sample_init(void) {} ...@@ -525,7 +526,9 @@ static inline void res_sample_init(void) {}
static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused, static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused,
struct evsel *evsel __maybe_unused, struct evsel *evsel __maybe_unused,
float min_percent __maybe_unused) float min_percent __maybe_unused,
struct perf_env *env __maybe_unused,
struct annotation_options *annotation_opts __maybe_unused)
{ {
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment