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: Implementing a generic binary trace interface.


Hi -


On Fri, Jan 27, 2006 at 12:04:23PM +0900, Masami Hiramatsu wrote:

> [...]
> > Can you think of a scenario where tracing an entire array could be
> > necessary in a time-critical place?  [...]
> 
> I think this feature is useful for the cases below.
> - Shortage of Stack
>
> There may be trace points at where there is not enough memory of
> stack. The variable arguments may consume a lot of memory from
> the stack. [...]

But to insert values into an array, or to pull them back out, involves
possibly deeply nested function calls into the runtime.  These take
far more dynamic stack space than one or two extra paramters to a
single function.

Please note that my current favorite scheme is different, where
individual traced values would not be passed to a function like the
gBTI trace(), but rather passed as an specialized binary struct to
some buffer reservation routine, so the above is just hypothetical.

> - Single Probe for Various Events
> [...]
> // definitions of events
> probe kernel.trace.event1 = kernel.function("sys_gettimeofday").return {
> 	etype = 1; arg1 = retval(); nargs = 1
> }
> probe kernel.trace.event2 = kernel.function(""do_fork") {
> 	etype = 2; arg1 = pid(); arg2 = $clone_flags;
> 	arg3 = $stack_start;arg4 = $stack_size; nargs = 4;
> }
> // probe handler
> probe kernel.trace.* {
> 	binary_log(nargs + 1,etype, arg1,arg2,arg3,arg4);
> }
> [...]

To spell out the other (struct-based) binary tracing scenario, the
above could look like this instead:
 
# probe kernel.trace.event1 = kernel.function("sys_gettimeofday").return {
#       trace(retval())
# }
# probe kernel.trace.event2 = kernel.function(""do_fork") {
#       trace(pid())
#       trace($clone_flags)
#       trace($stack_start)
#       trace($stack_size)
# }
# // invoke all aliases
# probe kernel.trace.* { }

Note:

- systemtap could uniquely identify each trace record by assigning
  each of them a unique type (ID) number automatically
- that mapping can be reversed to the probe point (pp()) automatically
  when the binary data is decoded
- no explicit function call is needed to send the data on its way,
  that too is automatic (due to presence of trace())

 
> On the other hand, an array uses only necessary memory.

Even an empty systemtap array takes a lot of heap memory.


- FChE


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