lkml.org 
[lkml]   [2009]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: malloc() tracing in perf?
Hi -

On Thu, Aug 06, 2009 at 10:16:50AM +0200, Peter Zijlstra wrote:
> [...]
> > But then it hit me, why can't I have kmemtrace + perf but for
> > user-space? Something like the "Malloc Trace" shown here:
> > [...]

> I seem to have heard people are working on such a thing, but I can't
> seem to find a single LKML post with 'uprobe' in the subject in the
> past two years [...]

That work is ongoing, and being discussed on utrace-devel@redhat.com,
since it is a prerequisite. One of the widgets that is being proposed
for it is an ftrace engine frontend for uprobes, paralleling the one
mhiramat wrote for kprobes.


> Now doing probes on userspace is hard because you need to know more
> about the userspace bits than a kernel really ought to be interested
> in. [...] Anyway, like you say, it has uses (potentially very
> powerful ones), Sun/Apple do it with Dtrace, Linux wants it but I
> don't think we quite agreed on how to do it :-)

While these deliberations are ongoing, you can use systemtap. Probing
random places in userspace is about as casual as probing the kernel:


# stap -e '
probe process("/lib/libc.so.6").function("malloc").return,
process("/lib/libc.so.6").function("free").return
{ println(probfunc()," ",$$parms," ",$$return) }
' -c 'ls' # -c 'CMD ARGS'

__libc_malloc bytes=0x238 return=0x1524010
__libc_malloc bytes=0x238 return=0x1524010
__libc_malloc bytes=0x78 return=0x1524250
__libc_malloc bytes=0xa return=0x15242d0
__libc_free mem=0x1524250
__libc_free mem=0x1524010
__libc_malloc bytes=0x64 return=0x1524010
__libc_malloc bytes=0x16 return=0x1524080
__libc_free mem=0x1524010
__libc_malloc bytes=0x64 return=0x1524010
[...]
__libc_free mem=0x1524490
__libc_free mem=0x1524500
__libc_free mem=0x15245e0
__libc_free mem=0x1524620
__libc_free mem=0x1524430
__libc_free mem=0x1524570
__libc_free mem=0x1524660
__libc_free mem=0x15246d0
__libc_free mem=0x15242d0

You can google some other success stories or ask for more help at
systemtap@sourceware.org.


- FChE


\
 
 \ /
  Last update: 2009-08-06 13:25    [W:0.036 / U:1.764 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site