perf maps: Set the kmaps for newly created/added kernel maps
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 28 Feb 2025 21:17:30 +0000 (18:17 -0300)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 6 Mar 2025 07:03:11 +0000 (23:03 -0800)
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.

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-3-acme@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/maps.c

index 51b507233269d8b414b9dbeec5c72608c3f9f8fe..8c5f5d79cd24a6bce0ddb8a923c62e68d77feb09 100644 (file)
@@ -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_maps(new1, maps);
+       map__set_kmap_maps(new2, maps);
+
        check_invariants(maps);
        return 0;
 }