diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-11-04 21:57:38 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-11-12 14:20:53 +0300 |
commit | d46a4cdf49937b0b3abeb2cd7fa5dc65795e7ea7 (patch) | |
tree | 0537e9384efbdcf3d97e4ab1c4dd8bd8e751e5c4 /tools/perf/util/sort.c | |
parent | 5f0fef8ac3e7a5707751493293ba8ff2ffc0f8a4 (diff) | |
download | linux-d46a4cdf49937b0b3abeb2cd7fa5dc65795e7ea7.tar.xz |
pref tools: Make 'struct addr_map_symbol' contain 'struct map_symbol'
So that we pass that substructure around and with it consolidate lots of
functions that receive a (map, symbol) pair and now can receive just a
'struct map_symbol' pointer.
This further paves the way to add 'struct map_groups' to 'struct
map_symbol' so that we can have all we need for annotation so that we
can ditch 'struct map'->groups, i.e. have the map_groups pointer in a
more central place, avoiding the pointer in the 'struct map' that have
tons of instances.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-fs90ttd9q12l7989fo7pw81q@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/sort.c')
-rw-r--r-- | tools/perf/util/sort.c | 89 |
1 files changed, 41 insertions, 48 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 43d1d410854a..6b626e6b111e 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -287,10 +287,12 @@ sort__sym_sort(struct hist_entry *left, struct hist_entry *right) return strcmp(right->ms.sym->name, left->ms.sym->name); } -static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, +static int _hist_entry__sym_snprintf(struct map_symbol *ms, u64 ip, char level, char *bf, size_t size, unsigned int width) { + struct symbol *sym = ms->sym; + struct map *map = ms->map; size_t ret = 0; if (verbose > 0) { @@ -325,7 +327,7 @@ static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, static int hist_entry__sym_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { - return _hist_entry__sym_snprintf(he->ms.map, he->ms.sym, he->ip, + return _hist_entry__sym_snprintf(&he->ms, he->ip, he->level, bf, size, width); } @@ -386,7 +388,7 @@ struct sort_entry sort_srcline = { static char *addr_map_symbol__srcline(struct addr_map_symbol *ams) { - return map__srcline(ams->map, ams->al_addr, ams->sym); + return map__srcline(ams->ms.map, ams->al_addr, ams->ms.sym); } static int64_t @@ -769,15 +771,15 @@ sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right) if (!left->branch_info || !right->branch_info) return cmp_null(left->branch_info, right->branch_info); - return _sort__dso_cmp(left->branch_info->from.map, - right->branch_info->from.map); + return _sort__dso_cmp(left->branch_info->from.ms.map, + right->branch_info->from.ms.map); } static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { if (he->branch_info) - return _hist_entry__dso_snprintf(he->branch_info->from.map, + return _hist_entry__dso_snprintf(he->branch_info->from.ms.map, bf, size, width); else return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); @@ -791,8 +793,8 @@ static int hist_entry__dso_from_filter(struct hist_entry *he, int type, if (type != HIST_FILTER__DSO) return -1; - return dso && (!he->branch_info || !he->branch_info->from.map || - he->branch_info->from.map->dso != dso); + return dso && (!he->branch_info || !he->branch_info->from.ms.map || + he->branch_info->from.ms.map->dso != dso); } static int64_t @@ -801,15 +803,15 @@ sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right) if (!left->branch_info || !right->branch_info) return cmp_null(left->branch_info, right->branch_info); - return _sort__dso_cmp(left->branch_info->to.map, - right->branch_info->to.map); + return _sort__dso_cmp(left->branch_info->to.ms.map, + right->branch_info->to.ms.map); } static int hist_entry__dso_to_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { if (he->branch_info) - return _hist_entry__dso_snprintf(he->branch_info->to.map, + return _hist_entry__dso_snprintf(he->branch_info->to.ms.map, bf, size, width); else return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); @@ -823,8 +825,8 @@ static int hist_entry__dso_to_filter(struct hist_entry *he, int type, if (type != HIST_FILTER__DSO) return -1; - return dso && (!he->branch_info || !he->branch_info->to.map || - he->branch_info->to.map->dso != dso); + return dso && (!he->branch_info || !he->branch_info->to.ms.map || + he->branch_info->to.ms.map->dso != dso); } static int64_t @@ -839,10 +841,10 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right) from_l = &left->branch_info->from; from_r = &right->branch_info->from; - if (!from_l->sym && !from_r->sym) + if (!from_l->ms.sym && !from_r->ms.sym) return _sort__addr_cmp(from_l->addr, from_r->addr); - return _sort__sym_cmp(from_l->sym, from_r->sym); + return _sort__sym_cmp(from_l->ms.sym, from_r->ms.sym); } static int64_t @@ -856,10 +858,10 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right) to_l = &left->branch_info->to; to_r = &right->branch_info->to; - if (!to_l->sym && !to_r->sym) + if (!to_l->ms.sym && !to_r->ms.sym) return _sort__addr_cmp(to_l->addr, to_r->addr); - return _sort__sym_cmp(to_l->sym, to_r->sym); + return _sort__sym_cmp(to_l->ms.sym, to_r->ms.sym); } static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf, @@ -868,8 +870,7 @@ static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf, if (he->branch_info) { struct addr_map_symbol *from = &he->branch_info->from; - return _hist_entry__sym_snprintf(from->map, from->sym, from->addr, - he->level, bf, size, width); + return _hist_entry__sym_snprintf(&from->ms, from->addr, he->level, bf, size, width); } return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); @@ -881,8 +882,7 @@ static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf, if (he->branch_info) { struct addr_map_symbol *to = &he->branch_info->to; - return _hist_entry__sym_snprintf(to->map, to->sym, to->addr, - he->level, bf, size, width); + return _hist_entry__sym_snprintf(&to->ms, to->addr, he->level, bf, size, width); } return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); @@ -896,8 +896,8 @@ static int hist_entry__sym_from_filter(struct hist_entry *he, int type, if (type != HIST_FILTER__SYMBOL) return -1; - return sym && !(he->branch_info && he->branch_info->from.sym && - strstr(he->branch_info->from.sym->name, sym)); + return sym && !(he->branch_info && he->branch_info->from.ms.sym && + strstr(he->branch_info->from.ms.sym->name, sym)); } static int hist_entry__sym_to_filter(struct hist_entry *he, int type, @@ -908,8 +908,8 @@ static int hist_entry__sym_to_filter(struct hist_entry *he, int type, if (type != HIST_FILTER__SYMBOL) return -1; - return sym && !(he->branch_info && he->branch_info->to.sym && - strstr(he->branch_info->to.sym->name, sym)); + return sym && !(he->branch_info && he->branch_info->to.ms.sym && + strstr(he->branch_info->to.ms.sym->name, sym)); } struct sort_entry sort_dso_from = { @@ -1017,16 +1017,13 @@ static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { uint64_t addr = 0; - struct map *map = NULL; - struct symbol *sym = NULL; + struct map_symbol *ms = NULL; if (he->mem_info) { addr = he->mem_info->daddr.addr; - map = he->mem_info->daddr.map; - sym = he->mem_info->daddr.sym; + ms = &he->mem_info->daddr.ms; } - return _hist_entry__sym_snprintf(map, sym, addr, he->level, bf, size, - width); + return _hist_entry__sym_snprintf(ms, addr, he->level, bf, size, width); } int64_t @@ -1046,16 +1043,13 @@ static int hist_entry__iaddr_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { uint64_t addr = 0; - struct map *map = NULL; - struct symbol *sym = NULL; + struct map_symbol *ms = NULL; if (he->mem_info) { addr = he->mem_info->iaddr.addr; - map = he->mem_info->iaddr.map; - sym = he->mem_info->iaddr.sym; + ms = &he->mem_info->iaddr.ms; } - return _hist_entry__sym_snprintf(map, sym, addr, he->level, bf, size, - width); + return _hist_entry__sym_snprintf(ms, addr, he->level, bf, size, width); } static int64_t @@ -1065,9 +1059,9 @@ sort__dso_daddr_cmp(struct hist_entry *left, struct hist_entry *right) struct map *map_r = NULL; if (left->mem_info) - map_l = left->mem_info->daddr.map; + map_l = left->mem_info->daddr.ms.map; if (right->mem_info) - map_r = right->mem_info->daddr.map; + map_r = right->mem_info->daddr.ms.map; return _sort__dso_cmp(map_l, map_r); } @@ -1078,7 +1072,7 @@ static int hist_entry__dso_daddr_snprintf(struct hist_entry *he, char *bf, struct map *map = NULL; if (he->mem_info) - map = he->mem_info->daddr.map; + map = he->mem_info->daddr.ms.map; return _hist_entry__dso_snprintf(map, bf, size, width); } @@ -1208,8 +1202,8 @@ sort__dcacheline_cmp(struct hist_entry *left, struct hist_entry *right) if (left->cpumode > right->cpumode) return -1; if (left->cpumode < right->cpumode) return 1; - l_map = left->mem_info->daddr.map; - r_map = right->mem_info->daddr.map; + l_map = left->mem_info->daddr.ms.map; + r_map = right->mem_info->daddr.ms.map; /* if both are NULL, jump to sort on al_addr instead */ if (!l_map && !r_map) @@ -1264,14 +1258,14 @@ static int hist_entry__dcacheline_snprintf(struct hist_entry *he, char *bf, { uint64_t addr = 0; - struct map *map = NULL; - struct symbol *sym = NULL; + struct map_symbol *ms = NULL; char level = he->level; if (he->mem_info) { + struct map *map = he->mem_info->daddr.ms.map; + addr = cl_address(he->mem_info->daddr.al_addr); - map = he->mem_info->daddr.map; - sym = he->mem_info->daddr.sym; + ms = &he->mem_info->daddr.ms; /* print [s] for shared data mmaps */ if ((he->cpumode != PERF_RECORD_MISC_KERNEL) && @@ -1283,8 +1277,7 @@ static int hist_entry__dcacheline_snprintf(struct hist_entry *he, char *bf, else if (!map) level = 'X'; } - return _hist_entry__sym_snprintf(map, sym, addr, level, bf, size, - width); + return _hist_entry__sym_snprintf(ms, addr, level, bf, size, width); } struct sort_entry sort_mispredict = { |