Kernel Profiling on FreeBSD


Use "config -p" to configure the kernel with profiling support; make sure to build the kernel from scratch (i.e., do a make clean before make depend). "config -p" will configure for low-resolution timers; specifying "-pp" will configure for high-resolution timers.


Boot the kernel, and use the kgmon(8) command to frob the kernel profiling state. The "-b" (-p) and "-B" (-pp) parameters turn on profiling; "-h" turns it off, and "-p" dumps the profiling buffers to a gmon.out file in the current working directory.

You can then use gprof against the kernel binary and profile buffer to generate call graphs and user-readable profile data. Typically, this will take the form of "gprof /boot/kernel/kernel gmon.out".

You can also use kernbb(8) to dump the profile buffers in a form to be used by the gcov(1) tool to generate coverage data.


See Also

See also: gcov(1), gprof(1), config(8), kernbb(8), kgmon(8)

Some Files