Commit 2b215ec7 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf annotate: Move max_coverage from 'struct annotation' to 'struct annotated_branch'

The max_coverage field is only used when branch stack info is available
so it'd be natural to move to 'struct annotated_branch'.
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
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-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b7f87e32
...@@ -94,6 +94,7 @@ static void process_basic_block(struct addr_map_symbol *start, ...@@ -94,6 +94,7 @@ static void process_basic_block(struct addr_map_symbol *start,
struct annotation *notes = sym ? symbol__annotation(sym) : NULL; struct annotation *notes = sym ? symbol__annotation(sym) : NULL;
struct block_range_iter iter; struct block_range_iter iter;
struct block_range *entry; struct block_range *entry;
struct annotated_branch *branch;
/* /*
* Sanity; NULL isn't executable and the CPU cannot execute backwards * Sanity; NULL isn't executable and the CPU cannot execute backwards
...@@ -105,6 +106,8 @@ static void process_basic_block(struct addr_map_symbol *start, ...@@ -105,6 +106,8 @@ static void process_basic_block(struct addr_map_symbol *start,
if (!block_range_iter__valid(&iter)) if (!block_range_iter__valid(&iter))
return; return;
branch = annotation__get_branch(notes);
/* /*
* First block in range is a branch target. * First block in range is a branch target.
*/ */
...@@ -118,8 +121,8 @@ static void process_basic_block(struct addr_map_symbol *start, ...@@ -118,8 +121,8 @@ static void process_basic_block(struct addr_map_symbol *start,
entry->coverage++; entry->coverage++;
entry->sym = sym; entry->sym = sym;
if (notes) if (branch)
notes->max_coverage = max(notes->max_coverage, entry->coverage); branch->max_coverage = max(branch->max_coverage, entry->coverage);
} while (block_range_iter__next(&iter)); } while (block_range_iter__next(&iter));
......
...@@ -946,7 +946,7 @@ static int __symbol__inc_addr_samples(struct map_symbol *ms, ...@@ -946,7 +946,7 @@ static int __symbol__inc_addr_samples(struct map_symbol *ms,
return 0; return 0;
} }
static struct annotated_branch *annotation__get_branch(struct annotation *notes) struct annotated_branch *annotation__get_branch(struct annotation *notes)
{ {
if (notes == NULL) if (notes == NULL)
return NULL; return NULL;
......
...@@ -280,10 +280,10 @@ struct annotated_branch { ...@@ -280,10 +280,10 @@ struct annotated_branch {
unsigned int total_insn; unsigned int total_insn;
unsigned int cover_insn; unsigned int cover_insn;
struct cyc_hist *cycles_hist; struct cyc_hist *cycles_hist;
u64 max_coverage;
}; };
struct LOCKABLE annotation { struct LOCKABLE annotation {
u64 max_coverage;
u64 start; u64 start;
struct annotation_options *options; struct annotation_options *options;
struct annotation_line **offsets; struct annotation_line **offsets;
...@@ -355,6 +355,8 @@ static inline struct annotation *symbol__annotation(struct symbol *sym) ...@@ -355,6 +355,8 @@ static inline struct annotation *symbol__annotation(struct symbol *sym)
int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample, int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
struct evsel *evsel); struct evsel *evsel);
struct annotated_branch *annotation__get_branch(struct annotation *notes);
int addr_map_symbol__account_cycles(struct addr_map_symbol *ams, int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
struct addr_map_symbol *start, struct addr_map_symbol *start,
unsigned cycles); unsigned cycles);
......
...@@ -311,6 +311,7 @@ struct block_range_iter block_range__create(u64 start, u64 end) ...@@ -311,6 +311,7 @@ struct block_range_iter block_range__create(u64 start, u64 end)
double block_range__coverage(struct block_range *br) double block_range__coverage(struct block_range *br)
{ {
struct symbol *sym; struct symbol *sym;
struct annotated_branch *branch;
if (!br) { if (!br) {
if (block_ranges.blocks) if (block_ranges.blocks)
...@@ -323,5 +324,9 @@ double block_range__coverage(struct block_range *br) ...@@ -323,5 +324,9 @@ double block_range__coverage(struct block_range *br)
if (!sym) if (!sym)
return -1; return -1;
return (double)br->coverage / symbol__annotation(sym)->max_coverage; branch = symbol__annotation(sym)->branch;
if (!branch)
return -1;
return (double)br->coverage / branch->max_coverage;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment