diff options
author | Ian Rogers <irogers@google.com> | 2025-01-17 10:18:48 -0800 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2025-01-18 10:02:10 -0800 |
commit | 035f0c279bcfc07314240de273d90f4061aef04d (patch) | |
tree | 28ff6090c9d777f129609c70ab4c9b3ca018f6fc /tools/perf/util/annotate.h | |
parent | ac22d75377a04ceca53a8d438440e82bf4c722fc (diff) |
perf annotate: Prefer passing evsel to evsel->core.idx
An evsel idx may not be stable due to sorting, evlist removal,
etc. Try to reduce it being part of APIs by explicitly passing the
evsel in annotate code. Internally the code just reads evsel->core.idx
so behavior is unchanged.
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Chen Ni <nichen@iscas.ac.cn>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Link: https://lore.kernel.org/r/20250117181848.690474-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/annotate.h')
-rw-r--r-- | tools/perf/util/annotate.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index c6a59aaefdb8..0ba5846dad4d 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -15,6 +15,7 @@ #include "hashmap.h" #include "disasm.h" #include "branch.h" +#include "evsel.h" struct hist_browser_timer; struct hist_entry; @@ -23,7 +24,6 @@ struct map_symbol; struct addr_map_symbol; struct option; struct perf_sample; -struct evsel; struct symbol; struct annotated_data_type; @@ -373,21 +373,23 @@ static inline u8 annotation__br_cntr_width(void) void annotation__update_column_widths(struct annotation *notes); void annotation__toggle_full_addr(struct annotation *notes, struct map_symbol *ms); -static inline struct sym_hist *annotated_source__histogram(struct annotated_source *src, int idx) +static inline struct sym_hist *annotated_source__histogram(struct annotated_source *src, + const struct evsel *evsel) { - return &src->histograms[idx]; + return &src->histograms[evsel->core.idx]; } -static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx) +static inline struct sym_hist *annotation__histogram(struct annotation *notes, + const struct evsel *evsel) { - return annotated_source__histogram(notes->src, idx); + return annotated_source__histogram(notes->src, evsel); } static inline struct sym_hist_entry * -annotated_source__hist_entry(struct annotated_source *src, int idx, u64 offset) +annotated_source__hist_entry(struct annotated_source *src, const struct evsel *evsel, u64 offset) { struct sym_hist_entry *entry; - long key = offset << 16 | idx; + long key = offset << 16 | evsel->core.idx; if (!hashmap__find(src->samples, key, &entry)) return NULL; @@ -449,8 +451,8 @@ enum symbol_disassemble_errno { int symbol__strerror_disassemble(struct map_symbol *ms, int errnum, char *buf, size_t buflen); int symbol__annotate_printf(struct map_symbol *ms, struct evsel *evsel); -void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); -void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); +void symbol__annotate_zero_histogram(struct symbol *sym, struct evsel *evsel); +void symbol__annotate_decay_histogram(struct symbol *sym, struct evsel *evsel); void annotated_source__purge(struct annotated_source *as); int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel); |