[DTrace-devel] Scratch space in the BPF-based DTrace

Kris Van Hees kris.van.hees at oracle.com
Fri May 21 21:29:39 PDT 2021


DTrace has traditionally used the remainder of the current buffer (in the
default buffer swap strategy) as scratch space.  This is memory that can
be used during the execution of a clause.  It is used to perform various
actions that have a temporary need for a memory block, such as alloca(),
bcopy(), many string operations, and so on.

In BPF-based DTrace we have similar needs due to the need to implement
all the same subroutines and actions.  Furthermore, we need space to
construct the trace data record for the clause, and also space to store
a stack trace when we are only interested in the depth rather than also
wanting the actual data.  (On a side note, it may be possible to use an
optimization where a stack() / stackdepth combination is encountered,
even if a few statements apart, to only retrieve the stack trace once.)

Fortunately (from an efficiency perspective), we do not actually need
scratch spsce for all these different uses in one single clause.  E.g.
temporary string value that is stored in scratch space will no longer be
needed when a copy of the current stack trace might be requested.  This
means that the size of the scratch space can be calculated based on the
greatest need for space that is requested from any clause.

Note that the scratch space will be allocated within the 'mem' BPF map.

	Kris



More information about the DTrace-devel mailing list