]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf maps: Fix fixup_overlap_and_insert that can break sorted by name order
authorIan Rogers <irogers@google.com>
Wed, 8 Apr 2026 02:08:37 +0000 (19:08 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 8 Apr 2026 17:28:49 +0000 (10:28 -0700)
When an entry in the address array is replaced, the corresponding name
entry is replaced. The entries names may sort differently and so it is
important that the sorted by name property be cleared on the maps.

Fixes: 0d11fab32714 ("perf maps: Fixup maps_by_name when modifying maps_by_address")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/maps.c

index 7dd6da9d1e4f030e8e38f4ed1878059e460a5571..b44bc41f51f3bae29b5cf138c9e47e0030da48a3 100644 (file)
@@ -955,6 +955,7 @@ static int __maps__fixup_overlap_and_insert(struct maps *maps, struct map *new)
                        if (maps_by_name) {
                                map__put(maps_by_name[ni]);
                                maps_by_name[ni] = map__get(new);
+                               maps__set_maps_by_name_sorted(maps, false);
                        }
 
                        err = __maps__insert_sorted(maps, i + 1, after, NULL);
@@ -981,6 +982,7 @@ static int __maps__fixup_overlap_and_insert(struct maps *maps, struct map *new)
                                if (maps_by_name) {
                                        map__put(maps_by_name[ni]);
                                        maps_by_name[ni] = map__get(new);
+                                       maps__set_maps_by_name_sorted(maps, false);
                                }
 
                                check_invariants(maps);