From: Jin Yao <yao.jin@linux.intel.com>
To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com
Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com,
Jin Yao <yao.jin@linux.intel.com>
Subject: [PATCH v1 3/4] perf annotate: Display multiple events for tui mode
Date: Wed, 16 Aug 2017 18:18:35 +0800 [thread overview]
Message-ID: <1502878716-30817-4-git-send-email-yao.jin@linux.intel.com> (raw)
In-Reply-To: <1502878716-30817-1-git-send-email-yao.jin@linux.intel.com>
For example:
perf record -e cycles,branches ./div
perf annotate main
│ for (i = 0; i < 2000000000; i++) {
│ flag = compute_flag();
5.77 4.85 │38: xor %eax,%eax
0.01 0.01 │ → callq compute_flag
│
│ count++;
2.38 4.38 │ mov count,%edx
0.00 0.00 │ add $0x1,%edx
│
│ if (flag)
│ test %eax,%eax
│ srand(s_randseed);
│
│ for (i = 0; i < 2000000000; i++) {
│ flag = compute_flag();
│
│ count++;
0.60 0.44 │ mov %edx,count
│
│ if (flag)
3.99 4.32 │ ↓ je 82
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
tools/perf/ui/browsers/annotate.c | 49 ++++++++++++++++++++++++++++-----------
tools/perf/ui/browsers/hists.c | 2 +-
tools/perf/util/annotate.h | 6 +++--
tools/perf/util/hist.h | 8 ++++---
4 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 80f38da..b76c238 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -428,13 +428,15 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
}
static void annotate_browser__calc_percent(struct annotate_browser *browser,
- struct perf_evsel *evsel)
+ struct perf_evsel *evsel,
+ struct hist_entry *he)
{
struct map_symbol *ms = browser->b.priv;
struct symbol *sym = ms->sym;
struct annotation *notes = symbol__annotation(sym);
struct disasm_line *pos, *next;
s64 len = symbol__size(sym);
+ struct hist_event *hevt;
browser->entries = RB_ROOT;
@@ -455,13 +457,25 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
for (i = 0; i < browser->nr_events; i++) {
struct sym_hist_entry sample;
-
- bpos->samples[i].percent = disasm__calc_percent(notes,
+ if (evsel) {
+ bpos->samples[i].percent =
+ disasm__calc_percent(notes,
evsel->idx + i,
pos->offset,
next ? next->offset : len,
&path, &sample);
- bpos->samples[i].he = sample;
+ bpos->samples[i].he = sample;
+ } else if (he) {
+ hevt = &he->events[i];
+ notes = symbol__annotation(hevt->ms.sym);
+ bpos->samples[i].percent =
+ disasm__calc_percent(notes,
+ hevt->idx,
+ pos->offset,
+ next ? next->offset : len,
+ &path, &sample);
+ bpos->samples[i].he = sample;
+ }
if (max_percent < bpos->samples[i].percent)
max_percent = bpos->samples[i].percent;
@@ -567,7 +581,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
}
pthread_mutex_unlock(¬es->lock);
- symbol__tui_annotate(target.sym, target.map, evsel, hbt);
+ symbol__tui_annotate(target.sym, target.map, evsel, hbt, NULL);
sym_title(ms->sym, ms->map, title, sizeof(title));
ui_browser__show_title(&browser->b, title);
return true;
@@ -755,7 +769,8 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser
static int annotate_browser__run(struct annotate_browser *browser,
struct perf_evsel *evsel,
- struct hist_browser_timer *hbt)
+ struct hist_browser_timer *hbt,
+ struct hist_entry *he)
{
struct rb_node *nd = NULL;
struct map_symbol *ms = browser->b.priv;
@@ -769,7 +784,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
if (ui_browser__show(&browser->b, title, help) < 0)
return -1;
- annotate_browser__calc_percent(browser, evsel);
+ annotate_browser__calc_percent(browser, evsel, he);
if (browser->curr_hot) {
annotate_browser__set_rb_top(browser, browser->curr_hot);
@@ -782,7 +797,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
key = ui_browser__run(&browser->b, delay_secs);
if (delay_secs != 0) {
- annotate_browser__calc_percent(browser, evsel);
+ annotate_browser__calc_percent(browser, evsel, he);
/*
* Current line focus got out of the list of most active
* lines, NULL it so that if TAB|UNTAB is pressed, we
@@ -929,13 +944,14 @@ static int annotate_browser__run(struct annotate_browser *browser,
}
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
- struct hist_browser_timer *hbt)
+ struct hist_browser_timer *hbt,
+ struct hist_entry *he)
{
/* Set default value for show_total_period. */
annotate_browser__opts.show_total_period =
symbol_conf.show_total_period;
- return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
+ return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt, he);
}
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
@@ -945,7 +961,7 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
SLang_reset_tty();
SLang_init_tty(0, 0, 0);
- return map_symbol__tui_annotate(&he->ms, evsel, hbt);
+ return map_symbol__tui_annotate(&he->ms, evsel, hbt, he);
}
@@ -1062,7 +1078,8 @@ static inline int width_jumps(int n)
int symbol__tui_annotate(struct symbol *sym, struct map *map,
struct perf_evsel *evsel,
- struct hist_browser_timer *hbt)
+ struct hist_browser_timer *hbt,
+ struct hist_entry *he)
{
struct disasm_line *pos, *n;
struct annotation *notes;
@@ -1099,10 +1116,14 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
return -1;
}
- if (perf_evsel__is_group_event(evsel)) {
+ if (evsel && perf_evsel__is_group_event(evsel)) {
nr_pcnt = evsel->nr_members;
sizeof_bdl += sizeof(struct disasm_line_samples) *
(nr_pcnt - 1);
+ } else if (he) {
+ nr_pcnt = he->event_nr;
+ sizeof_bdl += sizeof(struct disasm_line_samples) *
+ (nr_pcnt - 1);
}
err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
@@ -1159,7 +1180,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
annotate_browser__update_addr_width(&browser);
- ret = annotate_browser__run(&browser, evsel, hbt);
+ ret = annotate_browser__run(&browser, evsel, hbt, he);
list_for_each_entry_safe(pos, n, ¬es->src->source, node) {
list_del(&pos->node);
disasm_line__free(pos);
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index f4bc246..b37458d 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2570,7 +2570,7 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)
return 0;
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, NULL);
he = hist_browser__selected_entry(browser);
/*
* offer option to annotate the other branch source or target
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 83b78ff..1b9ef1d 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -214,13 +214,15 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
#ifdef HAVE_SLANG_SUPPORT
int symbol__tui_annotate(struct symbol *sym, struct map *map,
struct perf_evsel *evsel,
- struct hist_browser_timer *hbt);
+ struct hist_browser_timer *hbt,
+ struct hist_entry *he);
#else
static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused,
struct map *map __maybe_unused,
struct perf_evsel *evsel __maybe_unused,
struct hist_browser_timer *hbt
- __maybe_unused)
+ __maybe_unused,
+ struct hist_entry *he __maybe_unused)
{
return 0;
}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index ee3670a..ece79a1 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -420,7 +420,8 @@ struct hist_browser_timer {
#ifdef HAVE_SLANG_SUPPORT
#include "../ui/keysyms.h"
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
- struct hist_browser_timer *hbt);
+ struct hist_browser_timer *hbt,
+ struct hist_entry *he);
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
struct hist_browser_timer *hbt);
@@ -441,8 +442,9 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,
return 0;
}
static inline int map_symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
- struct perf_evsel *evsel __maybe_unused,
- struct hist_browser_timer *hbt __maybe_unused)
+ struct perf_evsel *evsel __maybe_unused,
+ struct hist_browser_timer *hbt __maybe_unused,
+ struct hist_entry *he __maybe_unused)
{
return 0;
}
--
2.7.4
next prev parent reply other threads:[~2017-08-16 2:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 10:18 [PATCH v1 0/4] perf annotate: Display multiple events on the left side of annotate view Jin Yao
2017-08-16 10:18 ` [PATCH v1 1/4] perf annotate: create a new hists to manage multiple events samples Jin Yao
2017-09-08 13:43 ` Arnaldo Carvalho de Melo
2017-09-11 1:33 ` Jin, Yao
2017-09-14 1:03 ` Jin, Yao
2017-09-14 14:05 ` Arnaldo Carvalho de Melo
2017-09-14 14:31 ` Jin, Yao
2017-10-05 13:21 ` Arnaldo Carvalho de Melo
2017-10-06 16:31 ` Jin, Yao
2017-10-06 18:54 ` Arnaldo Carvalho de Melo
2017-10-09 1:40 ` Jin, Yao
2017-10-12 1:39 ` Jin, Yao
2017-08-16 10:18 ` [PATCH v1 2/4] perf annotate: Display multiple events for stdio mode Jin Yao
2017-08-16 10:18 ` Jin Yao [this message]
2017-08-16 10:18 ` [PATCH v1 4/4] perf annotate: Display multiple events for gtk mode Jin Yao
2017-09-08 7:31 ` [PATCH v1 0/4] perf annotate: Display multiple events on the left side of annotate view Jin, Yao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502878716-30817-4-git-send-email-yao.jin@linux.intel.com \
--to=yao.jin@linux.intel.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome