Commit ee05d217 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf machine: Set main kernel end address properly

map_groups__fixup_end() was called to set the end addresses of kernel
and module maps.  But now since machine__create_modules() sets the end
address of modules properly, the only remaining piece is the kernel map.

We can set it with adjacent module's address directly instead of calling
map_groups__fixup_end().  If there's no module after the kernel map, the
end address will be ~0ULL.

Since it also changes the start address of the kernel map, it needs to
re-insert the map to the kmaps in order to keep a correct ordering.  Kim
reported that it caused problems on ARM64.
Reported-by: default avatarKim Phillips <kim.phillips@arm.com>
Tested-by: default avatarKim Phillips <kim.phillips@arm.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20180419235915.GA19067@sejongSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c042f7e9
...@@ -1019,13 +1019,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type) ...@@ -1019,13 +1019,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type)
return ret; return ret;
} }
static void map_groups__fixup_end(struct map_groups *mg)
{
int i;
for (i = 0; i < MAP__NR_TYPES; ++i)
__map_groups__fixup_end(mg, i);
}
static char *get_kernel_version(const char *root_dir) static char *get_kernel_version(const char *root_dir)
{ {
char version[PATH_MAX]; char version[PATH_MAX];
...@@ -1233,6 +1226,7 @@ int machine__create_kernel_maps(struct machine *machine) ...@@ -1233,6 +1226,7 @@ int machine__create_kernel_maps(struct machine *machine)
{ {
struct dso *kernel = machine__get_kernel(machine); struct dso *kernel = machine__get_kernel(machine);
const char *name = NULL; const char *name = NULL;
struct map *map;
u64 addr = 0; u64 addr = 0;
int ret; int ret;
...@@ -1259,13 +1253,25 @@ int machine__create_kernel_maps(struct machine *machine) ...@@ -1259,13 +1253,25 @@ int machine__create_kernel_maps(struct machine *machine)
machine__destroy_kernel_maps(machine); machine__destroy_kernel_maps(machine);
return -1; return -1;
} }
machine__set_kernel_mmap(machine, addr, 0);
/* we have a real start address now, so re-order the kmaps */
map = machine__kernel_map(machine);
map__get(map);
map_groups__remove(&machine->kmaps, map);
/* assume it's the last in the kmaps */
machine__set_kernel_mmap(machine, addr, ~0ULL);
map_groups__insert(&machine->kmaps, map);
map__put(map);
} }
/* /* update end address of the kernel map using adjacent module address */
* Now that we have all the maps created, just set the ->end of them: map = map__next(machine__kernel_map(machine));
*/ if (map)
map_groups__fixup_end(&machine->kmaps); machine__set_kernel_mmap(machine, addr, map->start);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment