linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: David Ahern <dsahern@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>,
	Brendan Gregg <brendan.d.gregg@gmail.com>,
	Carl Love <cel@us.ibm.com>, Pekka Enberg <penberg@kernel.org>,
	"linux-perf-use." <linux-perf-users@vger.kernel.org>
Subject: Re: Perf support for interpreted and Just-In-Time translated olanguages
Date: Wed, 10 Dec 2014 16:43:02 -0300	[thread overview]
Message-ID: <20141210194302.GH8788@kernel.org> (raw)
In-Reply-To: <54889086.4070606@gmail.com>

Em Wed, Dec 10, 2014 at 11:27:18AM -0700, David Ahern escreveu:
> On 12/10/14 11:05 AM, Andi Kleen wrote:
> >On Wed, Dec 10, 2014 at 10:39:53AM -0700, David Ahern wrote:
> >>On 12/10/14 10:32 AM, Andi Kleen wrote:
> >>>> From what I understood, how would it insert that event into the
> >>>>perf.data event stream? Only if it necessarily involved a new mmap, via
> >>>>the kernel, etc.

> >>>That's the new interface to be defined.

> >>>Just write a perf.data?

> >>Pawel Moll's new ioctl -- assumming it gets committed.

> >We can't push large volume data -- like line numbers and executable code -
> >through a ioctl.
 
> If you write a separate perf.data file then it has to be merged with the
> file generated by perf which brings in the perf_clock timestamp problem
> since timestamps are needed to merge the data sets.

yeap, but what he is saying is kinda like the problem with long running
perf sessions where a library may be updated while keeping the same
pathname, i.e. we samples taken up to the time the symtab backing
storage was replaced would be unreliable.

I think this should be solved in the same way, i.e. content based keys,
that we call build-ids, every mapping, when put in place generates an
event, say PERF_RECORD_MMAP3, that comes with a key that can later be
used to retrieve the matching ELF file with DWARF info for annotation,
symbol resolution, unwinding, etc.

Modern distros have this and that is why we store in the perf.data file
just the build ids, not the full ELF files at the time of the recording
session:

