|
|
Kernel profiling is a mechanism that allows you to determine where the operating system is spending its time during operation. It consists of commands that control the profiling process and commands that generate reports. (See profiler(1M) for a description of these commands.) The system profiler samples the program counter on every clock interrupt and increments the counter corresponding to the kernel function shown by that value of the program counter.
When enabled, the system profiler initializes the sampling mechanism with the addresses of kernel functions. During initialization, any dynamically loadable kernel modules that are present in memory are locked in place. Likewise, any modules that are later loaded are locked in place if profiling is enabled. Therefore it's important to disable profiling after your measurements are complete; if you don't, the dynamically loaded modules remain resident in memory, decreasing the amount of memory available for other purposes and making your system run slower than usual.
Here's a brief description of the profiling commands:
To operate the system profiler, run either prfdc or prfsnap to collect samples of the profiling counters, and run prfpr to print the profiling results. When profiling is complete, run prfstat off to disable the profiler and unlock the dynamically loadable kernel modules.
For example:
/usr/sbin/prfsnap temp <some time passes, with or without system activity> prfsnap temp prfpr temp prfstat off
If you want the profiler to begin automatically when you boot the system to multiuser state, you can add the following lines to the /etc/init.d/perf file:
/usr/sbin/prfstat onThe prf shell script is executed during system initialization and the following messages are displayed:
profiling enabledwhere xxx states how many kernel text addresses are in the current system kernel.xxx kernel text addresses loaded