[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240507141210.195939-2-james.clark@arm.com>
Date: Tue, 7 May 2024 15:12:05 +0100
From: James Clark <james.clark@....com>
To: linux-perf-users@...r.kernel.org,
atrajeev@...ux.vnet.ibm.com,
irogers@...gle.com
Cc: James Clark <james.clark@....com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/4] perf symbols: Remove map from list before updating addresses
Make the order of operations remove, update, add. Updating addresses
before the map is removed causes the ordering check to fail when the map
is removed. This can be reproduced when running Perf on an Arm system
with a static kernel and Perf uses kcore rather than other sources:
$ perf record -- ls
$ perf report
util/maps.c:96: check_invariants: Assertion `map__end(prev) <=
map__start(map) || map__start(prev) == map__start(map)' failed
Fixes: 659ad3492b91 ("perf maps: Switch from rbtree to lazily sorted array for addresses")
Signed-off-by: James Clark <james.clark@....com>
---
tools/perf/util/symbol.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 7772a4d3e66c..2d95f22d713d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1377,13 +1377,15 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
if (RC_CHK_EQUAL(new_map, replacement_map)) {
struct map *map_ref;
- map__set_start(map, map__start(new_map));
- map__set_end(map, map__end(new_map));
- map__set_pgoff(map, map__pgoff(new_map));
- map__set_mapping_type(map, map__mapping_type(new_map));
/* Ensure maps are correctly ordered */
map_ref = map__get(map);
maps__remove(kmaps, map_ref);
+
+ map__set_start(map_ref, map__start(new_map));
+ map__set_end(map_ref, map__end(new_map));
+ map__set_pgoff(map_ref, map__pgoff(new_map));
+ map__set_mapping_type(map_ref, map__mapping_type(new_map));
+
err = maps__insert(kmaps, map_ref);
map__put(map_ref);
map__put(new_map);
--
2.34.1
Powered by blists - more mailing lists