Skip to content

Commit

Permalink
Revert "perf callchain: Fix stitch LBR memory leaks"
Browse files Browse the repository at this point in the history
This reverts commit 42cd165b4cf89fb42b794d3a9ee792a7696c49b3 which is
commit 599c19397b17d197fc1184bbc950f163a292efc9 upstream.

It causes build breaks in the 6.6.y tree and should not have been
applied, so revert it.

Link: https://lore.kernel.org/r/[email protected]
Link: https://lore.kernel.org/r/[email protected]
Reported-by: Harshit Mogalapalli <[email protected]>
Reported-by: Florian Fainelli <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Anne Macedo <[email protected]>
Cc: Changbin Du <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh authored and Avenger-285714 committed Oct 11, 2024
1 parent 803c7c3 commit b10fb29
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
17 changes: 2 additions & 15 deletions tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -2536,12 +2536,8 @@ static void save_lbr_cursor_node(struct thread *thread,
cursor->curr = cursor->first;
else
cursor->curr = cursor->curr->next;

map_symbol__exit(&lbr_stitch->prev_lbr_cursor[idx].ms);
memcpy(&lbr_stitch->prev_lbr_cursor[idx], cursor->curr,
sizeof(struct callchain_cursor_node));
lbr_stitch->prev_lbr_cursor[idx].ms.maps = maps__get(cursor->curr->ms.maps);
lbr_stitch->prev_lbr_cursor[idx].ms.map = map__get(cursor->curr->ms.map);

lbr_stitch->prev_lbr_cursor[idx].valid = true;
cursor->pos++;
Expand Down Expand Up @@ -2752,9 +2748,6 @@ static bool has_stitched_lbr(struct thread *thread,
memcpy(&stitch_node->cursor, &lbr_stitch->prev_lbr_cursor[i],
sizeof(struct callchain_cursor_node));

stitch_node->cursor.ms.maps = maps__get(lbr_stitch->prev_lbr_cursor[i].ms.maps);
stitch_node->cursor.ms.map = map__get(lbr_stitch->prev_lbr_cursor[i].ms.map);

if (callee)
list_add(&stitch_node->node, &lbr_stitch->lists);
else
Expand All @@ -2778,8 +2771,6 @@ static bool alloc_lbr_stitch(struct thread *thread, unsigned int max_lbr)
if (!thread__lbr_stitch(thread)->prev_lbr_cursor)
goto free_lbr_stitch;

thread__lbr_stitch(thread)->prev_lbr_cursor_size = max_lbr + 1;

INIT_LIST_HEAD(&thread__lbr_stitch(thread)->lists);
INIT_LIST_HEAD(&thread__lbr_stitch(thread)->free_lists);

Expand Down Expand Up @@ -2835,12 +2826,8 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
max_lbr, callee);

if (!stitched_lbr && !list_empty(&lbr_stitch->lists)) {
struct stitch_list *stitch_node;

list_for_each_entry(stitch_node, &lbr_stitch->lists, node)
map_symbol__exit(&stitch_node->cursor.ms);

list_splice_init(&lbr_stitch->lists, &lbr_stitch->free_lists);
list_replace_init(&lbr_stitch->lists,
&lbr_stitch->free_lists);
}
memcpy(&lbr_stitch->prev_sample, sample, sizeof(*sample));
}
Expand Down
4 changes: 0 additions & 4 deletions tools/perf/util/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ void thread__free_stitch_list(struct thread *thread)
return;

list_for_each_entry_safe(pos, tmp, &lbr_stitch->lists, node) {
map_symbol__exit(&pos->cursor.ms);
list_del_init(&pos->node);
free(pos);
}
Expand All @@ -488,9 +487,6 @@ void thread__free_stitch_list(struct thread *thread)
free(pos);
}

for (unsigned int i = 0 ; i < lbr_stitch->prev_lbr_cursor_size; i++)
map_symbol__exit(&lbr_stitch->prev_lbr_cursor[i].ms);

zfree(&lbr_stitch->prev_lbr_cursor);
free(thread__lbr_stitch(thread));
thread__set_lbr_stitch(thread, NULL);
Expand Down
1 change: 0 additions & 1 deletion tools/perf/util/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct lbr_stitch {
struct list_head free_lists;
struct perf_sample prev_sample;
struct callchain_cursor_node *prev_lbr_cursor;
unsigned int prev_lbr_cursor_size;
};

struct thread_rb_node {
Expand Down

0 comments on commit b10fb29

Please sign in to comment.