You can run the er_kernel utility to profile only the kernel or both the kernel and the load you are running. For a complete description of the er_kernel command, see the er_kernel (1) man page.
% er_kernel -p on
Kernel clock profiling produces one performance metric, labeled KCPU Cycles. In the Performance Analyzer, it is shown for kernel functions in the Functions Tab, for callers and callees in the Caller-Callee Tab, and for instructions in the Disassembly Tab. The Source Tab does not show data, because kernel modules, as shipped, do not usually contain file and line symbol table information (stabs).
You can replace the -p on argument to the er_kernel utility with -p high for high-resolution profiling or -p low for low-resolution profiling. If you expect the run of the load to take 2 to 20 minutes, the default clock profiling is appropriate. If you expect the run to take less than 2 minutes, use -p high; if you expect the run to take longer than 20 minutes, use -p low.
You can add a -t duration argument, which will cause the er_kernel utility to terminate itself according to the time specified by duration.
The -t duration can be specified as a single number, with an optional m or s suffix, to indicate the time in minutes or seconds at which the experiment should be terminated. By default, the duration is in seconds. The duration can also be specified as two such numbers separated by a hyphen, which causes data collection to pause until the first time elapses, and at that time data collection begins. When the second time is reached, data collection terminates. If the second number is a zero, data will be collected after the initial pause until the end of the program's run. Even if the experiment is terminated, the target process is allowed to run to completion.
If no time duration or interval is specified, er_kernel will run until terminated. You can terminate it by pressing Ctrl-C (SIGINT), or by using the kill command and sending SIGINT, SIGQUIT, or SIGTERM to the er_kernel process. The er_kernel process terminates the experiment and runs er_archive (unless -A off is specified) when any of those signals is sent to the process. The er_archive utility reads the list of shared objects referenced in the experiment, and constructs an archive file for each object.
You can add the -v argument if you want more information about the run printed to the screen. The -n argument lets you see a preview of the experiment that would be recorded, without actually recording anything.
By default, the experiment generated by the er_kernel utility is named ktest.1.er; the number is incremented for successive runs.
If you have a single command, either a program or a script, that you wish to use as a load:
% er_kernel -p on load
% analyzer ktest.1.er
The er_kernel utility forks a child process and pauses for a quiet period, and then the child process runs the specified load. When the load terminates, the er_kernel utility pauses again for a quiet period and then exits. The experiment shows the behavior of the Solaris OS during the running of the load, and during the quiet periods before and after. You can specify the duration of the quiet period in seconds with the -q argument to the er_kernel command.
If you have a single program that you wish to use as a load, and you are interested in seeing its profile in conjunction with the kernel profile:
% er_kernel collect load
% analyzer ktest.1.er test.1.er
The data displayed by the Analyzer shows both the kernel profile from ktest.1.er and the user profile from test.1.er. The timeline allows you to see correlations between the two experiments.
Note - To use a script as the load, and profile the various parts of it, prepend the collect, command, with the appropriate arguments, to the various commands within the script.
You can invoke the er_kernel utility with one or more -T arguments to specify profiling for specific processes or threads:
-T pid/ tid for a specific process and kernel-thread
-T 0/ did for a specific pure-kernel thread
The target threads must have been created before you invoke the er_kernel utility for them.
When you give one or more -T arguments, an additional metric, labeled Kthr Time, is produced. Data is captured for all profiled threads, whether running on a CPU or not. Special single-frame call stacks are used for indicating the process is suspended (the function <SLEEPING>) or waiting for the CPU (the function <STALLED >).
Functions with high Kthr Time metrics, but low KCPU Cycles metrics, are functions that are spending a lot of time for the profiled threads waiting for some other events.