5.2.1 switch Policy

By default, the principal buffer has a switch buffer policy. Under this policy, per-CPU buffers are allocated in pairs, where one buffer is active and the other buffer is inactive. When a DTrace consumer attempts to read a buffer, the kernel first switches the inactive and active buffers. Buffer switching is done in such a manner that there is no window in which tracing data can be lost. When the buffers are switched, the newly inactive buffer is copied out to the DTrace consumer. This policy assures that the consumer always sees a self-consistent buffer. Note that a buffer is never simultaneously traced to and copied out. This technique also avoids introducing a window of time in which tracing is paused or otherwise prevented. The rate at which the buffer is switched and read out is controlled by the consumer with the switchrate option. As with any rate option, switchrate can be specified with the any time suffix, but defaults to rate-per-second. For more information about switchrate and other options, see Chapter 10, Options and Tunables.

Under the switch policy, if a given enabled probe would trace more data than there is space available in the active principal buffer, the data is dropped and a per-CPU drop count is incremented. In the event of one or more drops, dtrace displays a message similar to the following:

dtrace: 11 drops on CPU 0

If a given record is larger than the total buffer size, the record is dropped, regardless of buffer policy. You can reduce or eliminate drops, either by increasing the size of the principal buffer with the bufsize option, or by increasing the switching rate with the switchrate option.

Under the switch policy, scratch memory for DTrace subroutines is allocated out of the active buffer.