mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
perf maps: Introduce map__set_kmap_maps() for kernel maps
We need to set it in other places than __maps__insert(), so that we can
have access to the 'struct maps' from a kernel 'struct map'.
When building perf with 'DEBUG=1' we can notice it failing a consistency
check done in the check_invariants() function:
root@number:~# perf record -- perf test -w offcpu
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.040 MB perf.data (23 samples) ]
perf: util/maps.c:95: check_invariants: Assertion `map__end(prev) <= map__end(map)' failed.
Aborted (core dumped)
root@number:~#
The investigation on that was happening bisected to 876e80cf83
("perf tools: Fixup end address of modules"), and the following patches
will plug the problems found, this patch is just legwork on that
direction.
Use the map__set_kmap_maps() name as per a review comment from Ian
Rogers, later there are further suggestions from him on getting rid of
the kmaps variable, see the thread referenced in the Link below.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/lkml/Z74V0hZXrTLM6VIJ@x1
Link: https://lore.kernel.org/r/20250228211734.33781-2-acme@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
74fb903b21
commit
99deaf5578
|
|
@ -428,11 +428,29 @@ static unsigned int maps__by_name_index(const struct maps *maps, const struct ma
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void map__set_kmap_maps(struct map *map, struct maps *maps)
|
||||
{
|
||||
struct dso *dso;
|
||||
|
||||
if (map == NULL)
|
||||
return;
|
||||
|
||||
dso = map__dso(map);
|
||||
|
||||
if (dso && dso__kernel(dso)) {
|
||||
struct kmap *kmap = map__kmap(map);
|
||||
|
||||
if (kmap)
|
||||
kmap->kmaps = maps;
|
||||
else
|
||||
pr_err("Internal error: kernel dso with non kernel map\n");
|
||||
}
|
||||
}
|
||||
|
||||
static int __maps__insert(struct maps *maps, struct map *new)
|
||||
{
|
||||
struct map **maps_by_address = maps__maps_by_address(maps);
|
||||
struct map **maps_by_name = maps__maps_by_name(maps);
|
||||
const struct dso *dso = map__dso(new);
|
||||
unsigned int nr_maps = maps__nr_maps(maps);
|
||||
unsigned int nr_allocate = RC_CHK_ACCESS(maps)->nr_maps_allocated;
|
||||
|
||||
|
|
@ -483,14 +501,9 @@ static int __maps__insert(struct maps *maps, struct map *new)
|
|||
}
|
||||
if (map__end(new) < map__start(new))
|
||||
RC_CHK_ACCESS(maps)->ends_broken = true;
|
||||
if (dso && dso__kernel(dso)) {
|
||||
struct kmap *kmap = map__kmap(new);
|
||||
|
||||
if (kmap)
|
||||
kmap->kmaps = maps;
|
||||
else
|
||||
pr_err("Internal error: kernel dso with non kernel map\n");
|
||||
}
|
||||
map__set_kmap_maps(new, maps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user