From: Jiri Olsa <jolsa@redhat.com>
To: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: acme@kernel.org, namhyung@kernel.org, irogers@google.com,
songliubraving@fb.com, yao.jin@linux.intel.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] perf annotate: Simplify disasm_line allocation and freeing code
Date: Mon, 27 Jan 2020 12:59:11 +0100 [thread overview]
Message-ID: <20200127115911.GB1114818@krava> (raw)
In-Reply-To: <20200124080432.8065-3-ravi.bangoria@linux.ibm.com>
On Fri, Jan 24, 2020 at 01:34:28PM +0530, Ravi Bangoria wrote:
SNIP
>
> /*
> * Allocating the disasm annotation line data with
> * following structure:
> *
> - * ------------------------------------------------------------
> - * privsize space | struct disasm_line | struct annotation_line
> - * ------------------------------------------------------------
> + * -------------------------------------------
> + * struct disasm_line | struct annotation_line
> + * -------------------------------------------
> *
> * We have 'struct annotation_line' member as last member
> * of 'struct disasm_line' to have an easy access.
> - *
> */
> static struct disasm_line *disasm_line__new(struct annotate_args *args)
> {
> struct disasm_line *dl = NULL;
> - struct annotation_line *al;
> - size_t privsize = args->privsize + offsetof(struct disasm_line, al);
> + int nr = 1;
>
> - al = annotation_line__new(args, privsize);
ok, I finally recalled why we did it like this.. for the python
annotation support, which never made it in ;-) however the allocation
in 'specialized' line and later call to annotation_line__init might
actualy be a better way
> - if (al != NULL) {
> - dl = disasm_line(al);
> + if (perf_evsel__is_group_event(args->evsel))
> + nr = args->evsel->core.nr_members;
>
> - if (dl->al.line == NULL)
> - goto out_delete;
> + dl = zalloc(disasm_line_size(nr));
> + if (!dl)
> + return NULL;
>
> - if (args->offset != -1) {
> - if (disasm_line__parse(dl->al.line, &dl->ins.name, &dl->ops.raw) < 0)
> - goto out_free_line;
> + annotation_line__init(&dl->al, args, nr);
> + if (dl->al.line == NULL)
> + goto out_delete;
>
> - disasm_line__init_ins(dl, args->arch, &args->ms);
> - }
> + if (args->offset != -1) {
> + if (disasm_line__parse(dl->al.line, &dl->ins.name, &dl->ops.raw) < 0)
> + goto out_free_line;
> +
> + disasm_line__init_ins(dl, args->arch, &args->ms);
> }
>
> return dl;
> @@ -1248,7 +1219,9 @@ void disasm_line__free(struct disasm_line *dl)
> else
> ins__delete(&dl->ops);
> zfree(&dl->ins.name);
> - annotation_line__delete(&dl->al);
> + free_srcline(dl->al.path);
> + zfree(&dl->al.line);
no need to zfree if you're freeing the memory on the next line
also could you please put it to annotation_line__exit, since
you already added the __init function
> + free(dl);
> }
>
the rest of the patches look good to me
thanks,
jirka
next prev parent reply other threads:[~2020-01-27 11:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-24 8:04 [PATCH v2 0/6] perf annotate: Misc fixes / improvements Ravi Bangoria
2020-01-24 8:04 ` [PATCH v2 1/6] perf annotate: Remove privsize from symbol__annotate() args Ravi Bangoria
2020-01-30 11:16 ` Arnaldo Carvalho de Melo
2020-02-03 4:54 ` Ravi Bangoria
2020-02-03 13:30 ` Jiri Olsa
2020-02-04 2:37 ` Ravi Bangoria
2020-01-24 8:04 ` [PATCH v2 2/6] perf annotate: Simplify disasm_line allocation and freeing code Ravi Bangoria
2020-01-27 11:59 ` Jiri Olsa [this message]
2020-01-28 13:57 ` Ravi Bangoria
2020-01-24 8:04 ` [PATCH v2 3/6] perf annotate: Align struct annotate_args Ravi Bangoria
2020-01-24 8:04 ` [PATCH v2 4/6] perf annotate: Fix segfault with source toggle Ravi Bangoria
2020-01-24 8:04 ` [PATCH v2 5/6] perf annotate: Make few functions static Ravi Bangoria
2020-01-24 8:04 ` [PATCH v2 6/6] perf annotate: Get rid of annotation->nr_jumps Ravi Bangoria
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200127115911.GB1114818@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=ravi.bangoria@linux.ibm.com \
--cc=songliubraving@fb.com \
--cc=yao.jin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®