This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] Tracepoint Tapset for Memory Subsystem


On Mon, Sep 28, 2009 at 11:12:28AM -0700, Jim Keniston wrote:
> 
> On Fri, 2009-09-25 at 14:19 -0500, David Smith wrote:
> ...
> > 
> > Sorry to keep finding more things, but...
> > 
> > I'm a bit worried about your use of '__builtin_return_address()' here.
> > Jim Keniston reported on it back in 2005 in the following message, but
> > there isn't much context.
> > 
> > <http://sourceware.org/ml/systemtap/2005-q2/msg00242.html>
> > 
> > Jim, can you remember some context here?  Was the use of
> > '__builtin_return_address' considered good/bad/neutral?  We don't seem
> > to use it anywhere else.
> > 
> 
> In case anybody still cares...
>

Yes, your explanation actually helped!
 
> The context was that we had recently implemented kretprobes, and
> somebody pointed out that hijacking the return address would cause
> __builtin_return_address() to return the wrong value.  From my survey of
> the kernel, I concluded that "__builtin_return_address is used entirely
> for tracing (tracing that is disabled by default), profiling, and error
> reporting.  I couldn't find any case where normal operation of the OS
> would be affected."
> 
> Ironically, soon after that, kprobes itself started using
> __builtin_return_address().
> 
> Anyway, there was no controversy as to whether
> __builtin_return_address() was bad or good per se; it was simply
> recognized that it would return invalid results when called from a
> return-probed function.
> 
> Jim
> 

This means that __builtin_return_address() would return incorrect values
irrespective of whether it is used inside a kprobe or a tracepoint based
probe i.e. "kmem.kfree.kp" or "kmem.kfree.tp".

And since the tracepoints export them (through $call_site parameter),
I think we can continue to use them in the kprobe based fallback probe
too.

Thanks,
K.Prasad


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]