diff options
| author | Namhyung Kim <[email protected]> | 2025-07-03 01:49:39 +0000 |
|---|---|---|
| committer | Namhyung Kim <[email protected]> | 2025-07-03 18:39:56 +0000 |
| commit | 117e5c33b1c44037af016d77ce6c0b086d55535f (patch) | |
| tree | aa73164d3abfd100c58a6477122aa609fb25df08 /tools/perf/builtin-sched.c | |
| parent | perf sched: Fix thread leaks in 'perf sched timehist' (diff) | |
| download | kernel-117e5c33b1c44037af016d77ce6c0b086d55535f.tar.gz kernel-117e5c33b1c44037af016d77ce6c0b086d55535f.zip | |
perf sched: Fix memory leaks for evsel->priv in timehist
It uses evsel->priv to save per-cpu timing information. It should be
freed when the evsel is released.
Add the priv destructor for evsel same as thread to handle that.
Fixes: 49394a2a24c78ce0 ("perf sched timehist: Introduce timehist command")
Reviewed-by: Ian Rogers <[email protected]>
Tested-by: Ian Rogers <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Diffstat (limited to 'tools/perf/builtin-sched.c')
| -rw-r--r-- | tools/perf/builtin-sched.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 83b5a85a91b7..a6eb0462dd5b 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -2020,6 +2020,16 @@ static u64 evsel__get_time(struct evsel *evsel, u32 cpu) return r->last_time[cpu]; } +static void timehist__evsel_priv_destructor(void *priv) +{ + struct evsel_runtime *r = priv; + + if (r) { + free(r->last_time); + free(r); + } +} + static int comm_width = 30; static char *timehist_get_commstr(struct thread *thread) @@ -3314,6 +3324,8 @@ static int perf_sched__timehist(struct perf_sched *sched) setup_pager(); + evsel__set_priv_destructor(timehist__evsel_priv_destructor); + /* prefer sched_waking if it is captured */ if (evlist__find_tracepoint_by_name(session->evlist, "sched:sched_waking")) handlers[1].handler = timehist_sched_wakeup_ignore; |
