Intel 64 and IA-32 Architectures Software Developers Manual Volume 3B, System Programming Guide Part 2

Table Of Contents
Vol. 3 18-93
DEBUGGING AND PERFORMANCE MONITORING
when operating system code and/or application code are being executed. If neither
the OS nor USR flag is set, no events will be counted.
The ESCRs are initialized to all 0s on reset. The flags and fields of an ESCR are config-
ured by writing to the ESCR using the WRMSR instruction. Table 18-26 gives the
addresses of the ESCR MSRs.
Writing to an ESCR MSR does not enable counting with its associated performance
counter; it only selects the event or events to be counted. The CCCR for the selected
performance counter must also be configured. Configuration of the CCCR includes
selecting the ESCR and enabling the counter.
18.18.2 Performance Counters
The performance counters in conjunction with the counter configuration control
registers (CCCRs) are used for filtering and counting the events selected by the
ESCRs. The Pentium 4 and Intel Xeon processors provide 18 performance counters
organized into 9 pairs. A pair of performance counters is associated with a particular
subset of events and ESCR’s (see Table 18-26). The counter pairs are partitioned into
four groups:
The BPU group, includes two performance counter pairs:
MSR_BPU_COUNTER0 and MSR_BPU_COUNTER1.
MSR_BPU_COUNTER2 and MSR_BPU_COUNTER3.
The MS group, includes two performance counter pairs:
MSR_MS_COUNTER0 and MSR_MS_COUNTER1.
MSR_MS_COUNTER2 and MSR_MS_COUNTER3.
The FLAME group, includes two performance counter pairs:
MSR_FLAME_COUNTER0 and MSR_FLAME_COUNTER1.
MSR_FLAME_COUNTER2 and MSR_FLAME_COUNTER3.
The IQ group, includes three performance counter pairs:
MSR_IQ_COUNTER0 and MSR_IQ_COUNTER1.
MSR_IQ_COUNTER2 and MSR_IQ_COUNTER3.
MSR_IQ_COUNTER4 and MSR_IQ_COUNTER5.
The MSR_IQ_COUNTER4 counter in the IQ group provides support for the PEBS.
Alternate counters in each group can be cascaded: the first counter in one pair can
start the first counter in the second pair and vice versa. A similar cascading is
possible for the second counters in each pair. For example, within the BPU group of
counters, MSR_BPU_COUNTER0 can start MSR_BPU_COUNTER2 and vice versa, and
MSR_BPU_COUNTER1 can start MSR_BPU_COUNTER3 and vice versa (see Section
18.18.6.6, “Cascading Counters”). The cascade flag in the CCCR register for the
performance counter enables the cascading of counters.