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 v2 2/3] perf probe: Add --range option to show variable location range
Date: Mon, 11 May 2015 15:03:46 +0900	[thread overview]
Message-ID: <55504642.1020301@hitachi.com> (raw)
In-Reply-To: <5550127D.7020506@huawei.com>

On 2015/05/11 11:22, He Kuang wrote:
> Hi, Masami
> 
> On 2015/5/10 11:21, Masami Hiramatsu wrote:
>> On 2015/05/09 18:55, 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.
>>>
>>> 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.
>>>
>>> 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 @<generic_perform_write+[324-331]>
>>>                  [INV]   struct address_space_operations*        a_ops   @<generic_perform_write+[55-61,170-176,223-246]>
>>>                  [VAL]   (unknown_type)  fsdata  @<generic_perform_write+[70-307,346-411]>
>>>                  [VAL]   loff_t  pos     @<generic_perform_write+[0-286,286-336,346-411]>
>>>                  [VAL]   long int        status  @<generic_perform_write+[83-342,346-411]>
>>>                  [VAL]   long unsigned int       bytes   @<generic_perform_write+[122-311,320-338,346-403,403-411]>
>>>                  [VAL]   struct address_space*   mapping @<generic_perform_write+[35-344,346-411]>
>>>                  [VAL]   struct iov_iter*        i       @<generic_perform_write+[0-340,346-411]>
>>>                  [VAL]   struct page*    page    @<generic_perform_write+[70-307,346-411]>
>>>
>> Thanks, this looks easier to understand :)
>>
>> [...]
>>> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
>>> index dcca551..30a1a1b 100644
>>> --- a/tools/perf/util/probe-finder.c
>>> +++ b/tools/perf/util/probe-finder.c
>>> @@ -43,6 +43,9 @@
>>>   /* Kprobe tracer basic type is up to u64 */
>>>   #define MAX_BASIC_TYPE_BITS	64
>>>   
>>> +/* Variable location invalid at addr but valid in scope */
>>> +#define VARIABLE_LOCATION_INVALID_AT_ADDR	-10000
>> Hmm, could you use -ERANGE instead of this?
>> Other part is OK for me.
>>
>> Thank you!
> 
> I've checked libdw, it never returns -ERANGE, but there is an
> errno conflict in the function convert_variable_location itself:
> 
>    268        regs = get_arch_regstr(regn);
>    269        if (!regs) {
>    270                /* This should be a bug in DWARF or this tool */
>    271                pr_warning("Mapping for the register number %u "
>    272                           "missing on this architecture.\n", regn);
>    273                return -ERANGE;
>    274 }
> 
> So shell we change the above errno to -ENOENT or choose another
> errno for current 'VARIABLE_LOCATION_INVALID_AT_ADDR', what's
> your opinion?

OK, above should be changed to -ENOTSUP, since it does not seem to come
from an invalid range :)

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-11  6:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-09  9:55 [PATCH v2 1/3] perf probe: Remove length limitation for showing available variables He Kuang
2015-05-09  9:55 ` [PATCH v2 2/3] perf probe: Add --range option to show variable location range He Kuang
2015-05-10  3:21   ` Masami Hiramatsu
2015-05-11  2:22     ` He Kuang
2015-05-11  6:03       ` Masami Hiramatsu [this message]
2015-05-09  9:55 ` [PATCH v2 3/3] perf probe: Show better error message when failed to find variable He Kuang
2015-05-10  3:23   ` Masami Hiramatsu
2015-05-10  3:23 ` [PATCH v2 1/3] perf probe: Remove length limitation for showing available variables Masami Hiramatsu

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=55504642.1020301@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