Re: [PATCH 2/4] perf tools: Move zstd_fini() to session deletion

From: Jiri Olsa
Date: Mon Apr 20 2020 - 04:55:14 EST


On Fri, Apr 17, 2020 at 04:23:27PM +0300, Tommi Rantala wrote:
> Move zstd_fini() call to perf_session__delete(), so that we always
> cleanup the zstd state when deleting the session.

it shold be orthogonal with zstd_init calls, which
are not currently called within perf_session

I guess zstd_initcould moved to perf_session__new,
just need some nice way to pass rec->opts.comp_level

jirka

>
> Signed-off-by: Tommi Rantala <tommi.t.rantala@xxxxxxxxx>
> ---
> tools/perf/builtin-inject.c | 1 -
> tools/perf/builtin-record.c | 1 -
> tools/perf/builtin-report.c | 1 -
> tools/perf/util/session.c | 1 +
> 4 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
> index 7e124a7b8bfd..1ffb8393357a 100644
> --- a/tools/perf/builtin-inject.c
> +++ b/tools/perf/builtin-inject.c
> @@ -836,7 +836,6 @@ int cmd_inject(int argc, const char **argv)
> ret = __cmd_inject(&inject);
>
> out_delete:
> - zstd_fini(&(inject.session->zstd_data));
> perf_session__delete(inject.session);
> return ret;
> }
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 1ab349abe904..8ed00de1ca29 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1827,7 +1827,6 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
> }
>
> out_delete_session:
> - zstd_fini(&session->zstd_data);
> perf_session__delete(session);
>
> if (!opts->no_bpf_event)
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 26d8fc27e427..e06e14980264 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -1579,7 +1579,6 @@ int cmd_report(int argc, const char **argv)
> report.block_reports = NULL;
> }
>
> - zstd_fini(&(session->zstd_data));
> perf_session__delete(session);
> return ret;
> }
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 0b0bfe5bef17..64e8b794b0bc 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -302,6 +302,7 @@ void perf_session__delete(struct perf_session *session)
> machines__exit(&session->machines);
> if (session->data)
> perf_data__close(session->data);
> + zstd_fini(&session->zstd_data);
> free(session);
> }
>
> --
> 2.25.2
>