In sys/malloc.h
The header where struct malloc_type is defined.
A dtrace provider for tracing kernel memory allocations by type
dtmalloc::function:malloc
dtmalloc::function:free
The dtmalloc provider instruments malloc(9) and free(9) kernel functions to trace memory allocations by type. Refer to malloc(9) for more details about malloc types.
The dtmalloc::function:malloc probe fires upon a successful allocation. Its probe arguments are:
| Probe Argument | Definition |
| args[0] | struct malloc_type *mtp |
| args[1] | struct malloc_type_internal *mtip |
| args[2] | struct malloc_type_stats *mtsp |
| args[3] | unsigned long size |
| args[4] | int zindx |
The dtmalloc::function:free probe fires upon a free operation. Its probe arguments are:
| free Probe Argument | Definition |
| args[0] | struct malloc_type *mtp |
| args[1] | struct malloc_type_internal *mtip |
| args[2] | struct malloc_type_stats *mtsp |
| args[3] | unsigned long size |
| args[4] | Always 0 |
The first three arguments for each probe (i.e., mtp, mtip,, and mtsp) provide references to the malloc(9) type internals; size is the size of the allocation; zindx is the index into the kmemzones[] array used for the allocation. In practice, size is the most useful parameter to trace.
The function part of the probe description in the dtmalloc provider is the malloc(9) type short description with all whitespace characters replaced with underscores. For example, a malloc type defined by
MALLOC_DEFINE(M_FOO_BAR, "foo bar", "FooBar subsystem");
will have probes called
dtmalloc::foo_bar:
In sys/malloc.h
The header where struct malloc_type is defined.
# dtrace -n 'dtmalloc:::malloc {@[stringof args[0]->ks_shortdesc] = count()}'
dtrace: description 'dtmalloc:::malloc ' matched 480 probes
^C
80211node 1
CAM CCB 1
CAM periph 1
ioctlops 1
netlink 1
soname 4
sysctltmp 4
solaris 5
acpica 16
temp 36
lkpikmalloc 44
iov 100
selfd 648
The dtmalloc provider does not trace uma(9) allocations.