]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf sched: Free callchain nodes in idle thread cleanup
authorArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 6 Jun 2026 14:33:41 +0000 (11:33 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 6 Jun 2026 17:42:19 +0000 (14:42 -0300)
commitc3e51ed45ffa7547495a851e33ce332f81ef3665
treefc52cdc6976137c900c502ac4f5dd6bcb8267afe
parent33fa2bf5608fc36bc25231592145f4738f14f11b
perf sched: Free callchain nodes in idle thread cleanup

free_idle_threads() relies on the thread priv destructor (free()) to
clean up idle_thread_runtime structs.  But free() doesn't walk the
callchain_cursor linked list or the callchain_root tree allocated
by callchain_cursor__copy() and callchain_append() during --idle-hist
processing.  Every idle thread with callchain data leaks these nodes.

Introduce callchain_cursor_cleanup() to free the cursor's linked list
of callchain_cursor_node entries, and call it together with
free_callchain() in free_idle_threads() before thread__put().

Fixes: 225b24f569980ac9 ("perf sched timehist: Save callchain when entering idle")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-sched.c
tools/perf/util/callchain.c
tools/perf/util/callchain.h