mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: acme@kernel.org, jolsa@kernel.org, mhiramat@kernel.org,
	adrian.hunter@intel.com, linux-kernel@vger.kernel.org
Subject: Re: Implement dwarf variable/type resolving for perf script
Date: Tue, 28 Nov 2017 14:31:00 +0900	[thread overview]
Message-ID: <20171128143100.e23ce8a6a592bbb1b51cda19@kernel.org> (raw)
In-Reply-To: <20171128002321.2878-1-andi@firstfloor.org>

Hi Andi,

On Mon, 27 Nov 2017 16:23:09 -0800
Andi Kleen <andi@firstfloor.org> wrote:

> This patchkit extends perf script to query dwarf information for variable
> names or types/structure fields accessed from code. 

Very interesting! so it is a kind of revert query interface.

> 
> The dwarf resolution is all on top of Masami's perf probe dwarf code.
> 
> It supports multiple use cases:
> - When we sample registers it can use the dwarf information to resolve
> the registers to names.
> - When we sample any instruction the instruction can be decoded and
> we can determine the type/struct field to make an estimate of the 
> memory access patterns in data structures. 
> - When we sample the new PTWRITE instruction the logged value from
> the PT log can be associated with a variable.
> - Various cleanups and fixes to make the one above all possible.

OK, I'll review that.

Thanks!

> 
> It is all implemented with new output formats in perf script:
> iregval (map register values to names) and insnvar (decode instruction
> and map back memory operand to dwarf operation)
> 
> There are some limitations, it cannot decode everything, and is
> somewhat slow, but it's already quite useful for typical code
> 
> 
>     % perf record -Idi,si ./targ
>     % perf script -F +iregvals
>     ...
>         targ  8584 169763.761843:    2091795 cycles:ppp:            40041a main (targ)
>         targ  8584 169763.762520:    1913932 cycles:ppp:            400534 f1 (targ) { b = 0x2, int }  { a = 0x1, int }
>         targ  8584 169763.763141:    1638913 cycles:ppp:            400523 f2 (targ) { b = 0x1, int }  { a = 0x2, int }
>         targ  8584 169763.763672:    1516522 cycles:ppp:            400522 f2 (targ) { b = 0x1, int }  { a = 0x2, int }
>         targ  8584 169763.764165:    1335501 cycles:ppp:            400523 f2 (targ) { b = 0x1, int }  { a = 0x2, int }
>         targ  8584 169763.764598:    1253289 cycles:ppp:            400522 f2 (targ) { b = 0x2, int }  { a = 0x1, int }
>         targ  8584 169763.765005:    1135131 cycles:ppp:            400534 f1 (targ) { b = 0x2, int }  { a = 0x1, int }
>         targ  8584 169763.765373:    1080325 cycles:ppp:            400522 f2 (targ) { b = 0x2, int }  { a = 0x1, int }
>         targ  8584 169763.765724:    1036999 cycles:ppp:            400522 f2 (targ) { b = 0x1, int }  { a = 0x2, int }
>         targ  8584 169763.766061:     971213 cycles:ppp:            400534 f1 (targ) { b = 0x2, int }  { a = 0x1, int }
> 
> 
>     % perf record -e intel_pt//u  -a sleep 1
>     % perf script --itrace=i0ns -F insnvar,insn,ip,sym  -f 2>&1 | xed -F insn: -A -64 | less
>     ...
>                4f7e61 xyarray__max_y                pushq  %rbp
>                4f7e62 xyarray__max_y                mov %rsp, %rbp
>                4f7e65 xyarray__max_y                sub $0x20, %rsp
>                4f7e69 xyarray__max_y                movq  %rdi, -0x18(%rbp) { -24(xy), struct xyarray* }
>                4f7e6d xyarray__max_y                movq  %fs:0x28, %rax
>                4f7e76 xyarray__max_y                movq  %rax, -0x8(%rbp) { -8(xy), struct xyarray* }
>                4f7e7a xyarray__max_y                xor %eax, %eax
>                4f7e7c xyarray__max_y                movq  -0x18(%rbp), %rax { -24(xy), struct xyarray* }
>                4f7e80 xyarray__max_y                movq  0x20(%rax), %rax
>                4f7e84 xyarray__max_y                movq  -0x8(%rbp), %rdx { -8(xy), struct xyarray* }
>                4f7e88 xyarray__max_y                xorq  %fs:0x28, %rdx
>                4f7e91 xyarray__max_y                jz 0x7
>                4f7e98 xyarray__max_y                leaveq
>                4f7e99 xyarray__max_y                retq
>     
> In this example we now know that this function accesses two fields in struct xyarray *
> 
> Available from
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc perf/var-resolve-2
> 
> v1: Initial post


-- 
Masami Hiramatsu <mhiramat@kernel.org>

      parent reply	other threads:[~2017-11-28  5:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28  0:23 Andi Kleen
2017-11-28  0:23 ` [PATCH 01/12] perf, tools, pt: Clear instruction for ptwrite samples Andi Kleen
2017-11-28  0:23 ` [PATCH 02/12] perf, tools, script: Print insn/insnlen for non PT sample Andi Kleen
2017-11-28  0:23 ` [PATCH 03/12] perf, tools: Support storing additional data in strlist Andi Kleen
2017-11-28 13:31   ` Masami Hiramatsu
2017-11-28  0:23 ` [PATCH 04/12] perf, tools: Store variable name and register for dwarf variable lists Andi Kleen
2017-11-28  0:23 ` [PATCH 05/12] perf, tools, probe: Print location for resolved variables Andi Kleen
2017-11-29  1:19   ` Masami Hiramatsu
2017-11-28  0:23 ` [PATCH 06/12] perf, tools, probe: Support a quiet argument for debug info open Andi Kleen
2017-11-29  3:14   ` Masami Hiramatsu
2017-11-29  3:39     ` Andi Kleen
2017-11-30  2:36       ` Masami Hiramatsu
2017-11-28  0:23 ` [PATCH 07/12] perf, tools, script: Resolve variable names for registers Andi Kleen
2017-11-28  0:23 ` [PATCH 08/12] perf, tools: Always print probe finder warnings with -v Andi Kleen
2017-11-29  3:16   ` Masami Hiramatsu
2017-11-28  0:23 ` [PATCH 09/12] perf, tools: Downgrade register mapping message to warning Andi Kleen
2017-11-29  5:56   ` Masami Hiramatsu
2017-11-28  0:23 ` [PATCH 10/12] perf, tools: Add args and gprs shortcut for registers Andi Kleen
2017-11-28  0:23 ` [PATCH 11/12] perf, tools: Print probe warnings for binaries only once per binary Andi Kleen
2017-11-30  2:38   ` Masami Hiramatsu
2017-11-28  0:23 ` [PATCH 12/12] perf, tools, script: Implement dwarf resolving of instructions Andi Kleen
2017-12-01  2:36   ` Masami Hiramatsu
2017-11-28  5:31 ` Masami Hiramatsu [this message]

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=20171128143100.e23ce8a6a592bbb1b51cda19@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome