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

perf annotate: Move some source code related fields from 'struct annotation'...

perf annotate: Move some source code related fields from 'struct annotation' to 'struct annotated_source'

Some fields in the 'struct annotation' are only used with 'struct
annotated_source' so better to be moved there in order to reduce memory
consumption for other symbols.
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-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2b215ec7
...@@ -384,7 +384,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser) ...@@ -384,7 +384,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
if (al->idx_asm < offset) if (al->idx_asm < offset)
offset = al->idx; offset = al->idx;
browser->b.nr_entries = notes->nr_entries; browser->b.nr_entries = notes->src->nr_entries;
notes->options->hide_src_code = false; notes->options->hide_src_code = false;
browser->b.seek(&browser->b, -offset, SEEK_CUR); browser->b.seek(&browser->b, -offset, SEEK_CUR);
browser->b.top_idx = al->idx - offset; browser->b.top_idx = al->idx - offset;
...@@ -402,7 +402,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser) ...@@ -402,7 +402,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
if (al->idx_asm < offset) if (al->idx_asm < offset)
offset = al->idx_asm; offset = al->idx_asm;
browser->b.nr_entries = notes->nr_asm_entries; browser->b.nr_entries = notes->src->nr_asm_entries;
notes->options->hide_src_code = true; notes->options->hide_src_code = true;
browser->b.seek(&browser->b, -offset, SEEK_CUR); browser->b.seek(&browser->b, -offset, SEEK_CUR);
browser->b.top_idx = al->idx_asm - offset; browser->b.top_idx = al->idx_asm - offset;
...@@ -435,7 +435,7 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser) ...@@ -435,7 +435,7 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser)
{ {
struct annotation *notes = browser__annotation(browser); struct annotation *notes = browser__annotation(browser);
ui_browser__reset_index(browser); ui_browser__reset_index(browser);
browser->nr_entries = notes->nr_asm_entries; browser->nr_entries = notes->src->nr_asm_entries;
} }
static int sym_title(struct symbol *sym, struct map *map, char *title, static int sym_title(struct symbol *sym, struct map *map, char *title,
...@@ -860,7 +860,7 @@ static int annotate_browser__run(struct annotate_browser *browser, ...@@ -860,7 +860,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
browser->b.height, browser->b.height,
browser->b.index, browser->b.index,
browser->b.top_idx, browser->b.top_idx,
notes->nr_asm_entries); notes->src->nr_asm_entries);
} }
continue; continue;
case K_ENTER: case K_ENTER:
...@@ -991,8 +991,8 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, ...@@ -991,8 +991,8 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
ui_helpline__push("Press ESC to exit"); ui_helpline__push("Press ESC to exit");
browser.b.width = notes->max_line_len; browser.b.width = notes->src->max_line_len;
browser.b.nr_entries = notes->nr_entries; browser.b.nr_entries = notes->src->nr_entries;
browser.b.entries = &notes->src->source, browser.b.entries = &notes->src->source,
browser.b.width += 18; /* Percentage */ browser.b.width += 18; /* Percentage */
......
...@@ -2825,19 +2825,20 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym) ...@@ -2825,19 +2825,20 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym)
void annotation__set_offsets(struct annotation *notes, s64 size) void annotation__set_offsets(struct annotation *notes, s64 size)
{ {
struct annotation_line *al; struct annotation_line *al;
struct annotated_source *src = notes->src;
notes->max_line_len = 0; src->max_line_len = 0;
notes->nr_entries = 0; src->nr_entries = 0;
notes->nr_asm_entries = 0; src->nr_asm_entries = 0;
list_for_each_entry(al, &notes->src->source, node) { list_for_each_entry(al, &src->source, node) {
size_t line_len = strlen(al->line); size_t line_len = strlen(al->line);
if (notes->max_line_len < line_len) if (src->max_line_len < line_len)
notes->max_line_len = line_len; src->max_line_len = line_len;
al->idx = notes->nr_entries++; al->idx = src->nr_entries++;
if (al->offset != -1) { if (al->offset != -1) {
al->idx_asm = notes->nr_asm_entries++; al->idx_asm = src->nr_asm_entries++;
/* /*
* FIXME: short term bandaid to cope with assembly * FIXME: short term bandaid to cope with assembly
* routines that comes with labels in the same column * routines that comes with labels in the same column
......
...@@ -268,10 +268,13 @@ struct cyc_hist { ...@@ -268,10 +268,13 @@ struct cyc_hist {
* returns. * returns.
*/ */
struct annotated_source { struct annotated_source {
struct list_head source; struct list_head source;
int nr_histograms; size_t sizeof_sym_hist;
size_t sizeof_sym_hist; struct sym_hist *histograms;
struct sym_hist *histograms; int nr_histograms;
int nr_entries;
int nr_asm_entries;
u16 max_line_len;
}; };
struct annotated_branch { struct annotated_branch {
...@@ -289,9 +292,6 @@ struct LOCKABLE annotation { ...@@ -289,9 +292,6 @@ struct LOCKABLE annotation {
struct annotation_line **offsets; struct annotation_line **offsets;
int nr_events; int nr_events;
int max_jump_sources; int max_jump_sources;
int nr_entries;
int nr_asm_entries;
u16 max_line_len;
struct { struct {
u8 addr; u8 addr;
u8 jumps; u8 jumps;
......
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