perf annotate: Move 'start' field struct to 'struct annotated_source'
authorNamhyung Kim <namhyung@kernel.org>
Thu, 4 Apr 2024 17:57:16 +0000 (10:57 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 8 Apr 2024 20:43:20 +0000 (17:43 -0300)
It's only used in 'perf annotate' output which means functions with actual
samples.  No need to consume memory for every symbol ('struct annotation').

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240404175716.1225482-10-namhyung@kernel.org
Cc: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Cc: <linux-perf-users@vger.kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate.c
tools/perf/util/annotate.h

index 5f79ae0bccfd37200f25d6a6e024389d8427f9ab..4db49611c3868cd7f471aff88882fb664d749dc1 100644 (file)
@@ -909,9 +909,9 @@ int symbol__annotate(struct map_symbol *ms, struct evsel *evsel,
        args.arch = arch;
        args.ms = *ms;
        if (annotate_opts.full_addr)
-               notes->start = map__objdump_2mem(ms->map, ms->sym->start);
+               notes->src->start = map__objdump_2mem(ms->map, ms->sym->start);
        else
-               notes->start = map__rip_2objdump(ms->map, ms->sym->start);
+               notes->src->start = map__rip_2objdump(ms->map, ms->sym->start);
 
        return symbol__disassemble(sym, &args);
 }
@@ -1456,9 +1456,9 @@ void annotation__toggle_full_addr(struct annotation *notes, struct map_symbol *m
        annotate_opts.full_addr = !annotate_opts.full_addr;
 
        if (annotate_opts.full_addr)
-               notes->start = map__objdump_2mem(ms->map, ms->sym->start);
+               notes->src->start = map__objdump_2mem(ms->map, ms->sym->start);
        else
-               notes->start = map__rip_2objdump(ms->map, ms->sym->start);
+               notes->src->start = map__rip_2objdump(ms->map, ms->sym->start);
 
        annotation__update_column_widths(notes);
 }
@@ -1766,7 +1766,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
                int color = -1;
 
                if (!annotate_opts.use_offset)
-                       addr += notes->start;
+                       addr += notes->src->start;
 
                if (!annotate_opts.use_offset) {
                        printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ": ", addr);
index d22b9e9a2fadc8ba91a556d86a190c2a0cdec614..d5c821c22f79e526f9371bfa0b867237422bfee8 100644 (file)
@@ -270,6 +270,7 @@ struct annotated_source {
        int                     nr_entries;
        int                     nr_asm_entries;
        int                     max_jump_sources;
+       u64                     start;
        struct {
                u8              addr;
                u8              jumps;
@@ -312,7 +313,6 @@ struct annotated_branch {
 };
 
 struct LOCKABLE annotation {
-       u64                     start;
        struct annotated_source *src;
        struct annotated_branch *branch;
 };