lkml.org 
[lkml]   [2008]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH] Make ftrace able to trace function return
On Thu, Oct 30, 2008 at 08:26:21PM +0100, Ingo Molnar wrote:
>
> * Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > gcc -c -finstrument-functions traceme.c
>
> > This is not 5 extra bytes but 27 extra bytes for a total of 32 bytes
> > at every function. Also note that this also adds these calls to
> > inline functions as well. We could easly stop that by adding
> > "notrace" to the inline define (which I've done).
> >
> > But this would make the patching a bit more difficult (not
> > impossible). But it will bloat the image quite a bit.
>
> yeah, i too knew it was expensive, but didnt realize it's this bloaty.
> It's a non-starter really.
>
> How reliable can we make Frederic's trampoline approach? Especially
> with the opt-in function filters of dyn-ftrace, there's real value in
> the trampoline approach IMO (we could display real function cost,
> etc.), and the runtime cost should be OK as long we dont probe a ton
> of functions all the time. (and it's optional anyway)

Something similar to Frederic's trampoline approach is what we use for
kretprobes. Recently, it's also acquired the capability to run handlers
at function entry. See samples/kprobes/kretprobe_example.c -- it
currently can print the time spent in any user-specified kernel routine.

Of course, this approach is not cheap... since it's kprobe based, we
have two exceptions -- but it is reliable. You are limited by the number
of slots available to record return addresses for each invocation,
especially if functions are reentrant, in the hotpath and can sleep.

There were other issues encountered during its implementation (some
of them 'cos we hash instances on the task) were with routines that are
entered/exited in different task contexts, noret type functions, etc.

Ananth


\
 
 \ /
  Last update: 2008-11-03 12:19    [W:0.202 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site