public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: He Kuang <hekuang@huawei.com>,
	a.p.zijlstra@chello.nl, acme@kernel.org, jolsa@kernel.org,
	mingo@redhat.com
Cc: wangnan0@huawei.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] perf probe: Add --range option to show variable location range
Date: Sun, 10 May 2015 12:02:30 +0900	[thread overview]
Message-ID: <554ECA46.3010102@hitachi.com> (raw)
In-Reply-To: <554DBA1D.6040702@huawei.com>

On 2015/05/09 16:41, He Kuang wrote:
> 
> On 2015/5/8 22:08, Masami Hiramatsu wrote:
>> On 2015/05/08 21:23, He Kuang wrote:
>>> It is not easy for users to get the accurate byte offset or the line
>>> number where a local variable can be probed. With '--range' option,
>>> local variables in scope of the probe point are showed with byte offset
>>> range, and can be added according to this range information.
>> Interesting idea :)
>>
>>> For example, there are some variables in function
>>> generic_perform_write():
>>>
>>>    <generic_perform_write@mm/filemap.c:0>
>>>    0  ssize_t generic_perform_write(struct file *file,
>>>    1                                 struct iov_iter *i, loff_t pos)
>>>    2  {
>>>    3          struct address_space *mapping = file->f_mapping;
>>>    4          const struct address_space_operations *a_ops = mapping->a_ops;
>>>    ...
>>>    42                 status = a_ops->write_begin(file, mapping, pos, bytes, flags,
>>>                                                 &page, &fsdata);
>>>    44                 if (unlikely(status < 0))
>>>
>>> But we got failed when we try to probe the variable 'a_ops' at line 42
>>> or 44.
>>>
>>>    $ perf probe --add 'generic_perform_write:42 a_ops'
>>>    Failed to find the location of a_ops at this address.
>>>      Perhaps, it has been optimized out.
>> Yeah, right. That's why I've introduced --vars option.
>>
>>> This is because source code do not match assembly, so a variable may not
>>> be available in the sourcecode line where it presents. After this patch,
>>> we can lookup the accurate byte offset range of a variable, 'INV'
>>> indicates that this variable is not valid at the given point, but
>>> available in scope:
>>>
>>>    $ perf probe --vars 'generic_perform_write:42' --range
>>>    Available variables at generic_perform_write:42
>>>          @<generic_perform_write+141>
>>>                  [INV]   ssize_t written [byte offset]: <324-331>
>>>                  [INV]   struct address_space_operations*        a_ops   [byte offset]: <55-61>,<170-176>,<223-246>
>>>                  [VAL]   (unknown_type)  fsdata  [byte offset]: <70-307>,<346-411>
>>>                  [VAL]   loff_t  pos     [byte offset]: <0-286>,<286-336>,<346-411>
>>>                  [VAL]   long int        status  [byte offset]: <83-342>,<346-411>
>>>                  [VAL]   long unsigned int       bytes   [byte offset]: <122-311>,<320-338>,<346-403>,<403-411>
>>>                  [VAL]   struct address_space*   mapping [byte offset]: <35-344>,<346-411>
>>>                  [VAL]   struct iov_iter*        i       [byte offset]: <0-340>,<346-411>
>>>                  [VAL]   struct page*    page    [byte offset]: <70-307>,<346-411>
>> OK, at first, I don't like frequently repeated "[byte offset]", I prefer to
>> show the function name+[offset range], like below :)
>>
>>   [INV]   ssize_t written @<generic_perform_write+[324-331]>
>>   [INV]   struct address_space_operations*        a_ops   <@generic_perform_write+[55-61,170-176,223-246]>
> 
> OK.
> 
>>
>> By the way, 'generic_perform_write+170' may be different from
>> given line, is that OK?
> 
> I think the prefix '[INV]' indicates that difference.
> 
> Before this patch, we should reference objdump, dwarf-info, then
> dwarf-loc to find the valid range of a variable. Sometimes we
> want to view more than one variables by adding one probe event,
> to find a place two or more variables all valid is difficult.

Yes, I think this looks good idea to trace variables :)

> 
> This patch gives an overview of the valid ranges of variables in
> scope, in most case, if we just want to find a place to probe
> variables, the location range result is just enough.  And we can
> use the result offset to locate the assembly code of the accurate
> meaning of a variable from objdump easily.

OK, but please note that the optimizer sometimes arranges code
sequence different from the source code. So I recommend to ensure
the address is actually where you imagine, by using perf probe -l :)

Thank you,


-- 
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: masami.hiramatsu.pt@hitachi.com

  reply	other threads:[~2015-05-10  3:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 12:23 [PATCH 1/3] perf probe: Remove length limitation for showing available variables He Kuang
2015-05-08 12:23 ` [PATCH 2/3] perf probe: Add flag for options when showing variables He Kuang
2015-05-08 13:15   ` Masami Hiramatsu
2015-05-09  6:30     ` He Kuang
2015-05-08 12:23 ` [PATCH 3/3] perf probe: Add --range option to show variable location range He Kuang
2015-05-08 14:08   ` Masami Hiramatsu
2015-05-09  7:41     ` He Kuang
2015-05-10  3:02       ` Masami Hiramatsu [this message]
2015-05-08 14:17 ` [PATCH 1/3] perf probe: Remove length limitation for showing available variables Masami Hiramatsu
2015-05-09  7:16   ` He Kuang

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=554ECA46.3010102@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=wangnan0@huawei.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