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

perf annotate: Move offsets array from 'struct annotation' to 'struct annotated_source'

The offsets array keeps pointers to 'struct annotation_line' entries
which are available in the 'struct annotated_source'.  Let's move it to
there.
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-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0aae4c99
...@@ -188,7 +188,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) ...@@ -188,7 +188,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
* name right after the '<' token and probably treating this like a * name right after the '<' token and probably treating this like a
* 'call' instruction. * 'call' instruction.
*/ */
target = notes->offsets[cursor->ops.target.offset]; target = notes->src->offsets[cursor->ops.target.offset];
if (target == NULL) { if (target == NULL) {
ui_helpline__printf("WARN: jump target inconsistency, press 'o', notes->offsets[%#x] = NULL\n", ui_helpline__printf("WARN: jump target inconsistency, press 'o', notes->offsets[%#x] = NULL\n",
cursor->ops.target.offset); cursor->ops.target.offset);
...@@ -1006,6 +1006,6 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, ...@@ -1006,6 +1006,6 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
out_free_offsets: out_free_offsets:
if(not_annotated) if(not_annotated)
zfree(&notes->offsets); zfree(&notes->src->offsets);
return ret; return ret;
} }
...@@ -1075,7 +1075,7 @@ static unsigned annotation__count_insn(struct annotation *notes, u64 start, u64 ...@@ -1075,7 +1075,7 @@ static unsigned annotation__count_insn(struct annotation *notes, u64 start, u64
u64 offset; u64 offset;
for (offset = start; offset <= end; offset++) { for (offset = start; offset <= end; offset++) {
if (notes->offsets[offset]) if (notes->src->offsets[offset])
n_insn++; n_insn++;
} }
return n_insn; return n_insn;
...@@ -1105,7 +1105,7 @@ static void annotation__count_and_fill(struct annotation *notes, u64 start, u64 ...@@ -1105,7 +1105,7 @@ static void annotation__count_and_fill(struct annotation *notes, u64 start, u64
return; return;
for (offset = start; offset <= end; offset++) { for (offset = start; offset <= end; offset++) {
struct annotation_line *al = notes->offsets[offset]; struct annotation_line *al = notes->src->offsets[offset];
if (al && al->cycles && al->cycles->ipc == 0.0) { if (al && al->cycles && al->cycles->ipc == 0.0) {
al->cycles->ipc = ipc; al->cycles->ipc = ipc;
...@@ -1143,7 +1143,7 @@ static int annotation__compute_ipc(struct annotation *notes, size_t size) ...@@ -1143,7 +1143,7 @@ static int annotation__compute_ipc(struct annotation *notes, size_t size)
if (ch && ch->cycles) { if (ch && ch->cycles) {
struct annotation_line *al; struct annotation_line *al;
al = notes->offsets[offset]; al = notes->src->offsets[offset];
if (al && al->cycles == NULL) { if (al && al->cycles == NULL) {
al->cycles = zalloc(sizeof(*al->cycles)); al->cycles = zalloc(sizeof(*al->cycles));
if (al->cycles == NULL) { if (al->cycles == NULL) {
...@@ -1166,7 +1166,7 @@ static int annotation__compute_ipc(struct annotation *notes, size_t size) ...@@ -1166,7 +1166,7 @@ static int annotation__compute_ipc(struct annotation *notes, size_t size)
struct cyc_hist *ch = &notes->branch->cycles_hist[offset]; struct cyc_hist *ch = &notes->branch->cycles_hist[offset];
if (ch && ch->cycles) { if (ch && ch->cycles) {
struct annotation_line *al = notes->offsets[offset]; struct annotation_line *al = notes->src->offsets[offset];
if (al) if (al)
zfree(&al->cycles); zfree(&al->cycles);
} }
...@@ -2800,7 +2800,7 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym) ...@@ -2800,7 +2800,7 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym)
return; return;
for (offset = 0; offset < size; ++offset) { for (offset = 0; offset < size; ++offset) {
struct annotation_line *al = notes->offsets[offset]; struct annotation_line *al = notes->src->offsets[offset];
struct disasm_line *dl; struct disasm_line *dl;
dl = disasm_line(al); dl = disasm_line(al);
...@@ -2808,7 +2808,7 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym) ...@@ -2808,7 +2808,7 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym)
if (!disasm_line__is_valid_local_jump(dl, sym)) if (!disasm_line__is_valid_local_jump(dl, sym))
continue; continue;
al = notes->offsets[dl->ops.target.offset]; al = notes->src->offsets[dl->ops.target.offset];
/* /*
* FIXME: Oops, no jump target? Buggy disassembler? Or do we * FIXME: Oops, no jump target? Buggy disassembler? Or do we
...@@ -2847,7 +2847,7 @@ void annotation__set_offsets(struct annotation *notes, s64 size) ...@@ -2847,7 +2847,7 @@ void annotation__set_offsets(struct annotation *notes, s64 size)
* E.g. copy_user_generic_unrolled * E.g. copy_user_generic_unrolled
*/ */
if (al->offset < size) if (al->offset < size)
notes->offsets[al->offset] = al; notes->src->offsets[al->offset] = al;
} else } else
al->idx_asm = -1; al->idx_asm = -1;
} }
...@@ -3280,8 +3280,8 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel, ...@@ -3280,8 +3280,8 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel,
size_t size = symbol__size(sym); size_t size = symbol__size(sym);
int nr_pcnt = 1, err; int nr_pcnt = 1, err;
notes->offsets = zalloc(size * sizeof(struct annotation_line *)); notes->src->offsets = zalloc(size * sizeof(struct annotation_line *));
if (notes->offsets == NULL) if (notes->src->offsets == NULL)
return ENOMEM; return ENOMEM;
if (evsel__is_group_event(evsel)) if (evsel__is_group_event(evsel))
...@@ -3311,7 +3311,7 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel, ...@@ -3311,7 +3311,7 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel,
return 0; return 0;
out_free_offsets: out_free_offsets:
zfree(&notes->offsets); zfree(&notes->src->offsets);
return err; return err;
} }
......
...@@ -271,6 +271,7 @@ struct annotated_source { ...@@ -271,6 +271,7 @@ struct annotated_source {
struct list_head source; struct list_head source;
size_t sizeof_sym_hist; size_t sizeof_sym_hist;
struct sym_hist *histograms; struct sym_hist *histograms;
struct annotation_line **offsets;
int nr_histograms; int nr_histograms;
int nr_entries; int nr_entries;
int nr_asm_entries; int nr_asm_entries;
...@@ -289,7 +290,6 @@ struct annotated_branch { ...@@ -289,7 +290,6 @@ struct annotated_branch {
struct LOCKABLE annotation { struct LOCKABLE annotation {
u64 start; u64 start;
struct annotation_options *options; struct annotation_options *options;
struct annotation_line **offsets;
int nr_events; int nr_events;
int max_jump_sources; int max_jump_sources;
struct { struct {
......
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