From: Namhyung Kim <namhyung@kernel.org>
To: Taeung Song <treeze.taeung@gmail.com>
Cc: perf group <linux-perf-users@vger.kernel.org>, kernel-team@lge.com
Subject: Re: [Question] about symbol__get_source_line() in util/annotate.c
Date: Thu, 23 Feb 2017 14:14:13 +0900 [thread overview]
Message-ID: <20170223051413.GA30710@sejong> (raw)
In-Reply-To: <13ff5742-c651-0211-c0e0-0961c2d1ab64@gmail.com>
Hi Taeung,
On Thu, Feb 23, 2017 at 12:31:08PM +0900, Taeung Song wrote:
> Hi Namhyung,
>
> I have two question about the code util/annotate.c:1653~1676
>
> https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/tree/tools/perf/util/annotate.c?h=perf/core#n1653
>
> 1653 for (i = 0; i < len; i++) {
> 1654 u64 offset;
> 1655 double percent_max = 0.0;
> 1656
> 1657 src_line->nr_pcnt = nr_pcnt;
> 1658
> 1659 for (k = 0; k < nr_pcnt; k++) {
> 1660 h = annotation__histogram(notes, evidx + k);
> 1661 src_line->samples[k].percent = 100.0 * h->addr[i] / h->sum;
> 1662
> 1663 if (src_line->samples[k].percent > percent_max)
> 1664 percent_max = src_line->samples[k].percent;
> 1665 }
> 1666
> 1667 if (percent_max <= 0.5)
> 1668 goto next;
> 1669
> 1670 offset = start + i;
> 1671 src_line->path = get_srcline(map->dso, offset, NULL, false);
> 1672 insert_source_line(&tmp_root, src_line);
> 1673
> 1674 next:
> 1675 src_line = (void *)src_line + sizeof_src_line;
> 1676 }
>
>
> 1) Why use 'offset = start + i;' ?
> For example,
> There are addresses matched with test.c:26 as below,
>
> 400816: push %rbp
> 400817: mov %rsp,%rbp
> 40081a: mov %edi,-0x24(%rbp)
> 40081d: mov %rsi,-0x30(%rbp)
>
> If using 'offset = start + i;' in the above for loop,
> needless addresses can be checked.
Right, that's not nice.
>
>
> i=0, 400816
> i=1, 400817
> i=2, 400818 (nonvalidated)
> i=3, 400819 (nonvalidated)
> i=4, 40081a
> i=5, 40081b (nonvalidated)
> i=6, 40081c (nonvalidated)
> i=7, 40081d
>
> So I think it is better to use dissemble_line array such as
> (in order to check only validated addresses.)
>
> list_for_each_entry(dl, ¬es->src->source, node)
>
> What about this ?
I agree with you. Maybe we can get rid of the source_line struct
entirely.
>
> 2) Why use the if statement as below ?
>
> if (percent_max <= 0.5)
> goto next;
>
> I think it is more correct to use 0.0 instead of 0.5
>
> What do you think about that ?
Well, I think that the summary line doesn't want to show too many
(small) lines. Using 0.0 instead seems meaningless though.
Thanks,
Namhyung
next prev parent reply other threads:[~2017-02-23 5:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-23 3:31 [Question] about symbol__get_source_line() in util/annotate.c Taeung Song
2017-02-23 5:14 ` Namhyung Kim [this message]
2017-02-23 5:26 ` Namhyung Kim
2017-02-23 7:02 ` Taeung Song
2017-02-23 6:29 ` Taeung Song
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=20170223051413.GA30710@sejong \
--to=namhyung@kernel.org \
--cc=kernel-team@lge.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=treeze.taeung@gmail.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;
as well as URLs for NNTP newsgroup(s).