lkml.org 
[lkml]   [2015]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf session: Fill in the missing freeing a session after an error occur
Em Sat, Jun 27, 2015 at 11:08:52PM +0900, taeung escreveu:
> In some cases some sessions aren't freed.
> For example, a session is allocated and then
> if an error occur, just a error value is returned
> without freeing the session. So allocating and freeing
> session have to be matched as a pair even if an error occur.
>
> Signed-off-by: taeung <treeze.taeung@gmail.com>
> ---
> tools/perf/builtin-inject.c | 7 ++++---
> tools/perf/builtin-kmem.c | 4 ++--
> tools/perf/builtin-kvm.c | 16 ++++++++++++----
> tools/perf/builtin-mem.c | 17 ++++++++++-------
> tools/perf/builtin-report.c | 6 ++++--
> 5 files changed, 32 insertions(+), 18 deletions(-)

<SNIP>

> +++ b/tools/perf/builtin-mem.c
> @@ -135,24 +135,27 @@ static int report_raw_events(struct perf_mem *mem)
> if (mem->cpu_list) {
> ret = perf_session__cpu_bitmap(session, mem->cpu_list,
> mem->cpu_bitmap);
> - if (ret)
> + if (ret) {
> + ret = err;
> goto out_delete;

How come?

Can you break this into per-tool patches? If that would be the case I
would have applied some now.

- Arnaldo

> + }
> }
>
> - if (symbol__init(&session->header.env) < 0)
> - return -1;
> + ret = symbol__init(&session->header.env);
> + if (ret < 0)
> + goto out_delete;
>
> printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
>
> err = perf_session__process_events(session);
> if (err)
> - return err;
> -
> - return 0;
> + ret = err;
> + else
> + ret = 0;
>
> out_delete:
> perf_session__delete(session);
> - return err;
> + return ret;
> }
>
> static int report_events(int argc, const char **argv, struct perf_mem *mem)
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 32626ea..610d056 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -828,8 +828,10 @@ repeat:
> if (report.header || report.header_only) {
> perf_session__fprintf_info(session, stdout,
> report.show_full_info);
> - if (report.header_only)
> - return 0;
> + if (report.header_only) {
> + ret = 0;
> + goto error;
> + }
> } else if (use_browser == 0) {
> fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
> stdout);
> --
> 1.9.1


\
 
 \ /
  Last update: 2015-06-29 15:21    [W:0.051 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site