4.5. Timer probes
You can use intervals defined by the standard kernel jiffies timer to trigger probe handlers asynchronously. A jiffy is a kernel-defined unit of time typically between 1 and 60 msec. Two probe point variants are supported by the translator:
timer.jiffies(N) timer.jiffies(N).randomize(M)
The probe handler runs every N jiffies. If the
randomize
component is given, a linearly distributed random value in the range [-M … +M] is added to N every time the handler executes. N is restricted to a reasonable range (1 to approximately 1,000,000), and M is restricted to be less than N. There are no target variables provided in either context. Probes can be run concurrently on multiple processors.
Intervals may be specified in units of time. There are two probe point variants similar to the jiffies timer:
timer.ms(N) timer.ms(N).randomize(M)
Here, N and M are specified in milliseconds, but the full options for units are seconds (s or sec), milliseconds (ms or msec), microseconds (us or usec), nanoseconds (ns or nsec), and hertz (hz). Randomization is not supported for hertz timers.
The resolution of the timers depends on the target kernel. For kernels prior to 2.6.17, timers are limited to jiffies resolution, so intervals are rounded up to the nearest jiffies interval. After 2.6.17, the implementation uses hrtimers for tighter precision, though the resulting resolution will be dependent upon architecture. In either case, if the randomize component is given, then the random value will be added to the interval before any rounding occurs.
Profiling timers are available to provide probes that execute on all CPUs at each system tick. This probe takes no parameters, as follows.
timer.profile
Full context information of the interrupted process is available, making this probe suitable for implementing a time-based sampling profiler.
The following is an example of timer usage.
# Refers to a periodic interrupt, every 1000 jiffies: timer.jiffies(1000) # Fires every 5 seconds: timer.sec(5) # Refers to a periodic interrupt, every 1000 +/- 200 jiffies: timer.jiffies(1000).randomize(200)