Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf maps: Move kmap::kmaps setup to maps__insert()

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
484214f4 7ce66139

+11 -12
+1 -12
tools/perf/util/machine.c
··· 981 981 982 982 kmap = map__kmap(map); 983 983 984 - kmap->kmaps = &machine->kmaps; 985 984 strlcpy(kmap->name, xm->name, KMAP_NAME_LEN); 986 985 987 986 maps__insert(&machine->kmaps, map); ··· 1090 1091 static int 1091 1092 __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) 1092 1093 { 1093 - struct kmap *kmap; 1094 - struct map *map; 1095 - 1096 1094 /* In case of renewal the kernel map, destroy previous one */ 1097 1095 machine__destroy_kernel_maps(machine); 1098 1096 ··· 1098 1102 return -1; 1099 1103 1100 1104 machine->vmlinux_map->map_ip = machine->vmlinux_map->unmap_ip = identity__map_ip; 1101 - map = machine__kernel_map(machine); 1102 - kmap = map__kmap(map); 1103 - if (!kmap) 1104 - return -1; 1105 - 1106 - kmap->kmaps = &machine->kmaps; 1107 - maps__insert(&machine->kmaps, map); 1108 - 1105 + maps__insert(&machine->kmaps, machine->vmlinux_map); 1109 1106 return 0; 1110 1107 } 1111 1108
+10
tools/perf/util/map.c
··· 543 543 __maps__insert(maps, map); 544 544 ++maps->nr_maps; 545 545 546 + if (map->dso && map->dso->kernel) { 547 + struct kmap *kmap = map__kmap(map); 548 + 549 + if (kmap) 550 + kmap->kmaps = maps; 551 + else 552 + pr_err("Internal error: kernel dso with non kernel map\n"); 553 + } 554 + 555 + 546 556 /* 547 557 * If we already performed some search by name, then we need to add the just 548 558 * inserted map and resort.