Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf report: Use map_symbol__copy() when copying callchains

It seems there are places to miss updating refcount of maps.
Let's use map_symbol__copy() helper to properly copy them with
refcounts updated.

Link: https://lore.kernel.org/r/20250307061250.320849-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+3 -7
+3 -7
tools/perf/util/callchain.c
··· 589 589 return -ENOMEM; 590 590 } 591 591 call->ip = cursor_node->ip; 592 - call->ms = cursor_node->ms; 593 - call->ms.map = map__get(call->ms.map); 594 - call->ms.maps = maps__get(call->ms.maps); 592 + map_symbol__copy(&call->ms, &cursor_node->ms); 595 593 call->srcline = cursor_node->srcline; 596 594 597 595 if (cursor_node->branch) { ··· 1092 1094 1093 1095 node->ip = ip; 1094 1096 map_symbol__exit(&node->ms); 1095 - node->ms = *ms; 1096 - node->ms.maps = maps__get(ms->maps); 1097 - node->ms.map = map__get(ms->map); 1097 + map_symbol__copy(&node->ms, ms); 1098 1098 node->branch = branch; 1099 1099 node->nr_loop_iter = nr_loop_iter; 1100 1100 node->iter_cycles = iter_cycles; ··· 1560 1564 goto out; 1561 1565 *new = *chain; 1562 1566 new->has_children = false; 1563 - new->ms.map = map__get(new->ms.map); 1567 + map_symbol__copy(&new->ms, &chain->ms); 1564 1568 list_add_tail(&new->list, &head); 1565 1569 } 1566 1570 parent = parent->parent;