[PATCH v5 24/50] perf maps: Fix up overlaps during fixup_end
From: Ian Rogers
Date: Mon Nov 27 2023 - 17:12:06 EST
Maps are sometimes made overlapping, in particular kernel maps. If the
end of a map overlaps the start of the next, shorten the overlapping
map. This should remove potential non-determinism in maps__find, ie
finding maps by address.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/maps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c
index 01c15d0b300a..fba95a00ecdf 100644
--- a/tools/perf/util/maps.c
+++ b/tools/perf/util/maps.c
@@ -700,7 +700,7 @@ void maps__fixup_end(struct maps *maps)
down_write(maps__lock(maps));
maps__for_each_entry(maps, curr) {
- if (prev != NULL && !map__end(prev->map))
+ if (prev && (!map__end(prev->map) || map__end(prev->map) > map__start(curr->map)))
map__set_end(prev->map, map__start(curr->map));
prev = curr;
--
2.43.0.rc1.413.gea7ed67945-goog