[root@ssdandy ~]# perf record -a sleep 1
^[[A^[[A[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.475 MB perf.data (~20748 samples) ]
[root@ssdandy ~]# perf buildid-list
2aae14c5b9aef2a3ebce0f168814ca7391c7ea6b /usr/lib/debug/lib/modules/3.10.0-123.el7.x86_64/vmlinux
e62a248621f017c39fbdeff22e3fb68ad3e0be77 /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/ata/libahci.ko
8acd5b3b420f0a37af9d661da5d6f88a86908c52 /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
37bed793bb0736d341002165538659862dcc9e4f /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/scsi/sd_mod.ko
8f0c72d8c938fdeecef941e47a586614ce1014e7 /lib/modules/3.10.0-123.el7.x86_64/kernel/fs/xfs/xfs.ko
9bb557cc045eb57af2f83b315389dd8287fb7f60 /lib/modules/3.10.0-123.el7.x86_64/kernel/net/ipv4/netfilter/ip_tables.ko
cff370844d00ea5451d7add439646a93c64d48a5 /usr/lib64/libc-2.17.so
18562ee0363bc9bd7101610bd86469aa426d0c44 /usr/lib64/libpthread-2.17.so
ebd9fbf2265129ceab3866d40c826c9629f08cd0 [vdso]
a8cf24d1279557a3f2e563c21a858dcd8784b665 /usr/lib64/libcrypto.so.1.0.1e
148a981dc96876372c6f5c06bbb3efd0a1668432 /usr/sbin/sshd
ce3715b450fc4015a6763b210c868f930d2cffa6 /usr/bin/find
[root@ssdandy ~]# 

[root@ssdandy ~]# ls -la perf.data
-rw-------. 1 root root 501828 Dec 10 16:26 perf.data
[root@ssdandy ~]# ls -la /usr/lib/debug/lib/modules/3.10.0-123.el7.x86_64/vmlinux
-rwxr-xr-x. 2 root root 146606780 May  5  2014 /usr/lib/debug/lib/modules/3.10.0-123.el7.x86_64/vmlinux
[root@ssdandy ~]# ls -la /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/ata/libahci.ko
-rw-r--r--. 2 root root 51561 May  5  2014 /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/ata/libahci.ko
[root@ssdandy ~]# ls -la /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
-rw-r--r--. 2 root root 400273 May  5  2014 /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
[root@ssdandy ~]# /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko


And by the build-id we can get to the right file, that may even not be
installed on the target machine at the time of profiling.

[root@ssdandy ~]# perf buildid-list -i /usr/lib64/libc-2.17.so 
cff370844d00ea5451d7add439646a93c64d48a5
[root@ssdandy ~]# ls -la /usr/lib/debug/.build-id/cf/f370844d00ea5451d7add439646a93c64d48a5
lrwxrwxrwx. 1 root root 33 Dec 10 16:32 /usr/lib/debug/.build-id/cf/f370844d00ea5451d7add439646a93c64d48a5 -> ../../../../../lib64/libc-2.17.so
[root@ssdandy ~]# rpm -qf /usr/lib/debug/.build-id/cf/f370844d00ea5451d7add439646a93c64d48a5
glibc-debuginfo-2.17-55.el7_0.1.x86_64
[root@ssdandy ~]# rpm -q glibc
glibc-2.17-55.el7_0.1.x86_64
[root@ssdandy ~]#

The agent would need to, using PERF_RECORD_MMAP3 + build-ids plus intercepting the
CompiledMethodLoad synthesize the right ELF files + build-ids, which
could be just one per workload, or multiple, if those methods gets
recompiled frequently and move to different locations.

And we may want even to have a different one per version of the compiled
method, so that developers could figure out which compiled method
generation is best :-)

- Arnaldo

  reply	other threads:[~2014-12-10 19:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-05 20:18 Perf support for interpreted and Just-In-Time translated languages Carl Love
2014-12-05 21:27 ` Brendan Gregg
2014-12-09 20:34   ` Arnaldo Carvalho de Melo
2014-12-09 22:01     ` Andi Kleen
2014-12-09 22:22       ` Perf support for interpreted and Just-In-Time translated olanguages Arnaldo Carvalho de Melo
2014-12-10  0:38         ` Andi Kleen
2014-12-10 17:41           ` Carl Love
2014-12-10 18:09             ` Andi Kleen
2014-12-10 19:21             ` Arnaldo Carvalho de Melo
2014-12-10 19:19           ` Arnaldo Carvalho de Melo
2014-12-10 17:32         ` Andi Kleen
2014-12-10 17:39           ` David Ahern
2014-12-10 18:05             ` Andi Kleen
2014-12-10 18:27               ` David Ahern
2014-12-10 19:43                 ` Arnaldo Carvalho de Melo [this message]
2015-01-09 20:19                   ` Carl Love
2015-01-10  4:15                     ` William Cohen
2015-01-10 15:14                       ` David Ahern
2015-01-12 17:22                         ` Carl Love
2015-01-12 17:58                           ` David Ahern
2015-01-12 18:43                             ` Carl Love
2015-01-20 18:19                             ` Carl Love
2015-01-20 19:29                               ` Arnaldo Carvalho de Melo
2015-01-20 20:34                                 ` Carl Love
2015-01-20 20:52                                   ` Arnaldo Carvalho de Melo
2015-01-23  8:25                               ` Sujoy Saraswati
2014-12-10  7:55     ` Perf support for interpreted and Just-In-Time translated languages Pekka Enberg

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=20141210194302.GH8788@kernel.org \
    --to=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=brendan.d.gregg@gmail.com \
    --cc=cel@us.ibm.com \
    --cc=dsahern@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=penberg@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;
as well as URLs for NNTP newsgroup(s).