aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2015-07-18 11:24:46 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-06 15:29:45 -0400
commit0e332f033a8216fa03792fde69882f66500848c7 (patch)
treeb88becef22fec7eb369b5dec4ba58e57985fd4b5 /tools/perf
parent93df8a1ed6231727c5db94a80b1a6bd5ee67cec3 (diff)
perf tools: Add support for cycles, weight branch_info field
cycles is a new branch_info field available on some CPUs that indicates the time deltas between branches in the LBR. Add a sort key and output code for the cycles to allow to display the basic block cycles individually in perf report. We also pass in the cycles for weight when LBRs are processed, which allows to get global and local weight, to get an estimate of the total cost. And also print the cycles information for perf report -D. I also added printing for the previously missing LBR flags (mispredict etc.) Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1437233094-12844-2-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Documentation/perf-report.txt1
-rw-r--r--tools/perf/util/event.h3
-rw-r--r--tools/perf/util/hist.c3
-rw-r--r--tools/perf/util/hist.h1
-rw-r--r--tools/perf/util/session.c16
-rw-r--r--tools/perf/util/sort.c24
-rw-r--r--tools/perf/util/sort.h1
7 files changed, 43 insertions, 6 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index c33b69f3374f..960da203ec11 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -109,6 +109,7 @@ OPTIONS
109 - mispredict: "N" for predicted branch, "Y" for mispredicted branch 109 - mispredict: "N" for predicted branch, "Y" for mispredicted branch
110 - in_tx: branch in TSX transaction 110 - in_tx: branch in TSX transaction
111 - abort: TSX transaction abort. 111 - abort: TSX transaction abort.
112 - cycles: Cycles in basic block
112 113
113 And default sort keys are changed to comm, dso_from, symbol_from, dso_to 114 And default sort keys are changed to comm, dso_from, symbol_from, dso_to
114 and symbol_to, see '--branch-stack'. 115 and symbol_to, see '--branch-stack'.
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 4bb2ae894c78..f729df5e25e6 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -134,7 +134,8 @@ struct branch_flags {
134 u64 predicted:1; 134 u64 predicted:1;
135 u64 in_tx:1; 135 u64 in_tx:1;
136 u64 abort:1; 136 u64 abort:1;
137 u64 reserved:60; 137 u64 cycles:16;
138 u64 reserved:44;
138}; 139};
139 140
140struct branch_entry { 141struct branch_entry {
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 6f28d53d4e46..54fc0033dd6a 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -618,7 +618,8 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a
618 * and not events sampled. Thus we use a pseudo period of 1. 618 * and not events sampled. Thus we use a pseudo period of 1.
619 */ 619 */
620 he = __hists__add_entry(hists, al, iter->parent, &bi[i], NULL, 620 he = __hists__add_entry(hists, al, iter->parent, &bi[i], NULL,
621 1, 1, 0, true); 621 1, bi->flags.cycles ? bi->flags.cycles : 1,
622 0, true);
622 if (he == NULL) 623 if (he == NULL)
623 return -ENOMEM; 624 return -ENOMEM;
624 625
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 5ed8d9c22981..3881d9815309 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -47,6 +47,7 @@ enum hist_column {
47 HISTC_MEM_SNOOP, 47 HISTC_MEM_SNOOP,
48 HISTC_MEM_DCACHELINE, 48 HISTC_MEM_DCACHELINE,
49 HISTC_TRANSACTION, 49 HISTC_TRANSACTION,
50 HISTC_CYCLES,
50 HISTC_NR_COLS, /* Last entry */ 51 HISTC_NR_COLS, /* Last entry */
51}; 52};
52 53
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f51eb54aeeb3..18722e774a69 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -784,10 +784,18 @@ static void branch_stack__printf(struct perf_sample *sample)
784 784
785 printf("... branch stack: nr:%" PRIu64 "\n", sample->branch_stack->nr); 785 printf("... branch stack: nr:%" PRIu64 "\n", sample->branch_stack->nr);
786 786
787 for (i = 0; i < sample->branch_stack->nr; i++) 787 for (i = 0; i < sample->branch_stack->nr; i++) {
788 printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 "\n", 788 struct branch_entry *e = &sample->branch_stack->entries[i];
789 i, sample->branch_stack->entries[i].from, 789
790 sample->branch_stack->entries[i].to); 790 printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 " %hu cycles %s%s%s%s %x\n",
791 i, e->from, e->to,
792 e->flags.cycles,
793 e->flags.mispred ? "M" : " ",
794 e->flags.predicted ? "P" : " ",
795 e->flags.abort ? "A" : " ",
796 e->flags.in_tx ? "T" : " ",
797 (unsigned)e->flags.reserved);
798 }
791} 799}
792 800
793static void regs_dump__printf(u64 mask, u64 *regs) 801static void regs_dump__printf(u64 mask, u64 *regs)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 4c65a143a34c..5b7a50c04e45 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -526,6 +526,29 @@ static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf,
526 return repsep_snprintf(bf, size, "%-*.*s", width, width, out); 526 return repsep_snprintf(bf, size, "%-*.*s", width, width, out);
527} 527}
528 528
529static int64_t
530sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right)
531{
532 return left->branch_info->flags.cycles -
533 right->branch_info->flags.cycles;
534}
535
536static int hist_entry__cycles_snprintf(struct hist_entry *he, char *bf,
537 size_t size, unsigned int width)
538{
539 if (he->branch_info->flags.cycles == 0)
540 return repsep_snprintf(bf, size, "%-*s", width, "-");
541 return repsep_snprintf(bf, size, "%-*hd", width,
542 he->branch_info->flags.cycles);
543}
544
545struct sort_entry sort_cycles = {
546 .se_header = "Basic Block Cycles",
547 .se_cmp = sort__cycles_cmp,
548 .se_snprintf = hist_entry__cycles_snprintf,
549 .se_width_idx = HISTC_CYCLES,
550};
551
529/* --sort daddr_sym */ 552/* --sort daddr_sym */
530static int64_t 553static int64_t
531sort__daddr_cmp(struct hist_entry *left, struct hist_entry *right) 554sort__daddr_cmp(struct hist_entry *left, struct hist_entry *right)
@@ -1190,6 +1213,7 @@ static struct sort_dimension bstack_sort_dimensions[] = {
1190 DIM(SORT_MISPREDICT, "mispredict", sort_mispredict), 1213 DIM(SORT_MISPREDICT, "mispredict", sort_mispredict),
1191 DIM(SORT_IN_TX, "in_tx", sort_in_tx), 1214 DIM(SORT_IN_TX, "in_tx", sort_in_tx),
1192 DIM(SORT_ABORT, "abort", sort_abort), 1215 DIM(SORT_ABORT, "abort", sort_abort),
1216 DIM(SORT_CYCLES, "cycles", sort_cycles),
1193}; 1217};
1194 1218
1195#undef DIM 1219#undef DIM
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index e97cd476d336..bc6c87a76d16 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -185,6 +185,7 @@ enum sort_type {
185 SORT_MISPREDICT, 185 SORT_MISPREDICT,
186 SORT_ABORT, 186 SORT_ABORT,
187 SORT_IN_TX, 187 SORT_IN_TX,
188 SORT_CYCLES,
188 189
189 /* memory mode specific sort keys */ 190 /* memory mode specific sort keys */
190 __SORT_MEMORY_MODE, 191 __SORT_MEMORY_MODE,