Skip to content

Commit 83cf774

Browse files
committed
perf map: Shorten map_groups__find_by_name() signature
Another step in the road to elliminate the MAP_{FUNCTION,VARIABLE} separation, reducing the exposure to these details in the tools using the symbol APIs. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-8a1hvrqe3r5i0kw865u3uxwt@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent d9a5f27 commit 83cf774

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎tools/perf/tests/vmlinux-kallsyms.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
183183
* so use the short name, less descriptive but the same ("[kernel]" in
184184
* both cases.
185185
*/
186-
pair = map_groups__find_by_name(&kallsyms.kmaps, type,
186+
pair = map_groups__find_by_name(&kallsyms.kmaps,
187187
(map->dso->kernel ?
188188
map->dso->short_name :
189189
map->dso->name));

‎tools/perf/util/machine.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,7 @@ struct map *machine__findnew_module_map(struct machine *machine, u64 start,
673673
if (kmod_path__parse_name(&m, filename))
674674
return NULL;
675675

676-
map = map_groups__find_by_name(&machine->kmaps, MAP__FUNCTION,
677-
m.name);
676+
map = map_groups__find_by_name(&machine->kmaps, m.name);
678677
if (map) {
679678
/*
680679
* If the map's dso is an offline module, give dso__load()
@@ -1055,10 +1054,9 @@ static bool is_kmod_dso(struct dso *dso)
10551054
static int map_groups__set_module_path(struct map_groups *mg, const char *path,
10561055
struct kmod_path *m)
10571056
{
1058-
struct map *map;
10591057
char *long_name;
1058+
struct map *map = map_groups__find_by_name(mg, m->name);
10601059

1061-
map = map_groups__find_by_name(mg, MAP__FUNCTION, m->name);
10621060
if (map == NULL)
10631061
return 0;
10641062

‎tools/perf/util/map.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
254254
int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
255255
FILE *fp);
256256

257-
struct map *map_groups__find_by_name(struct map_groups *mg,
258-
enum map_type type, const char *name);
257+
struct map *__map_groups__find_by_name(struct map_groups *mg, enum map_type type, const char *name);
258+
259+
static inline struct map *map_groups__find_by_name(struct map_groups *mg, const char *name)
260+
{
261+
return __map_groups__find_by_name(mg, MAP__FUNCTION, name);
262+
}
259263

260264
bool __map__is_kernel(const struct map *map);
261265

‎tools/perf/util/probe-event.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso)
341341
char module_name[128];
342342

343343
snprintf(module_name, sizeof(module_name), "[%s]", module);
344-
map = map_groups__find_by_name(&host_machine->kmaps, MAP__FUNCTION, module_name);
344+
map = map_groups__find_by_name(&host_machine->kmaps, module_name);
345345
if (map) {
346346
dso = map->dso;
347347
goto found;

‎tools/perf/util/symbol-elf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
10421042
snprintf(dso_name, sizeof(dso_name),
10431043
"%s%s", dso->short_name, section_name);
10441044

1045-
curr_map = map_groups__find_by_name(kmaps, map->type, dso_name);
1045+
curr_map = __map_groups__find_by_name(kmaps, map->type, dso_name);
10461046
if (curr_map == NULL) {
10471047
u64 start = sym.st_value;
10481048

‎tools/perf/util/symbol.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,7 @@ static int dso__split_kallsyms(struct dso *dso, struct map *map, u64 delta)
792792
curr_map->type);
793793
}
794794

795-
curr_map = map_groups__find_by_name(kmaps,
796-
map->type, module);
795+
curr_map = __map_groups__find_by_name(kmaps, map->type, module);
797796
if (curr_map == NULL) {
798797
pr_debug("%s/proc/{kallsyms,modules} "
799798
"inconsistency while looking "
@@ -1667,8 +1666,7 @@ int dso__load(struct dso *dso, struct map *map)
16671666
return ret;
16681667
}
16691668

1670-
struct map *map_groups__find_by_name(struct map_groups *mg,
1671-
enum map_type type, const char *name)
1669+
struct map *__map_groups__find_by_name(struct map_groups *mg, enum map_type type, const char *name)
16721670
{
16731671
struct maps *maps = &mg->maps[type];
16741672
struct map *map;

0 commit comments

Comments
 (0)