dtrace noob: How is it used?

Domagoj Stolfa domagoj.stolfa at gmail.com
Sat May 20 11:35:36 UTC 2017


Hello,

> Trying to use dtrace on my drm-next kernel that leaks memory to the
> extent that all swap space gets filled.
> easy enogh: kldload dtraceall
> 
> But which parameters and exactly how am I supposed to capture
> afterwards? I assume most useful info would be a) memory leaks per
> minute and b) source of leak. Wiki page was not much help for
> understanding usage: https://wiki.freebsd.org/DTrace/One-Liners

From my understanding, I don't think there are scripts that can explicltly tell
you that there have been memory leaks somewhere, but FreeBSD, upon unloading a
module will tell you that a given module has leaked X bytes of memory. However,
DTrace on FreeBSD has a dtmalloc provider, which lets you inspect quite a bit of
things based on named memory in the kernel. You could try using that in order to
detect which memory hasn't been freed based on the expected code flow in the
kernel.

To do this, you would have to look at the kernel code of interest, use the fbt
provider in order to instrument the problems you want, and based on that inspect
whether or not a given dtmalloc probe has fired with a given memory region (if
you have access to it).

Aside from that, I'm not aware of any other way to go about it.

> * /usr/share/dtrace has scirpts, are those sufficient for the problem
> or should I add sysutils/DTraceToolkit?
> * Which script(s) would provide adequate info for this problem and how
> could I log a per minute (or perhaps per event) output from the probes?

The DTrace Toolkit is largely written with Solaris (now illumos) in mind, so
there is a chance that some scripts in there might not work.

-- 
Best regards,
Domagoj Stolfa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-dtrace/attachments/20170520/c148e399/attachment.sig>


More information about the freebsd-dtrace mailing list