Re: [PATCH 8/9] perf sched: Use thread__put() in free_idle_threads()

From: David Ahern

Date: Sat Jun 06 2026 - 11:49:25 EST


On 6/5/26 5:38 PM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
>
> free_idle_threads() calls thread__delete() directly instead of
> thread__put(), bypassing the reference counting lifecycle. Under
> REFCNT_CHECKING builds, this leaks the pointer handle since
> thread__delete() frees the object without going through the refcount
> wrapper.
>
> The idle threads are created via thread__new() (refcount=1) in
> get_idle_thread(). Callers get additional references via thread__get()
> which they release with thread__put(). free_idle_threads() drops the
> base reference — thread__put() is the correct call, matching the
> thread__new() acquisition.
>
> Fixes: 49394a2a24c7 ("perf sched timehist: Introduce timehist command")
> 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>