Skip to content

Commit

Permalink
perf maps: Move kmap::kmaps setup to maps__insert()
Browse files Browse the repository at this point in the history
So the kmaps pointer setup is centralized and we do not need to update
it in all those places (2 current places and few more missing) after
calling maps__insert().

Reported-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Kim Phillips <kim.phillips@amd.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200210143218.24948-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Feb 11, 2020
1 parent 7ce6613 commit 484214f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
13 changes: 1 addition & 12 deletions tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ int machine__create_extra_kernel_map(struct machine *machine,

kmap = map__kmap(map);

kmap->kmaps = &machine->kmaps;
strlcpy(kmap->name, xm->name, KMAP_NAME_LEN);

maps__insert(&machine->kmaps, map);
Expand Down Expand Up @@ -1091,9 +1090,6 @@ int __weak machine__create_extra_kernel_maps(struct machine *machine __maybe_unu
static int
__machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
{
struct kmap *kmap;
struct map *map;

/* In case of renewal the kernel map, destroy previous one */
machine__destroy_kernel_maps(machine);

Expand All @@ -1102,14 +1098,7 @@ __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
return -1;

machine->vmlinux_map->map_ip = machine->vmlinux_map->unmap_ip = identity__map_ip;
map = machine__kernel_map(machine);
kmap = map__kmap(map);
if (!kmap)
return -1;

kmap->kmaps = &machine->kmaps;
maps__insert(&machine->kmaps, map);

maps__insert(&machine->kmaps, machine->vmlinux_map);
return 0;
}

Expand Down
10 changes: 10 additions & 0 deletions tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,16 @@ void maps__insert(struct maps *maps, struct map *map)
__maps__insert(maps, map);
++maps->nr_maps;

if (map->dso && map->dso->kernel) {
struct kmap *kmap = map__kmap(map);

if (kmap)
kmap->kmaps = maps;
else
pr_err("Internal error: kernel dso with non kernel map\n");
}


/*
* If we already performed some search by name, then we need to add the just
* inserted map and resort.
Expand Down

0 comments on commit 484214f

Please sign in to comment.