Declaring Probes

SDT probes are declared using the DTRACE_PROBE, DTRACE_PROBE1, DTRACE_PROBE2, DTRACE_PROBE3, and DTRACE_PROBE4 macros from <linux/sdt.h>. The module name and function name of an SDT-based probe corresponds to the kernel module and function of the probe. The name of the probe depends on the name given in the DTRACE_PROBEn macro. If the name does not contain two consecutive underscores (__), the name of the probe is as written in the macro. If the name contains two consecutive underscores, the probe name converts the consecutive underscores to a single dash (-). For example, if a DTRACE_PROBE macro specifies transaction__start, the SDT probe is named transaction-start. This substitution allows C code to provide macro names that are not valid C identifiers without specifying a string.

DTrace includes the kernel module name and function name as part of the tuple identifying a probe, so you do not need to include this information in the probe name to prevent name space collisions. You can use the command dtrace -l -m module to list the probes that your driver module has installed and the full names that are seen by DTrace users.

SDT can also act as a metaprovider by registering probes so they appear to come from other providers such as io, proc, and sched, which do not have dedicated modules of their own. For example, kernel/exit.c contains calls to the DTRACE_PROC macro, which is defined in <linux/sdt.h> as:

# define DTRACE_PROC(name) \

Probes that use such macros appear to come from a provider other than sdt. The leading double underscore, provider name, and trailing underscore in the name argument are used to match the provider and are not included in the probe name. At present, you cannot use this functionality to create probes for providers other than those that are hard-coded into DTrace.