perf annotate: Split branch stack cycles info from 'struct annotation'

The cycles info is only meaningful when sample has branch stacks.  To
save the memory for normal cases, move those fields to a new 'struct
annotated_branch' and dynamically allocate it when needed.  Also move
cycles_hist from annotated_source as it's related here.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231103191907.54531-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Namhyung Kim
2023-11-03 12:19:04 -07:00
committed by Arnaldo Carvalho de Melo
parent de2c7eb59c
commit b7f87e3259
4 changed files with 75 additions and 63 deletions

View File

@@ -583,21 +583,21 @@ static int hist_entry__sym_ipc_snprintf(struct hist_entry *he, char *bf,
{
struct symbol *sym = he->ms.sym;
struct annotation *notes;
struct annotated_branch *branch;
double ipc = 0.0, coverage = 0.0;
char tmp[64];
if (!sym)
return repsep_snprintf(bf, size, "%-*s", width, "-");
notes = symbol__annotation(sym);
branch = symbol__annotation(sym)->branch;
if (notes->hit_cycles)
ipc = notes->hit_insn / ((double)notes->hit_cycles);
if (branch && branch->hit_cycles)
ipc = branch->hit_insn / ((double)branch->hit_cycles);
if (notes->total_insn) {
coverage = notes->cover_insn * 100.0 /
((double)notes->total_insn);
if (branch && branch->total_insn) {
coverage = branch->cover_insn * 100.0 /
((double)branch->total_insn);
}
snprintf(tmp, sizeof(tmp), "%-5.2f [%5.1f%%]", ipc, coverage);