[PATCH 10/35] perf annotate: Add evsel into struct annotation_line_args

From: Jiri Olsa
Date: Wed Oct 11 2017 - 11:07:53 EST


Adding evsel into struct annotate_args to reduce the number
of arguments that need to travel all the way to line allocation.

This change also allow us to move the arch name initialization
under symbol__annotate function.

Link: http://lkml.kernel.org/n/tip-a9ok53rrgt1s5e8uglyvy6qt@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/ui/browsers/annotate.c | 2 +-
tools/perf/ui/gtk/annotate.c | 3 +--
tools/perf/util/annotate.c | 11 ++++++++---
tools/perf/util/annotate.h | 2 +-
4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 0ed935d934a0..2e2216e05444 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -1119,7 +1119,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
(nr_pcnt - 1);
}

- err = symbol__annotate(sym, map, perf_evsel__env_arch(evsel),
+ err = symbol__annotate(sym, map, evsel,
sizeof_bdl, &browser.arch,
perf_evsel__env_cpuid(evsel));
if (err) {
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index f5a81323bbe2..66e0352da391 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -168,8 +168,7 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
if (map->dso->annotate_warned)
return -1;

- err = symbol__annotate(sym, map, perf_evsel__env_arch(evsel),
- 0, NULL, NULL);
+ err = symbol__annotate(sym, map, evsel, 0, NULL, NULL);
if (err) {
char msg[BUFSIZ];
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 84afd05079b9..4462975fcafc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -872,6 +872,7 @@ struct annotate_args {
size_t privsize;
struct arch *arch;
struct map *map;
+ struct perf_evsel *evsel;
s64 offset;
char *line;
int line_nr;
@@ -1560,16 +1561,21 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
}

int symbol__annotate(struct symbol *sym, struct map *map,
- const char *arch_name, size_t privsize,
+ struct perf_evsel *evsel, size_t privsize,
struct arch **parch, char *cpuid)
{
struct annotate_args args = {
.privsize = privsize,
.map = map,
+ .evsel = evsel,
};
+ const char *arch_name = NULL;
struct arch *arch;
int err;

+ if (evsel)
+ arch_name = perf_evsel__env_arch(evsel);
+
arch_name = annotate__norm_arch(arch_name);
if (!arch_name)
return -1;
@@ -1965,8 +1971,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
struct rb_root source_line = RB_ROOT;
u64 len;

- if (symbol__annotate(sym, map, perf_evsel__env_arch(evsel),
- 0, NULL, NULL) < 0)
+ if (symbol__annotate(sym, map, evsel, 0, NULL, NULL) < 0)
return -1;

len = symbol__size(sym);
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index da494276c2b0..49161a95861e 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -173,7 +173,7 @@ int symbol__alloc_hist(struct symbol *sym);
void symbol__annotate_zero_histograms(struct symbol *sym);

int symbol__annotate(struct symbol *sym, struct map *map,
- const char *arch_name, size_t privsize,
+ struct perf_evsel *evsel, size_t privsize,
struct arch **parch, char *cpuid);

enum symbol_disassemble_errno {
--
2.13.6