diff options
author | Namhyung Kim <namhyung@kernel.org> | 2018-02-19 05:05:45 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-04-23 09:52:55 -0400 |
commit | ee05d21791db6db954bbb7b79bb18d88b5f6b7ff (patch) | |
tree | df80db128b4870e48d21ab4e99100f448f88e8d8 /tools | |
parent | c042f7e9bb6ad9429ea0f2c9138dc06413198967 (diff) |
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: Kim Phillips <kim.phillips@arm.com>
Tested-by: Kim Phillips <kim.phillips@arm.com>
Signed-off-by: Namhyung 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@sejong
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/machine.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 2eca8478e24f..32d50492505d 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -1019,13 +1019,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type) | |||
1019 | return ret; | 1019 | return ret; |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | static void map_groups__fixup_end(struct map_groups *mg) | ||
1023 | { | ||
1024 | int i; | ||
1025 | for (i = 0; i < MAP__NR_TYPES; ++i) | ||
1026 | __map_groups__fixup_end(mg, i); | ||
1027 | } | ||
1028 | |||
1029 | static char *get_kernel_version(const char *root_dir) | 1022 | static char *get_kernel_version(const char *root_dir) |
1030 | { | 1023 | { |
1031 | char version[PATH_MAX]; | 1024 | char version[PATH_MAX]; |
@@ -1233,6 +1226,7 @@ int machine__create_kernel_maps(struct machine *machine) | |||
1233 | { | 1226 | { |
1234 | struct dso *kernel = machine__get_kernel(machine); | 1227 | struct dso *kernel = machine__get_kernel(machine); |
1235 | const char *name = NULL; | 1228 | const char *name = NULL; |
1229 | struct map *map; | ||
1236 | u64 addr = 0; | 1230 | u64 addr = 0; |
1237 | int ret; | 1231 | int ret; |
1238 | 1232 | ||
@@ -1259,13 +1253,25 @@ int machine__create_kernel_maps(struct machine *machine) | |||
1259 | machine__destroy_kernel_maps(machine); | 1253 | machine__destroy_kernel_maps(machine); |
1260 | return -1; | 1254 | return -1; |
1261 | } | 1255 | } |
1262 | machine__set_kernel_mmap(machine, addr, 0); | 1256 | |
1257 | /* we have a real start address now, so re-order the kmaps */ | ||
1258 | map = machine__kernel_map(machine); | ||
1259 | |||
1260 | map__get(map); | ||
1261 | map_groups__remove(&machine->kmaps, map); | ||
1262 | |||
1263 | /* assume it's the last in the kmaps */ | ||
1264 | machine__set_kernel_mmap(machine, addr, ~0ULL); | ||
1265 | |||
1266 | map_groups__insert(&machine->kmaps, map); | ||
1267 | map__put(map); | ||
1263 | } | 1268 | } |
1264 | 1269 | ||
1265 | /* | 1270 | /* update end address of the kernel map using adjacent module address */ |
1266 | * Now that we have all the maps created, just set the ->end of them: | 1271 | map = map__next(machine__kernel_map(machine)); |
1267 | */ | 1272 | if (map) |
1268 | map_groups__fixup_end(&machine->kmaps); | 1273 | machine__set_kernel_mmap(machine, addr, map->start); |
1274 | |||
1269 | return 0; | 1275 | return 0; |
1270 | } | 1276 | } |
1271 | 1277 | ||