[PATCH 2/6] perf maps: Set the kmaps for newly created/added kernel maps
From: Arnaldo Carvalho de Melo
Date: Thu Feb 27 2025 - 16:55:47 EST
From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
When using __maps__insert_sorted() the map kmaps field needs to be
initialized, as we need kernel maps to work with map__kmap().
Fix it by using the newly introduced map__set_kmap() method.
Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Ian Rogers <irogers@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: James Clark <james.clark@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Link: https://lore.kernel.org/lkml/Z74V0hZXrTLM6VIJ@x1
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/maps.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c
index e21d29f5df01c6f7..dec2e04696c9097e 100644
--- a/tools/perf/util/maps.c
+++ b/tools/perf/util/maps.c
@@ -798,6 +798,9 @@ static int __maps__insert_sorted(struct maps *maps, unsigned int first_after_ind
}
RC_CHK_ACCESS(maps)->nr_maps = nr_maps + to_add;
maps__set_maps_by_name_sorted(maps, false);
+ map__set_kmap(new1, maps);
+ map__set_kmap(new2, maps);
+
check_invariants(maps);
return 0;
}
--
2.47.0