Skip to content

Commit 5784999

Browse files
Andi Kleenacmel
authored andcommitted
perf report: Add processing for cycle histograms
Call the earlier added cycle histogram infrastructure from the perf report hist iter callback. For this we walk the branch records. This allows to use cycle histograms when browsing perf report annotate. v2: Rename flag Signed-off-by: Andi Kleen <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d495763 commit 5784999

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

tools/perf/builtin-report.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
103103
if (!ui__has_annotation())
104104
return 0;
105105

106+
hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
107+
rep->nonany_branch_mode);
108+
106109
if (sort__mode == SORT_MODE__BRANCH) {
107110
bi = he->branch_info;
108111
err = addr_map_symbol__inc_samples(&bi->from, evsel->idx);

tools/perf/util/hist.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,39 @@ int hists__link(struct hists *leader, struct hists *other)
14151415
return 0;
14161416
}
14171417

1418+
void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
1419+
struct perf_sample *sample, bool nonany_branch_mode)
1420+
{
1421+
struct branch_info *bi;
1422+
1423+
/* If we have branch cycles always annotate them. */
1424+
if (bs && bs->nr && bs->entries[0].flags.cycles) {
1425+
int i;
1426+
1427+
bi = sample__resolve_bstack(sample, al);
1428+
if (bi) {
1429+
struct addr_map_symbol *prev = NULL;
1430+
1431+
/*
1432+
* Ignore errors, still want to process the
1433+
* other entries.
1434+
*
1435+
* For non standard branch modes always
1436+
* force no IPC (prev == NULL)
1437+
*
1438+
* Note that perf stores branches reversed from
1439+
* program order!
1440+
*/
1441+
for (i = bs->nr - 1; i >= 0; i--) {
1442+
addr_map_symbol__account_cycles(&bi[i].from,
1443+
nonany_branch_mode ? NULL : prev,
1444+
bi[i].flags.cycles);
1445+
prev = &bi[i].to;
1446+
}
1447+
free(bi);
1448+
}
1449+
}
1450+
}
14181451

14191452
size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp)
14201453
{

tools/perf/util/hist.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ static inline int script_browse(const char *script_opt __maybe_unused)
350350

351351
unsigned int hists__sort_list_width(struct hists *hists);
352352

353+
void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
354+
struct perf_sample *sample, bool nonany_branch_mode);
355+
353356
struct option;
354357
int parse_filter_percentage(const struct option *opt __maybe_unused,
355358
const char *arg, int unset __maybe_unused);

0 commit comments

Comments
 (0)