4. Specifying performance counter events

Both methods of profiling (operf and opcontrol) -- as well as event counting with ocount -- allow you to give one or more event specifications to provide details of how each hardware performance counter should be set up. With operf and ocount, you can provide a comma-separated list of event specfications using the --events option. With opcontrol, you use the --event option for each desired event specification. For profiling, the event specification is a colon-separated string of the form name:count:unitmask:kernel:user as described in the table below. For ocount, specification is of the form name:unitmask:kernel:user. Note the presence of the count field for profiling. The count field tells the profiler how many events should occur between a profile snapshot (usually referred to as a "sample"). Since ocount does not do sampling, the count field is not needed.

If no event specs are passed to operf, ocount, or opcontrol, the default event will be used. With opcontrol, if you have previously specified some non-default event but want to revert to the default event, use --event=default. Use of this option overrides all previous event selections that have been cached.


OProfile will allocate hardware counters as necessary, but some processor types have restrictions as to what hardware events may be counted simultaneously. operf and ocount use a multiplexing technique when such hardware restrictions are encountered, but opcontrol does not have this capability; instead, opcontrol will display an error message if you select an incompatible set of events.

name The symbolic event name, e.g. CPU_CLK_UNHALTED
count The counter reset value, e.g. 100000; use only for profiling
unitmask The unit mask, as given in the events list: e.g. 0x0f; or a symbolic name if a name=<um_name> field is present
kernel Whether to profile kernel code
user Whether to profile userspace code

The last three values are optional, if you omit them (e.g. operf --events=DATA_MEM_REFS:30000), they will be set to the default values (the default unit mask value for the given event, and profiling (or counting) both kernel and userspace code). Note that some events require a unit mask.

You can specify unit mask values using either a numerical value (hex values must begin with "0x") or a symbolic name (if the name=<um_name> field is shown in the ophelp output). For some named unit masks, the hex value is not unique; thus, OProfile tools enforce specifying such unit masks value by name.


When using legacy mode opcontrol on IBM PowerPC platforms, all events specified must be in the same group; i.e., the group number appended to the event name (e.g. <some-event-name>_GRP9 ) must be the same.

When using operf or ocount on IBM PowerPC platforms, the above restriction regarding the same group number does not apply, and events may be specified with or without the group number suffix. If no group number suffix is given, one will be automatically assigned; thus, OProfile post-processing tools will always show real event names that include the group number suffix.

If OProfile is using timer-interrupt mode, there is no event configuration possible.

The table below lists the default profiling event for various processor types. The same events can be used for ocount, minus the count field.

Processor cpu_type Default event
Alpha EV4 alpha/ev4 CYCLES:100000:0:1:1
Alpha EV5 alpha/ev5 CYCLES:100000:0:1:1
Alpha PCA56 alpha/pca56 CYCLES:100000:0:1:1
Alpha EV6 alpha/ev6 CYCLES:100000:0:1:1
Alpha EV67 alpha/ev67 CYCLES:100000:0:1:1
ARM/XScale PMU1 arm/xscale1 CPU_CYCLES:100000:0:1:1
ARM/XScale PMU2 arm/xscale2 CPU_CYCLES:100000:0:1:1
ARM/MPCore arm/mpcore CPU_CYCLES:100000:0:1:1
AVR32 avr32 CPU_CYCLES:100000:0:1:1
Athlon i386/athlon CPU_CLK_UNHALTED:100000:0:1:1
Pentium Pro i386/ppro CPU_CLK_UNHALTED:100000:0:1:1
Pentium II i386/pii CPU_CLK_UNHALTED:100000:0:1:1
Pentium III i386/piii CPU_CLK_UNHALTED:100000:0:1:1
Pentium M (P6 core) i386/p6_mobile CPU_CLK_UNHALTED:100000:0:1:1
Pentium 4 (non-HT) i386/p4 GLOBAL_POWER_EVENTS:100000:1:1:1
Pentium 4 (HT) i386/p4-ht GLOBAL_POWER_EVENTS:100000:1:1:1
Hammer x86-64/hammer CPU_CLK_UNHALTED:100000:0:1:1
Family10h x86-64/family10 CPU_CLK_UNHALTED:100000:0:1:1
Family11h x86-64/family11h CPU_CLK_UNHALTED:100000:0:1:1
Itanium ia64/itanium CPU_CYCLES:100000:0:1:1
Itanium 2 ia64/itanium2 CPU_CYCLES:100000:0:1:1
TIMER_INT timer None selectable
IBM pseries PowerPC 4/5/6/7/8/970/Cell CYCLES:100000:0:1:1
IBM s390 timer None selectable
IBM s390x timer None selectable