Intel IA-32 User Manual
Page 18
![background image](/manuals/129204/18/background.png)
CONTENTS
xviii
Vol. 3A
PAGE
18.5.7.1
Last Exception Records and Intel EM64T . . . . . . . . . . . . . . . . . . . . . . . . . .18-19
18.5.8
Branch Trace Store (BTS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-19
18.5.8.1
Detection of the BTS Facilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-20
18.5.8.2
Setting Up the DS Save Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-20
18.5.8.3
Setting Up the BTS Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-21
18.5.8.4
Setting Up CPL-Qualified BTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-22
18.5.8.5
Writing the DS Interrupt Service Routine . . . . . . . . . . . . . . . . . . . . . . . . . . .18-22
18.6
LAST BRANCH, INTERRUPT, AND EXCEPTION
RECORDING (PENTIUM M PROCESSORS) . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-23
18.7
LAST BRANCH, INTERRUPT, AND EXCEPTION
RECORDING (P6 FAMILY PROCESSORS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-25
18.7.1
DebugCtlMSR Register (P6 Family Processors). . . . . . . . . . . . . . . . . . . . . . . .18-25
18.7.2
Last Branch and Last Exception MSRs (P6 Family Processors). . . . . . . . . . . .18-26
18.7.3
Monitoring Branches, Exceptions, and Interrupts (P6 Family
Processors) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-27
18.8
TIME-STAMP COUNTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-28
18.9
PERFORMANCE MONITORING OVERVIEW. . . . . . . . . . . . . . . . . . . . . . . . . . . 18-29
18.10
PERFORMANCE MONITORING (PENTIUM 4
AND INTEL XEON PROCESSORS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-30
18.10.1
ESCR MSRs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-33
18.10.2
Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-35
18.10.3
CCCR MSRs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-36
18.10.4
Debug Store (DS) Mechanism. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-38
18.10.5
DS Save Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-39
18.10.5.1
DS Save Area and IA-32e Mode Operation . . . . . . . . . . . . . . . . . . . . . . . . .18-42
18.10.6
Programming the Performance Counters for Non-Retirement Events . . . . . . .18-43
18.10.6.1
Selecting Events to Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-44
18.10.6.2
Filtering Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-47
18.10.6.3
Starting Event Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-48
18.10.6.4
Reading a Performance Counter’s Count. . . . . . . . . . . . . . . . . . . . . . . . . . .18-48
18.10.6.5
Halting Event Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-49
18.10.6.6
Cascading Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-49
18.10.6.7
EXTENDED CASCADING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-50
18.10.6.8
EXTENDED CASCADING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-51
18.10.6.9
Generating an Interrupt on Overflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-51
18.10.6.10
Counter Usage Guideline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-52
18.10.7
At-Retirement Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-52
18.10.7.1
Using At-Retirement Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-54
18.10.7.2
Tagging Mechanism for Front_end_event . . . . . . . . . . . . . . . . . . . . . . . . . .18-55
18.10.7.3
Tagging Mechanism For Execution_event . . . . . . . . . . . . . . . . . . . . . . . . . .18-55
18.10.7.4
Tagging Mechanism for Replay_event . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-56
18.10.8
Precise Event-Based Sampling (PEBS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-56
18.10.8.1
Detection of the Availability of the PEBS Facilities . . . . . . . . . . . . . . . . . . . .18-56
18.10.8.2
Setting Up the DS Save Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-57
18.10.8.3
Setting Up the PEBS Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-57
18.10.8.4
Writing a PEBS Interrupt Service Routine . . . . . . . . . . . . . . . . . . . . . . . . . .18-57
18.10.8.5
Other DS Mechanism Implications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-57
18.10.9
Counting Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-57
18.10.9.1
Non-Halted Clockticks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-58
18.10.9.2
Non-Sleep Clockticks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-59
18.10.9.3
Incrementing the Time-Stamp Counter. . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-59
18.10.10
Operating System Implications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18-60