5.2.4 ring Policy

The DTrace ring buffer policy assists with
tracing 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. When 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 as follows:

# 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. The
dtrace command processes each ring buffer in
CPU order. Within a CPU's buffer, trace records are 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: