Product SiteDocumentation Site

20.2.2. Setting Events to Monitor

Most processors contain counters, which are used by OProfile to monitor specific events. As shown in Table 20.3, “OProfile Processors and Counters”, the number of counters available depends on the processor.
The events for each counter can be configured via the command line or with a graphical interface. For more information on the graphical interface, see Section 20.10, “Graphical Interface”. If the counter cannot be set to a specific event, an error message is displayed.

Older Processors and operf

Some older processor models are not supported by the underlying Linux Performance Events Subsystem kernel and therefore are not supported by operf. If you receive this message:
Your kernel's Performance Events Subsystem does not support your processor type
when attempting to use operf, try profiling with opcontrol to see if your processor type may be supported by OProfile's legacy mode.

Using operf on Virtual Systems

Since hardware performance counters are not available on guest virtual machines, you have to enable timer mode to use operf on virtual systems. To do so, type as root:
opcontrol --deinit
modprobe oprofile timer=1
To set the event for each configurable counter via the command line, use:
operf --events=event1,event2
Here, pass a comma-separated list of event specifications for profiling. Each event specification is a colon-separated list of attributes in the following form:
event-name:sample-rate:unit-mask:kernel:user
Table 20.2, “Event Specifications” summarizes these options. The last three values are optional, if you omit them, they will be set to their default values. Note that certain events do require a unit mask.
Table 20.2. Event Specifications
Specification Description
event-name The exact symbolic event name taken from ophelp
sample-rate The number of events to wait before sampling again. The smaller the count, the more frequent the samples. For events that do not happen frequently, a lower count may be needed to capture a statistically significant number of event instances. On the other hand, sampling too frequently can overload the system. By default, OProfile uses a time-based event set, which creates a sample every 100,000 clock cycles per processor.
unit-mask Unit masks, which further define the event, are listed in ophelp. You can insert either a hexadecimal value, beginning with "0x", or a string that matches the first word of the unit mask description in ophelp. Definition by name is valid only for unit masks having "extra:" parameters, as shown by the output of ophelp. This type of unit mask cannot be defined with a hexadecimal value. Note that on certain architectures, there can be multiple unit masks with the same hexadecimal value. In that case they have to be specified by their names only.
kernel Specifies whether to profile kernel code (insert 0 or 1(default))
user Specifies whether to profile user-space code (insert 0 or 1 (default))

The events available vary depending on the processor type. When no event specification is given, the default event for the running processor type will be used for profiling. See Table 20.4, “Default Events” for a list of these default events. To determine the events available for profiling, use the ophelp command.
ophelp