Re: [PATCH 2/8] perf sched: Free thread->priv using priv_destructor
From: Ian Rogers
Date: Wed Jul 02 2025 - 23:06:17 EST
On Wed, Jul 2, 2025 at 6:49 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> In many perf sched subcommand saves priv data structure in the thread
> but it forgot to free them. As it's an opaque type with 'void *', it
> needs to register that knows how to free the data. In this case, just
> regular 'free()' is fine.
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
Thanks,
Ian
> ---
> tools/perf/builtin-sched.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index b7bbfad0ed600eee..fa4052e040201105 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -3898,6 +3898,8 @@ int cmd_sched(int argc, const char **argv)
> if (!argc)
> usage_with_options(sched_usage, sched_options);
>
> + thread__set_priv_destructor(free);
> +
> /*
> * Aliased to 'perf script' for now:
> */
> --
> 2.50.0.727.gbf7dc18ff4-goog
>