Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e332f03 authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 93df8a1e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ OPTIONS
	- mispredict: "N" for predicted branch, "Y" for mispredicted branch
	- in_tx: branch in TSX transaction
	- abort: TSX transaction abort.
	- cycles: Cycles in basic block

	And default sort keys are changed to comm, dso_from, symbol_from, dso_to
	and symbol_to, see '--branch-stack'.
+2 −1
Original line number Diff line number Diff line
@@ -134,7 +134,8 @@ struct branch_flags {
	u64 predicted:1;
	u64 in_tx:1;
	u64 abort:1;
	u64 reserved:60;
	u64 cycles:16;
	u64 reserved:44;
};

struct branch_entry {
+2 −1
Original line number Diff line number Diff line
@@ -618,7 +618,8 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a
	 * and not events sampled. Thus we use a pseudo period of 1.
	 */
	he = __hists__add_entry(hists, al, iter->parent, &bi[i], NULL,
				1, 1, 0, true);
				1, bi->flags.cycles ? bi->flags.cycles : 1,
				0, true);
	if (he == NULL)
		return -ENOMEM;

+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ enum hist_column {
	HISTC_MEM_SNOOP,
	HISTC_MEM_DCACHELINE,
	HISTC_TRANSACTION,
	HISTC_CYCLES,
	HISTC_NR_COLS, /* Last entry */
};

+12 −4
Original line number Diff line number Diff line
@@ -784,10 +784,18 @@ static void branch_stack__printf(struct perf_sample *sample)

	printf("... branch stack: nr:%" PRIu64 "\n", sample->branch_stack->nr);

	for (i = 0; i < sample->branch_stack->nr; i++)
		printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 "\n",
			i, sample->branch_stack->entries[i].from,
			sample->branch_stack->entries[i].to);
	for (i = 0; i < sample->branch_stack->nr; i++) {
		struct branch_entry *e = &sample->branch_stack->entries[i];

		printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 " %hu cycles %s%s%s%s %x\n",
			i, e->from, e->to,
			e->flags.cycles,
			e->flags.mispred ? "M" : " ",
			e->flags.predicted ? "P" : " ",
			e->flags.abort ? "A" : " ",
			e->flags.in_tx ? "T" : " ",
			(unsigned)e->flags.reserved);
	}
}

static void regs_dump__printf(u64 mask, u64 *regs)
Loading