B U I L D I N G   A N D   U S I N G   A   P R O F I L I N G   K E R N E L


These instructions are based on a posting to the NetBSD-current mailing list by Jonathan Stone <jonathan@DSG.Stanford.EDU>, on Fri, 13 Jun 1997.

This document assumes that the config file for your current kernel is /sys/i386/conf/MYNAME, and the config file for your new kernel is MYNAME.PROF in the same directory. It also assumes that you are in /sys/i386/conf. Change things appropriately for your config file name and architecture.

  1. Copy your existing kernel configuration file to another file: cp MYNAME MYNAME.PROF.

  2. Add the following to your new profiling kernel config file:
    include "arch/i386/conf/MYNAME"
    
    # Always include profiling support; does not need 'config -p'.
    makeoptions     PROF="-pg"
    options         GPROF
    

  3. Configure and compile your new profiling kernel, and copy it to /netbsd.prof.

  4. Boot your system from /netbsd.prof, and run until you get to a point where you want to start collecting profiling data. The profiling data will be written to gmon.out in the current directory.

  5. Run kgmon -N /netbsd.prof -r -b, and execute the code you need to profile. Ideally you'd like it to execute for quite some time, say a half hour or so.

  6. After this, turn off profiling with kgmon -N /netbsd.prof -p.

  7. Examine the output with gprof /netbsd.prof gmon.out.


cjs Home   Up