Skip to content

Commit da3a53a

Browse files
changbinduacmel
authored andcommitted
perf maps: Purge all maps from the 'names' tree
Add function __maps__purge_names() to purge all maps from the names tree. We need to cleanup the names tree in maps__exit(). Detected with gcc's ASan. Signed-off-by: Changbin Du <[email protected]> Reviewed-by: Jiri Olsa <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Eric Saint-Etienne <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Fixes: 1e62856 ("perf symbols: Fix slowness due to -ffunction-section") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b49265e commit da3a53a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tools/perf/util/map.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,25 @@ static void __maps__purge(struct maps *maps)
577577
}
578578
}
579579

580+
static void __maps__purge_names(struct maps *maps)
581+
{
582+
struct rb_root *root = &maps->names;
583+
struct rb_node *next = rb_first(root);
584+
585+
while (next) {
586+
struct map *pos = rb_entry(next, struct map, rb_node_name);
587+
588+
next = rb_next(&pos->rb_node_name);
589+
rb_erase_init(&pos->rb_node_name, root);
590+
map__put(pos);
591+
}
592+
}
593+
580594
static void maps__exit(struct maps *maps)
581595
{
582596
down_write(&maps->lock);
583597
__maps__purge(maps);
598+
__maps__purge_names(maps);
584599
up_write(&maps->lock);
585600
}
586601

0 commit comments

Comments
 (0)