From 51b02a964728115761acc5baa5e67c8d0a9bc222 Mon Sep 17 00:00:00 2001 From: Leo Yan Date: Mon, 20 Mar 2023 14:16:19 +0800 Subject: perf kvm: Delete histograms entries before exiting It's good not to release resources for a program when kernel cleans up memory space, this patch explicitly releases histograms entries with hists__delete_entries(). Committer notice: This helps with memory leak checkers, but may delay exiting a tool by doing needless linked list traversals freeing lots of objects. Signed-off-by: Leo Yan Acked-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20230320061619.29520-2-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-kvm.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools/perf/builtin-kvm.c') diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 1e1cb5a9d0a2..fb9dc0dc46f9 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1528,6 +1528,8 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) } out: + hists__delete_entries(&kvm_hists.hists); + if (kvm->timerfd >= 0) close(kvm->timerfd); @@ -1690,6 +1692,7 @@ static int kvm_events_report_vcpu(struct perf_kvm_stat *kvm) kvm_display(kvm); exit: + hists__delete_entries(&kvm_hists.hists); return ret; } -- cgit v1.2.3-58-ga151