5.2.4 ring Policy

The DTrace ring buffer policy helps you trace the events leading up to a failure. If reproducing the failure takes hours or days, you might want to keep only the most recent data. Once a principal buffer has filled, tracing wraps around to the first entry, overwriting older tracing data. You establish the ring buffer by specifying bufpolicy=ring:

# dtrace -s foo.d -x bufpolicy=ring

When used to create a ring buffer, dtrace does not display any output until the process is terminated. At that time, the ring buffer is consumed and processed. dtrace processes each ring buffer in CPU order. Within a CPU's buffer, trace records will be displayed in order from oldest to youngest. Just as with the switch buffering policy, no ordering exists between records from different CPUs. If such an ordering is required, you should trace the timestamp variable as part of your tracing request.

The following example demonstrates the use of a #pragma option directive to enable ring buffering:

#pragma D option bufpolicy=ring
#pragma D option bufsize=16k

/execname == $1/