Skip to content

Commit e97cc01

Browse files
captain5050gregkh
authored andcommitted
perf maps: Fix copy_from that can break sorted by name order
[ Upstream commit f552b13 ] When an parent is copied into a child the name array is populated in address not name order. Make sure the name array isn't flagged as sorted. Fixes: 659ad34 ("perf maps: Switch from rbtree to lazily sorted array for addresses") Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent def6cd4 commit e97cc01

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

tools/perf/util/maps.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,16 +1032,9 @@ int maps__copy_from(struct maps *dest, struct maps *parent)
10321032
map__put(new);
10331033
}
10341034
maps__set_maps_by_address_sorted(dest, maps__maps_by_address_sorted(parent));
1035-
if (!err) {
1036-
RC_CHK_ACCESS(dest)->last_search_by_name_idx =
1037-
RC_CHK_ACCESS(parent)->last_search_by_name_idx;
1038-
maps__set_maps_by_name_sorted(dest,
1039-
dest_maps_by_name &&
1040-
maps__maps_by_name_sorted(parent));
1041-
} else {
1042-
RC_CHK_ACCESS(dest)->last_search_by_name_idx = 0;
1043-
maps__set_maps_by_name_sorted(dest, false);
1044-
}
1035+
RC_CHK_ACCESS(dest)->last_search_by_name_idx = 0;
1036+
/* Values were copied into the name array in address order. */
1037+
maps__set_maps_by_name_sorted(dest, false);
10451038
} else {
10461039
/* Unexpected copying to a maps containing entries. */
10471040
for (unsigned int i = 0; !err && i < n; i++) {

0 commit comments

Comments
 (0)