Re: [PATCH 7/9] perf sched: Fix thread reference leak in idle hist processing

From: David Ahern

Date: Sat Jun 06 2026 - 11:48:01 EST


On 6/5/26 5:38 PM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
>
> timehist_sched_change_event() sets itr->last_thread to NULL at the end
> of idle hist processing without calling thread__put() first. The
> thread reference was acquired via thread__get() in timehist_get_thread()
> (line 2581), so every idle context switch leaks a thread reference when
> --idle-hist is active.
>
> Use thread__zput() to properly release the reference before clearing
> the pointer.
>
> Fixes: 5d8f17fb5822 ("perf sched timehist: Add -I/--idle-hist option")
> Reported-by: sashiko-bot <sashiko-bot@xxxxxxxxxx>
> Cc: David Ahern <dsahern@xxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Assisted-by: Claude Opus 4.6 <noreply@xxxxxxxxxxxxx>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> ---
> tools/perf/builtin-sched.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: David Ahern <dsahern@xxxxxxxxxx>