1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
|
.\" Copyright (c) 2003 Joseph Koshy. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" This software is provided by Joseph Koshy ``as is'' and
.\" any express or implied warranties, including, but not limited to, the
.\" implied warranties of merchantability and fitness for a particular purpose
.\" are disclaimed. in no event shall Joseph Koshy be liable
.\" for any direct, indirect, incidental, special, exemplary, or consequential
.\" damages (including, but not limited to, procurement of substitute goods
.\" or services; loss of use, data, or profits; or business interruption)
.\" however caused and on any theory of liability, whether in contract, strict
.\" liability, or tort (including negligence or otherwise) arising in any way
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
.\" $FreeBSD$
.\"
.Dd Apr 15, 2005
.Os
.Dt PMC 3
.Sh NAME
.Nm pmc_allocate ,
.Nm pmc_attach ,
.Nm pmc_configure_logfile ,
.Nm pmc_cpuinfo ,
.Nm pmc_detach ,
.Nm pmc_disable ,
.Nm pmc_enable ,
.Nm pmc_event_names_of_class ,
.Nm pmc_get_driver_stats ,
.Nm pmc_init ,
.Nm pmc_name_of_capability ,
.Nm pmc_name_of_class ,
.Nm pmc_name_of_cputype ,
.Nm pmc_name_of_event ,
.Nm pmc_name_of_mode ,
.Nm pmc_name_of_state ,
.Nm pmc_ncpu ,
.Nm pmc_npmc ,
.Nm pmc_pmcinfo ,
.Nm pmc_read ,
.Nm pmc_release ,
.Nm pmc_rw ,
.Nm pmc_set ,
.Nm pmc_start ,
.Nm pmc_stop ,
.Nm pmc_write ,
.Nm pmc_x86_get_msr
.Nd programming API for using hardware performance monitoring counters
.Sh LIBRARY
.Lb libpmc
.Sh SYNOPSIS
.In pmc.h
.Ft int
.Fo pmc_allocate
.Fa "const char *eventspecifier"
.Fa "enum pmc_mode mode"
.Fa "uint32_t flags"
.Fa "uint32_t cpu"
.Fa "pmc_id_t *pmcid"
.Fc
.Ft int
.Fo pmc_attach
.Fa "pmc_id_t pmcid"
.Fa "pid_t pid"
.Fc
.Ft int
.Fn pmc_configure_logfile "int fd"
.Ft int
.Fn pmc_cpuinfo "const struct pmc_op_getcpuinfo **cpu_info"
.Ft int
.Fo pmc_detach
.Fa "pmc_id_t pmcid"
.Fa "pid_t pid"
.Fc
.Ft int
.Fn pmc_disable "uint32_t cpu" "int pmc"
.Ft int
.Fn pmc_enable "uint32_t cpu" "int pmc"
.Ft int
.Fo pmc_event_names_of_class
.Fa "enum pmc_class cl"
.Fa "const char ***eventnames"
.Fa "int *nevents"
.Fc
.Ft int
.Fn pmc_get_driver_stats "struct pmc_op_getdriverstats *gms"
.Ft int
.Fn pmc_init "void"
.Ft "const char *"
.Fn pmc_name_of_capability "enum pmc_caps pc"
.Ft "const char *"
.Fn pmc_name_of_class "enum pmc_class pc"
.Ft "const char *"
.Fn pmc_name_of_cputype "enum pmc_cputype ct"
.Ft "const char *"
.Fn pmc_name_of_disposition "enum pmc_disp pd"
.Ft "const char *"
.Fn pmc_name_of_event "enum pmc_event pe"
.Ft "const char *"
.Fn pmc_name_of_mode "enum pmc_mode pm"
.Ft "const char *"
.Fn pmc_name_of_state "enum pmc_state ps"
.Ft int
.Fn pmc_ncpu "void"
.Ft int
.Fn pmc_npmc "uint32_t cpu"
.Ft int
.Fn pmc_pmcinfo "uint32_t cpu" "struct pmc_op_getpmcinfo **pmc_info"
.Ft int
.Fn pmc_read "pmc_id_t pmc" "pmc_value_t *value"
.Ft int
.Fn pmc_release "pmc_id_t pmc"
.Ft int
.Fn pmc_rw "pmc_id_t pmc" "pmc_value_t newvalue" "pmc_value_t *oldvaluep"
.Ft int
.Fn pmc_set "pmc_id_t pmc" "pmc_value_t value"
.Ft int
.Fn pmc_start "pmc_id_t pmc"
.Ft int
.Fn pmc_stop "pmc_id_t pmc"
.Ft int
.Fn pmc_write "pmc_id_t pmc" "pmc_value_t value"
.Ft int
.Fn pmc_x86_get_msr "int pmc" "uint32_t *msr"
.Sh DESCRIPTION
These functions implement a high-level library for using the
system's hardware performance counters.
.Pp
PMCs are allocated using
.Fn pmc_allocate ,
released using
.Fn pmc_release
and read using
.Fn pmc_read .
Allocated PMCs may be started or stopped at any time using
.Fn pmc_start
and
.Fn pmc_stop
respectively.
An allocated PMC may be of
.Qq global
scope, meaning that the PMC measures system-wide events, or
.Qq process-private
scope, meaning that the PMC only counts hardware events when
the allocating process (or, optionally, its children)
are active.
.Pp
PMCs may further be in
.Qq "counting mode" ,
or in
.Qq "sampling mode" .
Sampling mode PMCs deliver an interrupt to the CPU after
a configured number of hardware events have been seen.
A process-private sampling mode PMC will cause its owner
process to get periodic
.Sy SIGPROF
interrupts, while a global sampling mode PMC is used to
do system-wide statistical sampling (see
.Xr hwpmc 4 ) .
The sampling rate desired of a sampling-mode PMC is set using
.Fn pmc_set .
Counting mode PMCs do not interrupt the CPU; their values
can be read using
.Fn pmc_read .
.Pp
System-wide statistical sampling is configured by allocating
at least one sampling mode PMC with
global scope, and when a log file is configured using
.Fn pmc_configure_logfile .
The
.Xr hwpmc 4
driver manages system-wide statistical sampling; for more
information please see
.Xr hwpmc 4 .
.Ss APPLICATION PROGRAMMING INTERFACE
.Fn pmc_init
initializes the
.Xr pmc 3
library.
This function must be called first, before any of the other
functions in the library.
.Pp
.Fn pmc_allocate
allocates a counter that counts the events named by
.Fa eventspecifier ,
and writes the allocated counter id to
.Fa *pmcid .
Argument
.Fa eventspecifier
comprises an PMC event name followed by an optional comma separated
list of keywords and qualifiers.
The allowed syntax for
.Fa eventspecifier
is processor architecture specific and is listed in section
.Sx "EVENT SPECIFIERS"
below.
The desired PMC mode is specified by
.Fa mode ,
and any mode specific modifiers are specified using
.Fa flags .
The
.Fa cpu
argument is the value
.Li PMC_CPU_ANY ,
or names the cpu the allocation is to be on.
Requesting a specific CPU makes only makes sense for global PMCs;
process-private PMC allocations should always specify
.Li PMC_CPU_ANY .
.Pp
By default a PMC configured in process-virtual counting mode is setup
to profile its owner process.
The function
.Fn pmc_attach
may be used to attach the PMC to a different process.
.Fn pmc_attach
needs to be called before the counter is first started
with
.Fn pmc_start .
The function
.Fn pmc_detach
may be used to detach a PMC from a process it was attached to
using a prior call to
.Fn pmc_attach .
.Pp
.Fn pmc_release
releases a PMC previously allocated with
.Fn pmc_allocate .
This function call implicitly detaches the PMC from all its target
processes.
.Pp
An allocated PMC may be started and stopped using
.Fn pmc_start
and
.Fn pmc_stop
respectively.
.Pp
The current value of a PMC may be read with
.Fn pmc_read
and written using
.Fn pmc_write ,
provided the underlying hardware supports these operations on
the allocated PMC.
The read and write operation may be combined using
.Fn pmc_rw .
.Pp
The
.Fn pmc_configure_logfile
function causes the
.Xr hwpmc 4
driver to log system wide performance data to file corresponding
to the process' file handle
.Fa fd .
.Pp
.Fn pmc_set
configures an sampling PMC
.Fa pmc
to interrupt every
.Fa value
events.
For counting PMCs,
.Fn pmc_set
sets the initial value of the PMC to
.Fa value .
.Pp
.Fn pmc_get_driver_statistics
copies a snapshot of the usage statistics maintained by
.Xr hwpmc 4
into the memory area pointed to be argument
.Fa gms .
.Ss SIGNAL HANDLING REQUIREMENTS
Applications using PMCs are required to handle the following signals:
.Bl -tag -width indent
.It SIGBUS
When the
.Xr hwpmc 4
module is unloaded using
.Xr kldunload 8 ,
processes that have PMCs allocated to them will be sent a
SIGBUS signal.
.It SIGIO
Attempting to read a PMC that is not currently attached to a running
process will cause a SIGIO signal to be sent to the reader.
.El
.Ss CONVENIENCE FUNCTIONS
.Fn pmc_ncpu
returns the number of CPUs present in the system.
.Pp
.Fn pmc_npmc
returns the number of PMCs supported on CPU
.Fa cpu .
.Fn pmc_cpuinfo
sets argument
.Fa cpu_info
to point to a structure with information about the system's CPUs.
.Fn pmc_pmcinfo
returns information about the current state of CPU
.Fa cpu Ap s
PMCs.
.Pp
The functions
.Fn pmc_name_of_capability ,
.Fn pmc_name_of_class ,
.Fn pmc_name_of_cputype ,
.Fn pmc_name_of_disposition ,
.Fn pmc_name_of_event ,
.Fn pmc_name_of_mode
and
.Fn pmc_name_of_state
are useful for code wanting to print error messages.
They return
.Ft "const char *"
pointers to human-readable representations of their arguments.
These return values should not be freed using
.Xr free 3 .
.Pp
.Fn pmc_event_names_of_class
returns a list of event names supported by a given PMC class
.Fa cl .
On successful return, an array of
.Ft "const char *"
pointers to the names of valid events supported by class
.Fa cl
is allocated by the library using
.Xr malloc 3 ,
and a pointer to this array is returned in the location pointed to by
.Fa eventnames .
The number of pointers allocated is returned in the location pointed
to by
.Fa nevents .
.Ss ADMINISTRATION
Individual PMCs may be enabled or disabled on a given CPU using
.Fn pmc_enable
and
.Fn pmc_disable
respectively.
For these functions,
.Fa cpu
is the CPU number, and
.Fa pmc
is the index of the PMC to be operated on.
Only the super-user is allowed to enable and disable PMCs.
.Ss X86 ARCHITECTURE SPECIFIC API
The
.Fn pmc_x86_get_msr
function returns the processor model specific register number
associated with
.Fa pmc .
Applications may use the x86
.Sy RDPMC
instruction to directly read the contents of the PMC.
.Sh EVENT SPECIFIERS
Event specifiers are strings comprising of an event name, followed by
optional parameters modifying the semantics of the hardware event
being probed.
Event names are PMC architecture dependent, but the
.Xr hwpmc 4
library defines machine independent aliases for commonly used
events.
.Ss Event Name Aliases
Event name aliases are CPU architecture independent names for commonly
used events.
The following aliases are known to this version of the
.Xr pmc 3
library:
.Bl -tag -width indent
.It Li branches
Measure the number of branches retired.
.It Li branch-mispredicts
Measure the number of retired branches that were mispredicted.
.It Li cycles
Measure processor cycles.
This event is implemented using the processor's Time Stamp Counter
register.
.It Li dc-misses
Measure the number of data cache misses.
.It Li ic-misses
Measure the number of instruction cache misses.
.It Li instructions
Measure the number of instructions retired.
.It Li interrupts
Measure the number of interrupts seen.
.El
.Ss Time Stamp Counter (TSC)
The timestamp counter is a monontonically non-decreasing counter that
counts processor cycles.
.Pp
In the i386 architecture this counter may
be selected by requesting an event with eventspecifier
.Ic tsc .
The
.Ic tsc
event does not support any further qualifiers.
It can only be allocated in system-wide counting mode,
and is a read-only counter.
Multiple processes are allowed to allocate the TSC.
Once allocated, it may be read using the
.Fn pmc_read
function, or by using the RDTSC instruction.
.Ss AMD (K7) PMCs
These PMCs are present in the
.Tn "AMD Athlon"
series of CPUs and are documented in:
.Rs
.%B "AMD Athlon Processor x86 Code Optimization Guide"
.%N "Publication No. 22007"
.%D "February 2002"
.%Q "Advanced Micronic Devices, Inc."
.Re
.Pp
Event specifiers for AMD K7 PMCs can have the following optional
qualifiers:
.Bl -tag -width indent
.It Li count= Ns Ar value
Configure the counter to increment only if the number of configured
events measured in a cycle is greater than or equal to
.Ar value .
.It Li edge
Configure the counter to only count negated-to-asserted transitions
of the conditions expressed by the other qualifiers.
In other words, the counter will increment only once whenever a given
condition becomes true, irrespective of the number of clocks during
which the condition remains true.
.It Li inv
Invert the sense of comparision when the
.Li count
qualifier is present, making the counter to increment when the
number of events per cycle is less than the value specified by
the
.Li count
qualifier.
.It Li os
Configure the PMC to count events happening at privilege level 0.
.It Li unitmask= Ns Ar mask
This qualifier is used to further qualify a select few events,
.Li k7-dc-refills-from-l2 ,
.Li k7-dc-refills-from-system
and
.Li k7-dc-writebacks .
Here
.Ar mask
is a string of the following characters optionally seperated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li m
Count operations for lines in the
.Dq Modified
state.
.It Li o
Count operations for lines in the
.Dq Owner
state.
.It Li e
Count operations for lines in the
.Dq Exclusive
state.
.It Li s
Count operations for lines in the
.Dq Shared
state.
.It Li i
Count operations for lines in the
.Dq Invalid
state.
.El
If no
.Ar unitmask
qualifier is specified, the default is to count events for caches
lines in any of the above states.
.It Li usr
Configure the PMC to count events occurring at privilege levels 1, 2
or 3.
.El
If neither of the
.Li os
or
.Li usr
qualifiers were specified, the default is to enable both.
.Pp
The event specifiers support on AMD K7 PMCs are:
.Bl -tag -width indent
.It Li k7-dc-accesses
Count data cache accesses.
.It Li k7-dc-misses
Count data cache misses.
.It Li k7-dc-refills-from-l2 Op Li ,unitmask= Ns Ar mask
Count data cache refills from L2 cache.
This event may be further qualified using the
.Li unitmask
qualifier.
.It Li k7-dc-refills-from-system Op Li ,unitmask= Ns Ar mask
Count data cache refills from system memory.
This event may be further qualified using the
.Li unitmask
qualifier.
.It Li k7-dc-writebacks Op Li ,unitmask= Ns Ar mask
Count data cache writebacks.
This event may be further qualified using the
.Li unitmask
qualifier.
.It Li k7-l1-dtlb-miss-and-l2-dtlb-hits
Count L1 DTLB misses and L2 DTLB hits.
.It Li k7-l1-and-l2-dtlb-misses
Count L1 and L2 DTLB misses.
.It Li k7-misaligned-references
Count misaligned data references.
.It Li k7-ic-fetches
Count instruction cache fetches.
.It Li k7-ic-misses
Count instruction cache misses.
.It Li k7-l1-itlb-misses
Count L1 ITLB misses that are L2 ITLB hits.
.It Li k7-l1-l2-itlb-misses
Count L1 (and L2) ITLB misses.
.It Li k7-retired-instructions
Count all retired instructions.
.It Li k7-retired-ops
Count retired ops.
.It Li k7-retired-branches
Count all retired branches (conditional, unconditional, exceptions
and interrupts).
.It Li k7-retired-branches-mispredicted
Count all misprediced retired branches.
.It Li k7-retired-taken-branches
Count retired taken branches.
.It Li k7-retired-taken-branches-mispredicted
Count mispredicted taken branches that were retired.
.It Li k7-retired-far-control-transfers
Count retired far control transfers.
.It Li k7-retired-resync-branches
Count retired resync branches (non control transfer branches).
.It Li k7-interrupts-masked-cycles
Count the number of cycles when the processor's
.Li IF
flag was zero.
.It Li k7-interrupts-masked-while-pending-cycles
Count the number of cycles interrupts were masked while pending due
to the processor's
.Li IF
flag being zero.
.It Li k7-hardware-interrupts
Count the number of taken hardware interrupts.
.El
.Ss AMD (K8) PMCs
These PMCs are present in the
.Tn "AMD Athlon64"
and
.Tn "AMD Opteron"
series of CPUs.
They are documented in:
.Rs
.%B "BIOS and Kernel Developer's Guide for the AMD Athlon(tm) 64 and AMD Opteron Processors"
.%N "Publication No. 26094"
.%D "April 2004"
.%Q "Advanced Micronic Devices, Inc."
.Re
.Pp
Event specifiers for AMD K8 PMCs can have the following optional
qualifiers:
.Bl -tag -width indent
.It Li count= Ns Ar value
Configure the counter to increment only if the number of configured
events measured in a cycle is greater than or equal to
.Ar value .
.It Li edge
Configure the counter to only count negated-to-asserted transitions
of the conditions expressed by the other fields.
In other words, the counter will increment only once whenever a given
condition becomes true, irrespective of the number of clocks during
which the condition remains true.
.It Li inv
Invert the sense of comparision when the
.Li count
qualifier is present, making the counter to increment when the
number of events per cycle is less than the value specified by
the
.Li count
qualifier.
.It Li mask= Ns Ar qualifier
Many event specifiers for AMD K8 PMCs need to be additionally
qualified using a mask qualifier.
These additional qualifiers are event-specific and are documented
along with their associated event specifiers below.
.It Li os
Configure the PMC to count events happening at privilege level 0.
.It Li usr
Configure the PMC to count events occurring at privilege levels 1, 2
or 3.
.El
If neither of the
.Li os
or
.Li usr
qualifiers were specified, the default is to enable both.
.Pp
The event specifiers support on AMD K8 PMCs are:
.Bl -tag -width indent
.It Li k8-bu-cpu-clk-unhalted
Count the number of clock cycles when the CPU is not in the HLT or
STPCLK states.
.It Li k8-bu-fill-request-l2-miss Op Li ,mask= Ns Ar qualifier
Count fill requests that missed in the L2 cache.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li + Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li dc-fill
Count data cache fill requests.
.It Li ic-fill
Count instruction cache fill requests.
.It Li tlb-reload
Count TLB reloads.
.El
The default is to count all types of requests.
.It Li k8-bu-internal-l2-request Op Li ,mask= Ns Ar qualifier
Count internally generated requests to the L2 cache.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li cancelled
Count cancelled requests.
.It Li dc-fill
Count data cache fill requests.
.It Li ic-fill
Count instruction cache fill requests.
.It Li tag-snoop
Count tag snoop requests.
.It Li tlb-reload
Count TLB reloads.
.El
The default is to count all types of requests.
.It Li k8-dc-access
Count data cache accesses including microcode scratchpad accesses.
.It Li k8-dc-copyback Op Li ,mask= Ns Ar qualifier
Count data cache copyback operations.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "exclusive" -compact
.It Li exclusive
Count operations for lines in the
.Dq exclusive
state.
.It Li invalid
Count operations for lines in the
.Dq invalid
state.
.It Li modified
Count operations for lines in the
.Dq modified
state.
.It Li owner
Count operations for lines in the
.Dq owner
state.
.It Li shared
Count operations for lines in the
.Dq shared
state.
.El
The default is to count operations for lines in all the
above states.
.It Li k8-dc-dcache-accesses-by-locks Op Li ,mask= Ns Ar qualifier
Count data cache accesses by lock instructions.
This event is only available on processors of revision C or later
vintage.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "exclusive" -compact
.It Li accesses
Count data cache accesses by lock instructions.
.It Li misses
Count data cache misses by lock instructions.
.El
The default is to count all accesses.
.It Li k8-dc-dispatched-prefetch-instructions Op Li ,mask= Ns Ar qualifier
Count the number of dispatched prefetch instructions.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "exclusive" -compact
.It Li load
Count load operations.
.It Li nta
Count non-temporal operations.
.It Li store
Count store operations.
.El
The default is to count all operations.
.It Li k8-dc-l1-dtlb-miss-and-l2-dtlb-hit
Count L1 DTLB misses that are L2 DTLB hits.
.It Li k8-dc-l1-dtlb-miss-and-l2-dtlb-miss
Count L1 DTLB misses that are also misses in the L2 DTLB.
.It Li k8-dc-microarchitectural-early-cancel-of-an-access
Count microarchitectural early cancels of data cache accesses.
.It Li k8-dc-microarchitectural-late-cancel-of-an-access
Count microarchitectural late cancels of data cache accesses.
.It Li k8-dc-misaligned-data-reference
Count misaligned data references.
.It Li k8-dc-miss
Count data cache misses.
.It Li k8-dc-one-bit-ecc-error Op Li ,mask= Ns Ar qualifier
Count one bit ECC errors found by the scrubber.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "piggyback" -compact
.It Li scrubber
Count scrubber detected errors.
.It Li piggyback
Count piggyback scrubber errors.
.El
The default is to count both kinds of errors.
.It Li k8-dc-refill-from-l2 Op Li ,mask= Ns Ar qualifier
Count data cache refills from L2 cache.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "exclusive" -compact
.It Li exclusive
Count operations for lines in the
.Dq exclusive
state.
.It Li invalid
Count operations for lines in the
.Dq invalid
state.
.It Li modified
Count operations for lines in the
.Dq modified
state.
.It Li owner
Count operations for lines in the
.Dq owner
state.
.It Li shared
Count operations for lines in the
.Dq shared
state.
.El
The default is to count operations for lines in all the
above states.
.It Li k8-dc-refill-from-system Op Li ,mask= Ns Ar qualifier
Count data cache refills from system memory.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "exclusive" -compact
.It Li exclusive
Count operations for lines in the
.Dq exclusive
state.
.It Li invalid
Count operations for lines in the
.Dq invalid
state.
.It Li modified
Count operations for lines in the
.Dq modified
state.
.It Li owner
Count operations for lines in the
.Dq owner
state.
.It Li shared
Count operations for lines in the
.Dq shared
state.
.El
The default is to count operations for lines in all the
above states.
.It Li k8-fp-dispatched-fpu-ops Op Li ,mask= Ns Ar qualifier
Count the number of dispatched FPU ops.
This event is supported in revision B and later CPUs.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li add-pipe-excluding-junk-ops
Count add pipe ops excluding junk ops.
.It Li add-pipe-junk-ops
Count junk ops in the add pipe.
.It Li multiply-pipe-excluding-junk-ops
Count multiply pipe ops excluding junk ops.
.It Li multiply-pipe-junk-ops
Count junk ops in the multiply pipe.
.It Li store-pipe-excluding-junk-ops
Count store pipe ops excluding junk ops
.It Li store-pipe-junk-ops
Count junk ops in the store pipe.
.El
The default is to count all types of ops.
.It Li k8-fp-cycles-with-no-fpu-ops-retired
Count cycles when no FPU ops were retired.
This event is supported in revision B and later CPUs.
.It Li k8-fp-dispatched-fpu-fast-flag-ops
Count dispatched FPU ops that use the fast flag interface.
This event is supported in revision B and later CPUs.
.It Li k8-fr-decoder-empty
Count cycles when there was nothing to dispatch (i.e., the decoder
was empty).
.It Li k8-fr-dispatch-stalls
Count all dispatch stalls.
.It Li k8-fr-dispatch-stall-for-segment-load
Count dispatch stalls for segment loads.
.It Li k8-fr-dispatch-stall-for-serialization
Count dispatch stalls for serialization.
.It Li k8-fr-dispatch-stall-from-branch-abort-to-retire
Count dispatch stalls from branch abort to retiral.
.It Li k8-fr-dispatch-stall-when-fpu-is-full
Count dispatch stalls when the FPU is full.
.It Li k8-fr-dispatch-stall-when-ls-is-full
Count dispatch stalls when the load/store unit is full.
.It Li k8-fr-dispatch-stall-when-reorder-buffer-is-full
Count dispatch stalls when the reorder buffer is full.
.It Li k8-fr-dispatch-stall-when-reservation-stations-are-full
Count dispatch stalls when reservation stations are full.
.It Li k8-fr-dispatch-stall-when-waiting-for-all-to-be-quiet
Count dispatch stalls when waiting for all to be quiet.
.\" XXX What does "waiting for all to be quiet" mean?
.It Li k8-fr-dispatch-stall-when-waiting-far-xfer-or-resync-branch-pending
Count dispatch stalls when a far control transfer or a resync branch
is pending.
.It Li k8-fr-fpu-exceptions Op Li ,mask= Ns Ar qualifier
Count FPU exceptions.
This event is supported in revision B and later CPUs.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li sse-and-x87-microtraps
Count SSE and x87 microtraps.
.It Li sse-reclass-microfaults
Count SSE reclass microfaults
.It Li sse-retype-microfaults
Count SSE retype microfaults
.It Li x87-reclass-microfaults
Count x87 reclass microfaults.
.El
The default is to count all types of exceptions.
.It Li k8-fr-interrupts-masked-cycles
Count cycles when interrupts were masked (by CPU RFLAGS field IF was zero).
.It Li k8-fr-interrupts-masked-while-pending-cycles
Count cycles while interrupts were masked while pending (i.e., cycles
when INTR was asserted while CPU RFLAGS field IF was zero).
.It Li k8-fr-number-of-breakpoints-for-dr0
Count the number of breakpoints for DR0.
.It Li k8-fr-number-of-breakpoints-for-dr1
Count the number of breakpoints for DR1.
.It Li k8-fr-number-of-breakpoints-for-dr2
Count the number of breakpoints for DR2.
.It Li k8-fr-number-of-breakpoints-for-dr3
Count the number of breakpoints for DR3.
.It Li k8-fr-retired-branches
Count retired branches including exceptions and interrupts.
.It Li k8-fr-retired-branches-mispredicted
Count mispredicted retired branches.
.It Li k8-fr-retired-far-control-transfers
Count retired far control transfers (which are always mispredicted).
.It Li k8-fr-retired-fastpath-double-op-instructions Op Li ,mask= Ns Ar qualifier
Count retired fastpath double op instructions.
This event is supported in revision B and later CPUs.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXXXX" -compact
.It Li low-op-pos-0
Count instructions with the low op in position 0.
.It Li low-op-pos-1
Count instructions with the low op in position 1.
.It Li low-op-pos-2
Count instructions with the low op in position 2.
.El
The default is to count all types of instructions.
.It Li k8-fr-retired-fpu-instructions Op Li ,mask= Ns Ar qualifier
Count retired FPU instructions.
This event is supported in revision B and later CPUs.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li mmx-3dnow
Count MMX and 3DNow! instructions.
.It Li packed-sse-sse2
Count packed SSE and SSE2 instructions.
.It Li scalar-sse-sse2
Count scalar SSE and SSE2 instructions
.It Li x87
Count x87 instructions.
.El
The default is to count all types of instructions.
.It Li k8-fr-retired-near-returns
Count retired near returns.
.It Li k8-fr-retired-near-returns-mispredicted
Count mispredicted near returns.
.It Li k8-fr-retired-resyncs
Count retired resyncs (non-control transfer branches).
.It Li k8-fr-retired-taken-hardware-interrupts
Count retired taken hardware interrupts.
.It Li k8-fr-retired-taken-branches
Count retired taken branches.
.It Li k8-fr-retired-taken-branches-mispredicted
Count retired taken branches that were mispredicted.
.It Li k8-fr-retired-taken-branches-mispredicted-by-addr-miscompare
Count retired taken branches that were mispredicted only due to an
address miscompare.
.It Li k8-fr-retired-uops
Count retired uops.
.It Li k8-fr-retired-x86-instructions
Count retired x86 instructions including exceptions and interrupts.
.It Li k8-ic-fetch
Count instruction cache fetches.
.It Li k8-ic-instruction-fetch-stall
Count cycles in stalls due to instruction fetch.
.It Li k8-ic-l1-itlb-miss-and-l2-itlb-hit
Count L1 ITLB misses that are L2 ITLB hits.
.It Li k8-ic-l1-itlb-miss-and-l2-itlb-miss
Count ITLB misses that miss in both L1 and L2 ITLBs.
.It Li k8-ic-microarchitectural-resync-by-snoop
Count microarchitectural resyncs caused by snoops.
.It Li k8-ic-miss
Count instruction cache misses.
.It Li k8-ic-refill-from-l2
Count instruction cache refills from L2 cache.
.It Li k8-ic-refill-from-system
Count instruction cache refills from system memory.
.It Li k8-ic-return-stack-hits
Count hits to the return stack.
.It Li k8-ic-return-stack-overflow
Count overflows of the return stack.
.It Li k8-ls-buffer2-full
Count load/store buffer2 full events.
.It Li k8-ls-locked-operation Op Li ,mask= Ns Ar qualifier
Count locked operations.
For revision C and later CPUs, the following qualifiers are supported:
.Bl -tag -width "XXXXXXXXXXXXX" -compact
.It Li cycles-in-request
Count the number of cycles in the lock request/grant stage.
.It Li cycles-to-complete
Count the number of cycles a lock takes to complete once it is
non-speculative and is the older load/store operation.
.It Li locked-instructions
Count the number of lock instructions executed.
.El
The default is to count the number of lock instructions executed.
.It Li k8-ls-microarchitectural-late-cancel
Count microarchitectural late cancels of operations in the load/store
unit.
.It Li k8-ls-microarchitectural-resync-by-self-modifying-code
Count microarchitectural resyncs caused by self-modifying code.
.It Li k8-ls-microarchitectural-resync-by-snoop
Count microarchitectural resyncs caused by snoops.
.It Li k8-ls-retired-cflush-instructions
Count retired CFLUSH instructions.
.It Li k8-ls-retired-cpuid-instructions
Count retired CPUID instructions.
.It Li k8-ls-segment-register-load Op Li ,mask= Ns Ar qualifier
Count segment register loads.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XX" -compact
.It Li cs
Count CS register loads.
.It Li ds
Count DS register loads.
.It Li es
Count ES register loads.
.It Li fs
Count FS register loads.
.It Li gs
Count GS register loads.
.\" .It Ic hs
.\" Count HS register loads.
.\" XXX "HS" register?
.It Li ss
Count SS register loads.
.El
The default is to count all types of loads.
.It Li k8-nb-memory-controller-bypass-saturation Op Li ,mask= Ns Ar qualifier
Count memory controller bypass counter saturation events.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li dram-controller-interface-bypass
Count DRAM controller interface bypass.
.It Li dram-controller-queue-bypass
Count DRAM controller queue bypass.
.It Li memory-controller-hi-pri-bypass
Count memory controller high priority bypasses.
.It Li memory-controller-lo-pri-bypass
Count memory controller low priority bypasses.
.El
.It Li k8-nb-memory-controller-dram-slots-missed
Count memory controller DRAM command slots missed (in MemClks).
.It Li k8-nb-memory-controller-page-access-event Op Li ,mask= Ns Ar qualifier
Count memory controller page access events.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li page-conflict
Count page conflicts.
.It Li page-hit
Count page hits.
.It Li page-miss
Count page misses.
.El
The default is to count all types of events.
.It Li k8-nb-memory-controller-page-table-overflow
Count memory control page table overflow events.
.It Li k8-nb-probe-result Op Li ,mask= Ns Ar qualifier
Count probe events.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "exclusive" -compact
.It Li probe-hit
Count all probe hits.
.It Li probe-hit-dirty-no-memory-cancel
Count probe hits without memory cancels.
.It Li probe-hit-dirty-with-memory-cancel
Count probe hits with memory cancels.
.It Li probe-miss
Count probe misses.
.El
.It Li k8-nb-sized-commands Op Li ,mask= Ns Ar qualifier
Count sized commands issued.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "exclusive" -compact
.It Li nonpostwrszbyte
.It Li nonpostwrszdword
.It Li postwrszbyte
.It Li postwrszdword
.It Li rdszbyte
.It Li rdszdword
.It Li rdmodwr
.El
The default is to count all types of commands.
.It Li k8-nb-memory-controller-turnaround Op Li ,mask= Ns Ar qualifier
Count memory control turnaround events.
This event may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.\" XXX doc is unclear whether these are cycle counts or event counts
.It Li dimm-turnaround
Count DIMM turnarounds.
.It Li read-to-write-turnaround
Count read to write turnarounds.
.It Li write-to-read-turnaround
Count write to read turnarounds.
.El
The default is to count all types of events.
.It Li k8-nb-ht-bus0-bandwidth Op Li ,mask= Ns Ar qualifier
.It Li k8-nb-ht-bus1-bandwidth Op Li ,mask= Ns Ar qualifier
.It Li k8-nb-ht-bus2-bandwidth Op Li ,mask= Ns Ar qualifier
Count events on the HyperTransport(tm) buses.
These events may be further qualified using
.Ar qualifier ,
which is a
.Li "+" Ns - Ns
separated set of the following keywords:
.Bl -tag -width "XXXXXXXXXX" -compact
.It Li buffer-release
Count buffer release messages sent.
.It Li command
Count command messages sent.
.It Li data
Count data messages sent.
.It Li nop
Count nop messages sent.
.El
The default is to count all types of messages.
.El
.Ss Intel P6 PMCS
Intel P6 PMCs are present in Intel
.Tn "Pentium Pro" ,
.Tn "Pentium II" ,
.Tn "Celeron" ,
.Tn "Pentium III"
and
.Tn "Pentium M"
processors.
.Pp
These CPUs have two counters.
Some events may only be used on specific counters and some events are
defined only on specific processor models.
.Pp
These PMCs are documented in
.Rs
.%B "IA-32 Intel(R) Architecture Software Developer's Manual"
.%T "Volume 3: System Programming Guide"
.%N "Order Number 245472-012"
.%D 2003
.%Q "Intel Corporation"
.Re
.Pp
Some of these events are affected by processor errata described in
.Rs
.%B "Intel(R) Pentium(R) III Processor Specification Update"
.%N "Document Number: 244453-054"
.%D "April 2005"
.%Q "Intel Corporation"
.Re
.Pp
Event specifiers for Intel P6 PMCs can have the following common
qualifiers:
.Bl -tag -width indent
.It Li cmask= Ns Ar value
Configure the PMC to increment only if the number of configured
events measured in a cycle is greater than or equal to
.Ar value .
.It Li edge
Configure the PMC to count the number of deasserted to asserted
transitions of the conditions expressed by the other qualifiers.
If specified, the counter will increment only once whenever a
condition becomes true, irrespective of the number of clocks during
which the condition remains true.
.It Li inv
Invert the sense of comparision when the
.Ar cmask
qualifier is present, making the counter increment when the number of
events per cycle is less than the value specified by the
.Ar cmask
qualifier.
.It Li os
Configure the PMC to count events happening at processor privilege
level 0.
.It Li umask= Ns Ar value
This qualifier is used to further qualify the event selected (see
below).
.It Li usr
Configure the PMC to count events occurring at privilege levels 1, 2
or 3.
.El
If neither of the
.Li os
or
.Li usr
qualifiers are specified, the default is to enable both.
.Pp
The event specifiers supported by Intel P6 PMCs are:
.Bl -tag -width indent
.It Li p6-baclears
Count the number of times a static branch prediction was made by the
branch decoder because the BTB did not have a prediction.
.It Li p6-br-bac-missp-exec
.Pq Tn "Pentium M"
Count the number of branch instructions executed that where
mispredicted at the Front End (BAC).
.It Li p6-br-bogus
Count the number of bogus branches.
.It Li p6-br-call-exec
.Pq Tn "Pentium M"
Count the number of call instructions executed.
.It Li p6-br-call-missp-exec
.Pq Tn "Pentium M"
Count the number of call instructions executed that were mispredicted.
.It Li p6-br-cnd-exec
.Pq Tn "Pentium M"
Count the number of conditional branch instructions executed.
.It Li p6-br-cnd-missp-exec
.Pq Tn "Pentium M"
Count the number of conditional branch instructions executed that were
mispredicted.
.It Li p6-br-ind-call-exec
.Pq Tn "Pentium M"
Count the number of indirect call instructions executed.
.It Li p6-br-ind-exec
.Pq Tn "Pentium M"
Count the number of indirect branch instructions executed.
.It Li p6-br-ind-missp-exec
.Pq Tn "Pentium M"
Count the number of indirect branch instructions executed that were
mispredicted.
.It Li p6-br-inst-decoded
Count the number of branch instructions decoded.
.It Li p6-br-inst-exec
.Pq Tn "Pentium M"
Count the number of branch instructions executed but necessarily retired.
.It Li p6-br-inst-retired
Count the number of branch instructions retired.
.It Li p6-br-miss-pred-retired
Count the number of mispredicted branch instructions retired.
.It Li p6-br-miss-pred-taken-ret
Count the number of taken mispredicted branches retired.
.It Li p6-br-missp-exec
.Pq Tn "Pentium M"
Count the number of branch instructions executed that were
mispredicted at execution.
.It Li p6-br-ret-bac-missp-exec
.Pq Tn "Pentium M"
Count the number of return instructions executed that were
mispredicted at the Front End (BAC).
.It Li p6-br-ret-exec
.Pq Tn "Pentium M"
Count the number of return instructions executed.
.It Li p6-br-ret-missp-exec
.Pq Tn "Pentium M"
Count the number of return instructions executed that were
mispredicted at execution.
.It Li p6-br-taken-retired
Count the number of taken branches retired.
.It Li p6-btb-misses
Count the number of branches for which the BTB did not produce a
prediction.
.It Li p6-bus-bnr-drv
Count the number of bus clock cycles during which this processor is
driving the BNR# pin.
.It Li p6-bus-data-rcv
Count the number of bus clock cycles during which this processor is
receiving data.
.It Li p6-bus-drdy-clocks Op Li ,umask= Ns Ar qualifier
Count the number of clocks during which DRDY# is asserted.
An additional qualifier may be specified, and comprises one of the
following keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-hit-drv
Count the number of bus clock cycles during which this processor is
driving the HIT# pin.
.It Li p6-bus-hitm-drv
Count the number of bus clock cycles during which this processor is
driving the HITM# pin.
.It Li p6-bus-lock-clocks Op Li ,umask= Ns Ar qualifier
Count the number of clocks during with LOCK# is asserted on the
external system bus.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-req-outstanding
Count the number of bus requests outstanding in any given cycle.
.It Li p6-bus-snoop-stall
Count the number of clock cycles during which the bus is snoop stalled.
.It Li p6-bus-tran-any Op Li ,umask= Ns Ar qualifier
Count the number of completed bus transactions of any kind.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-brd Op Li ,umask= Ns Ar qualifier
Count the number of burst read transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-burst Op Li ,umask= Ns Ar qualifier
Count the number of completed burst transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-def Op Li ,umask= Ns Ar qualifier
Count the number of completed deferred transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-ifetch Op Li ,umask= Ns Ar qualifier
Count the number of completed instruction fetch transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-inval Op Li ,umask= Ns Ar qualifier
Count the number of completed invalidate transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-mem Op Li ,umask= Ns Ar qualifier
Count the number of completed memory transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-pwr Op Li ,umask= Ns Ar qualifier
Count the number of completed partial write transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-tran-rfo Op Li ,umask= Ns Ar qualifier
Count the number of completed read-for-ownership transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-trans-io Op Li ,umask= Ns Ar qualifier
Count the number of completed I/O transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-trans-p Op Li ,umask= Ns Ar qualifier
Count the number of completed partial transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-bus-trans-wb Op Li ,umask= Ns Ar qualifier
Count the number of completed write-back transactions.
An additional qualifier may be specified and comprises one of the following
keywords:
.Bl -tag -width indent -compact
.It Li any
Count transactions generated by any agent on the bus.
.It Li self
Count transactions generated by this processor.
.El
The default is to count operations generated by this processor.
.It Li p6-cpu-clk-unhalted
Count the number of cycles during with the processor was not halted.
.Pp
.Pq Tn "Pentium M"
Count the number of cycles during with the processor was not halted
and not in a thermal trip.
.It Li p6-cycles-div-busy
Count the number of cycles during which the divider is busy and cannot
accept new divides.
This event is only allocated on counter 0.
.It Li p6-cycles-in-pending-and-masked
Count the number of processor cycles for which interrupts were
disabled and interrupts were pending.
.It Li p6-cycles-int-masked
Count the number of processor cycles for which interrupts were
disabled.
.It Li p6-data-mem-refs
Count all loads and all stores using any memory type, including
internal retries.
Each part of a split store is counted seperately.
.It Li p6-dcu-lines-in
Count the total lines allocated in the data cache unit.
.It Li p6-dcu-m-lines-in
Count the number of M state lines allocated in the data cache unit.
.It Li p6-dcu-m-lines-out
Count the number of M state lines evicted from the data cache unit.
.It Li p6-dcu-miss-outstanding
Count the weighted number of cycles while a data cache unit miss is
outstanding, incremented by the number of outstanding cache misses at
any time.
.It Li p6-div
Count the number of floating point multiplies.
This event is only allocated on counter 1.
.It Li p6-emon-esp-uops
.Pq Tn "Pentium M"
Count the total number of micro-ops.
.It Li p6-emon-est-trans Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium M"
Count the number of
.Tn "Enhanced Intel SpeedStep"
transitions.
An additional qualifier may be specified, and can be one of the
following keywords:
.Bl -tag -width indent -compact
.It Li all
Count all transitions.
.It Li freq
Count only frequency transitions.
.El
The default is to count all transitions.
.It Li p6-emon-fused-uops-ret Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium M"
Count the number of retired fused micro-ops.
An additional qualifier may be specified, and may be one of the
following keywords:
.Bl -tag -width indent -compact
.It Li all
Count all fused micro-ops.
.It Li loadop
Count only load and op micro-ops.
.It Li stdsta
Count only STD/STA micro-ops.
.El
The default is to count all fused micro-ops.
.It Li p6-emon-kni-comp-inst-ret
.Pq Tn "Pentium III"
Count the number of SSE computational instructions retired.
An additional qualifier may be specified, and comprises one of the
following keywords:
.Bl -tag -width indent -compact
.It Li packed-and-scalar
Count packed and scalar operations.
.It Li scalar
Count scalar operations only.
.El
The default is to count packed and scalar operations.
.It Li p6-emon-kni-inst-retired Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium III"
Count the number of SSE instructions retired.
An additional qualifier may be specified, and comprises one of the
following keywords:
.Bl -tag -width indent -compact
.It Li packed-and-scalar
Count packed and scalar operations.
.It Li scalar
Count scalar operations only.
.El
The default is to count packed and scalar operations.
.It Li p6-emon-kni-pref-dispatched Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium III"
Count the number of SSE prefetch or weakly ordered instructions
dispatched (including speculative prefetches).
An additional qualifier may be specified, and comprises one of the
following keywords:
.Bl -tag -width indent -compact
.It Li nta
Count non-temporal prefetches.
.It Li t1
Count prefetches to L1.
.It Li t2
Count prefetches to L2.
.It Li wos
Count weakly ordered stores.
.El
The default is to count non-temporal prefetches.
.It Li p6-emon-kni-pref-miss Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium III"
Count the number of prefetch or weakly ordered instructions that miss
all caches.
An additional qualifier may be specified, and comprises one of the
following keywords:
.Bl -tag -width indent -compact
.It Li nta
Count non-temporal prefetches.
.It Li t1
Count prefetches to L1.
.It Li t2
Count prefetches to L2.
.It Li wos
Count weakly ordered stores.
.El
The default is to count non-temporal prefetches.
.It Li p6-emon-pref-rqsts-dn
.Pq Tn "Pentium M"
Count the number of downward prefetches issued.
.It Li p6-emon-pref-rqsts-up
.Pq Tn "Pentium M"
Count the number of upward prefetches issued.
.It Li p6-emon-simd-instr-retired
.Pq Tn "Pentium M"
Count the number of retired
.Tn MMX
instructions.
.It Li p6-emon-sse-sse2-comp-inst-retired Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium M"
Count the number of computational SSE instructions retired.
An additional qualifier may be specified and can be one of the
following keywords:
.Bl -tag -width indent -compact
.It Li sse-packed-single
Count SSE packed-single instructions.
.It Li sse-scalar-single
Count SSE scalar-single instructions.
.It Li sse2-packed-double
Count SSE2 packed-double instructions.
.It Li sse2-scalar-double
Count SSE2 scalar-double instructions.
.El
The default is to count SSE packed-single instructions.
.It Li p6-emon-sse-sse2-inst-retired Op Li ,umask= Ns Ar qualifer
.Pp
.Pq Tn "Pentium M"
Count the number of SSE instructions retired.
An additional qualifier can be specified, and can be one of the
following keywords:
.Bl -tag -width indent -compact
.It Li sse-packed-single
Count SSE packed-single instructions.
.It Li sse-packed-single-scalar-single
Count SSE packed-single and scalar-single instructions.
.It Li sse2-packed-double
Count SSE2 packed-double instructions.
.It Li sse2-scalar-double
Count SSE2 scalar-double instructions.
.El
The default is to count SSE packed-single instructions.
.It Li p6-emon-synch-uops
.Pq Tn "Pentium M"
Count the number of sync micro-ops.
.It Li p6-emon-thermal-trip
.Pq Tn "Pentium M"
Count the duration or occurrences of thermal trips.
Use the
.Ar edge
qualifier to count occurrences of thermal trips.
.It Li p6-emon-unfusion
.Pq Tn "Pentium M"
Count the number of unfusion events in the reorder buffer.
.It Li p6-flops
Count the number of computational floating point operations retired.
This event is only allocated on counter 0.
.It Li p6-fp-assist
Count the number of floating point exceptions handled by microcode.
This event is only allocated on counter 1.
.It Li p6-fp-comps-ops-exe
Count the number of computation floating point operations executed.
This event is only allocated on counter 0.
.It Li p6-fp-mmx-trans Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of transitions between MMX and floating-point
instructions.
An additional qualifier may be specified, and comprises one of the
following keywords:
.Bl -tag -width indent -compact
.It Li mmxtofp
Count transitions from MMX instructions to floating-point instructions.
.It Li fptommx
Count transitions from floating-point instructions to MMX instructions.
.El
The default is to count MMX to floating-point transitions.
.It Li p6-hw-int-rx
Count the number of hardware interrupts received.
.It Li p6-ifu-fetch
Count the number of instruction fetches, both cacheable and non-cacheable.
.It Li p6-ifu-fetch-miss
Count the number of instruction fetch misses (i.e., those that produce
memory accesses).
.It Li p6-ifu-mem-stall
Count the number of cycles instruction fetch is stalled for any reason.
.It Li p6-ild-stall
Count the number of cycles the instruction length decoder is stalled.
.It Li p6-inst-decoded
Count the number of instructions decoded.
.It Li p6-inst-retired
Count the number of instructions retired.
.It Li p6-itlb-miss
Count the number of instruction TLB misses.
.It Li p6-l2-ads
Count the number of L2 address strobes.
.It Li p6-l2-dbus-busy
Count the number of cycles during which the L2 cache data bus was busy.
.It Li p6-l2-dbus-busy-rd
Count the number of cycles during which the L2 cache data bus was busy
transferring read data from L2 to the processor.
.It Li p6-l2-ifetch Op Li ,umask= Ns Ar qualifier
Count the number of L2 instruction fetches.
An additional qualifier may be specified and comprises a list of the following
keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li e
Count operations affecting E (exclusive) state lines.
.It Li i
Count operations affecting I (invalid) state lines.
.It Li m
Count operations affecting M (modified) state lines.
.It Li s
Count operations affecting S (shared) state lines.
.El
The default is to count operations affecting all (MESI) state lines.
.It Li p6-l2-ld Op Li ,umask= Ns Ar qualifier
Count the number of L2 data loads.
An additional qualifier may be specified and comprises a list of the following
keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li both
.Pq Tn "Pentium M"
Count both hardware-prefetched lines and non-hardware-prefetched lines.
.It Li e
Count operations affecting E (exclusive) state lines.
.It Li hw
.Pq Tn "Pentium M"
Count hardware-prefetched lines only.
.It Li i
Count operations affecting I (invalid) state lines.
.It Li m
Count operations affecting M (modified) state lines.
.It Li nonhw
.Pq Tn "Pentium M"
Exclude hardware-prefetched lines.
.It Li s
Count operations affecting S (shared) state lines.
.El
The default on processors other than
.Tn "Pentium M"
processors is to count operations affecting all (MESI) state lines.
The default on
.Tn "Pentium M"
processors is to count both hardware-prefetched and
non-hardware-prefetch operations on all (MESI) state lines.
.Pq Errata
This event is affected by processor errata E53.
.It Li p6-l2-lines-in Op Li ,umask= Ns Ar qualifier
Count the number of L2 lines allocated.
An additional qualifier may be specified and comprises a list of the following
keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li both
.Pq Tn "Pentium M"
Count both hardware-prefetched lines and non-hardware-prefetched lines.
.It Li e
Count operations affecting E (exclusive) state lines.
.It Li hw
.Pq Tn "Pentium M"
Count hardware-prefetched lines only.
.It Li i
Count operations affecting I (invalid) state lines.
.It Li m
Count operations affecting M (modified) state lines.
.It Li nonhw
.Pq Tn "Pentium M"
Exclude hardware-prefetched lines.
.It Li s
Count operations affecting S (shared) state lines.
.El
The default on processors other than
.Tn "Pentium M"
processors is to count operations affecting all (MESI) state lines.
The default on
.Tn "Pentium M"
processors is to count both hardware-prefetched and
non-hardware-prefetch operations on all (MESI) state lines.
.Pq Errata
This event is affected by processor errata E45.
.It Li p6-l2-lines-out Op Li ,umask= Ns Ar qualifier
Count the number of L2 lines evicted.
An additional qualifier may be specified and comprises a list of the following
keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li both
.Pq Tn "Pentium M"
Count both hardware-prefetched lines and non-hardware-prefetched lines.
.It Li e
Count operations affecting E (exclusive) state lines.
.It Li hw
.Pq Tn "Pentium M"
Count hardware-prefetched lines only.
.It Li i
Count operations affecting I (invalid) state lines.
.It Li m
Count operations affecting M (modified) state lines.
.It Li nonhw
.Pq Tn "Pentium M" only
Exclude hardware-prefetched lines.
.It Li s
Count operations affecting S (shared) state lines.
.El
The default on processors other than
.Tn "Pentium M"
processors is to count operations affecting all (MESI) state lines.
The default on
.Tn "Pentium M"
processors is to count both hardware-prefetched and
non-hardware-prefetch operations on all (MESI) state lines.
.Pq Errata
This event is affected by processor errata E45.
.It Li p6-l2-m-lines-inm
Count the number of modified lines allocated in L2 cache.
.It Li p6-l2-m-lines-outm Op Li ,umask= Ns Ar qualifier
Count the number of L2 M-state lines evicted.
.Pp
.Pq Tn "Pentium M"
On these processors an additional qualifier may be specified and
comprises a list of the following keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li both
Count both hardware-prefetched lines and non-hardware-prefetched lines.
.It Li hw
Count hardware-prefetched lines only.
.It Li nonhw
Exclude hardware-prefetched lines.
.El
The default is to count both hardware-prefetched and
non-hardware-prefetch operations.
.Pq Errata
This event is affected by processor errata E53.
.It Li p6-l2-rqsts Op Li ,umask= Ns Ar qualifier
Count the total number of L2 requests.
An additional qualifier may be specified and comprises a list of the following
keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li e
Count operations affecting E (exclusive) state lines.
.It Li i
Count operations affecting I (invalid) state lines.
.It Li m
Count operations affecting M (modified) state lines.
.It Li s
Count operations affecting S (shared) state lines.
.El
The default is to count operations affecting all (MESI) state lines.
.It Li p6-l2-st
Count the number of L2 data stores.
An additional qualifier may be specified and comprises a list of the following
keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li e
Count operations affecting E (exclusive) state lines.
.It Li i
Count operations affecting I (invalid) state lines.
.It Li m
Count operations affecting M (modified) state lines.
.It Li s
Count operations affecting S (shared) state lines.
.El
The default is to count operations affecting all (MESI) state lines.
.It Li p6-ld-blocks
Count the number of load operations delayed due to store buffer blocks.
.It Li p6-misalign-mem-ref
Count the number of misaligned data memory references (crossing a 64
bit boundary).
.It Li p6-mmx-assist
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of MMX assists executed.
.It Li p6-mmx-instr-exec
.Pq Tn "Celeron" , Tn "Pentium II"
Count the number of MMX instructions executed, except MOVQ and MOVD
stores from register to memory.
.It Li p6-mmx-instr-ret
.Pq Tn "Pentium II"
Count the number of MMX instructions retired.
.It Li p6-mmx-instr-type-exec Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of MMX instructions executed.
An additional qualifier may be specified and comprises a list of
the following keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li pack
Count MMX pack operation instructions.
.It Li packed-arithmetic
Count MMX packed arithmetic instructions.
.It Li packed-logical
Count MMX packed logical instructions.
.It Li packed-multiply
Count MMX packed multiply instructions.
.It Li packed-shift
Count MMX packed shift instructions.
.It Li unpack
Count MMX unpack operation instructions.
.El
The default is to count all operations.
.It Li p6-mmx-sat-instr-exec
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of MMX saturating instructions executed.
.It Li p6-mmx-uops-exec
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of MMX micro-ops executed.
.It Li p6-mul
Count the number of floating point multiplies.
This event is only allocated on counter 1.
.It Li p6-partial-rat-stalls
Count the number of cycles or events for partial stalls.
.It Li p6-resource-stalls
Count the number of cycles there was a resource related stall of any kind.
.It Li p6-ret-seg-renames
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of segment register rename events retired.
.It Li p6-sb-drains
Count the number of cycles the store buffer is draining.
.It Li p6-seg-reg-renames Op Li ,umask= Ns Ar qualifier
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of segment register renames.
An additional qualifier may be specified, and comprises a list of the
following keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li ds
Count renames for segment register DS.
.It Li es
Count renames for segment register ES.
.It Li fs
Count renames for segment register FS.
.It Li gs
Count renames for segment register GS.
.El
The default is to count operations affecting all segment registers.
.It Li p6-seg-rename-stalls
.Pq Tn "Pentium II" , Tn "Pentium III"
Count the number of segment register renaming stalls.
An additional qualifier may be specified, and comprises a list of the
following keywords separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li ds
Count stalls for segment register DS.
.It Li es
Count stalls for segment register ES.
.It Li fs
Count stalls for segment register FS.
.It Li gs
Count stalls for segment register GS.
.El
The default is to count operations affecting all the segment registers.
.It Li p6-segment-reg-loads
Count the number of segment register loads.
.It Li p6-uops-retired
Count the number of micro-ops retired.
.El
.Ss Intel P4 PMCS
Intel P4 PMCs are present in Intel
.Tn "Pentium 4"
and
.Tn Xeon
processors.
These PMCs are documented in
.Rs
.%B "IA-32 Intel(R) Architecture Software Developer's Manual"
.%T "Volume 3: System Programming Guide"
.%N "Order Number 245472-012"
.%D 2003
.%Q "Intel Corporation"
.Re
Further information about using these PMCs may be found in
.Rs
.%B "IA-32 Intel(R) Architecture Optimization Guide"
.%D 2003
.%N "Order Number 248966-009"
.%Q "Intel Corporation"
.Re
Some of these events are affected by processor errata described in
.Rs
.%B "Intel(R) Pentium(R) 4 Processor Specification Update"
.%N "Document Number: 249199-059"
.%D "April 2005"
.%Q "Intel Corporation"
.Re
.Pp
Event specifiers for Intel P4 PMCs can have the following common
qualifiers:
.Bl -tag -width indent
.It Li active= Ns Ar choice
(On P4 HTT CPUs) Filter event counting based on which logical
processors are active.
The allowed values of
.Ar choice
are:
.Bl -tag -width indent -compact
.It Li any
Count when either logical processor is active.
.It Li both
Count when both logical processors are active.
.It Li none
Count only when neither logical processor is active.
.It Li single
Count only when one logical processor is active.
.El
The default is
.Li both .
.It Li cascade
Configure the PMC to cascade onto its partner.
The PMC for the partner must already have been allocated by the
current process.
See
.Sx "Cascading P4 PMCs"
below for more information.
.It Li edge
Configure the counter to count false to true transitions of the threshold
comparision output.
This qualifier only takes effect if a threshold qualifier has also been
specified.
.It Li complement
Configure the counter to increment only when the event count seen is
less than the threshold qualifier value specified.
.It Li mask= Ns Ar qualifier
Many event specifiers for Intel P4 PMCs need to be additionally
qualified using a mask qualifier.
The allowed syntax for these qualifiers is event specific and is
described along with the events.
.It Li os
Configure the PMC to count when the CPL of the processor is 0.
.It Li precise
Select precise event based sampling.
Precise sampling is supported by the hardware for a limited set of
events.
.It Li tag= Ns Ar value
Configure the PMC to tag the internal uop selected by the other
fields in this event specifier with value
.Ar value .
This feature is used when cascading PMCs.
.It Li threshold= Ns Ar value
Configure the PMC to increment only when the event counts seen are
greater than the specified threshold value
.Ar value .
.It Li usr
Configure the PMC to count when the CPL of the processor is 1, 2 or 3.
.El
If neither of the
.Li os
or
.Li usr
qualifiers are specified, the default is to enable both.
.Pp
On Intel Pentium 4 processors with HTT, events are
divided into two classes:
.Bl -tag -width "XXXXXXXXXX" -compact
.It "TS Events"
are those where hardware can differentiate between events
generated on one logical processor from those generated on the
other.
.It "TI Events"
are those where hardware cannot differentiate between events
generated by multiple logical processors in a package.
.El
Only TS events are allowed for use with process-mode PMCs on
Pentium-4/HTT CPUs.
.Pp
The event specifiers supported by Intel P4 PMCs are:
.Bl -tag -width indent
.It Li p4-128bit-mmx-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count integer SIMD SSE2 instructions that operate on 128 bit SIMD
operands.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count all uops operating on 128 bit SIMD integer operands in memory or
XMM register.
.El
If an instruction contains more than one 128 bit MMX uop, then each
uop will be counted.
.It Li p4-64bit-mmx-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count MMX instructions that operate on 64 bit SIMD operands.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count all uops operating on 64 bit SIMD integer operands in memory or
in MMX registers.
.El
If an instruction contains more than one 64 bit MMX uop, then each
uop will be counted.
.It Li p4-b2b-cycles
.Pq "TI event"
Count back-to-back bys cycles.
Further documentation for this event is unavailable.
.It Li p4-bnr
.Pq "TI event"
Count bus-not-ready conditions.
Further documentation for this event is unavailable.
.It Li p4-bpu-fetch-request Op Li ,mask= Ns Ar qualifier
.Pq "TS event"
Count instruction fetch requests qualified by additional
flags specified in
.Ar qualifier .
At this point only one flag is supported:
.Bl -tag -width indent -compact
.It Li tcmiss
Count trace cache lookup misses.
.El
The default qualifier is also
.Ar mask=tcmiss .
.It Li p4-branch-retired Op Li ,mask= Ns Ar flags
.Pq "TS event"
Counts retired branches.
Qualifier
.Ar flags
is a list of the following
.Li +
separated strings:
.Bl -tag -width indent -compact
.It Li mmnp
Count branches not-taken and predicted.
.It Li mmnm
Count branches not-taken and mis-predicted.
.It Li mmtp
Count branches taken and predicted.
.It Li mmtm
Count branches taken and mis-predicted.
.El
The default qualifier counts all four kinds of branches.
.It Li p4-bsq-active-entries Op Li ,mask= Ns Ar qualifier
.Pq "TS event"
Count the number of entries (clipped at 15) currently active in the
BSQ.
Qualifier
.Ar qualifier
is a
.Li +
separated set of the following flags:
.Bl -tag -width indent -compact
.It Li req-type0 , Li req-type1
Forms a 2-bit number used to select the request type encoding:
.Bl -tag -width indent -compact
.It Li 0
reads excluding read invalidate
.It Li 1
read invalidates
.It Li 2
writes other than writebacks
.It Li 3
writebacks
.El
Bit
.Li req-type1
is the MSB for this two bit number.
.It Li req-len0 , Li req-len1
Forms a two-bit number that specifies the request length encoding:
.Bl -tag -width indent -compact
.It Li 0
0 chunks
.It Li 1
1 chunk
.It Li 3
8 chunks
.El
Bit
.Li req-len1
is the MSB for this two bit number.
.It Li req-io-type
Count requests that are input or output requests.
.It Li req-lock-type
Count requests that lock the bus.
.It Li req-lock-cache
Count requests that lock the cache.
.It Li req-split-type
Count requests that is a bus 8-byte chunk that is split across an
8-byte boundary.
.It Li req-dem-type
Count requests that are demand (not prefetches) if set.
Count requests that are prefetches if not set.
.It Li req-ord-type
Count requests that are ordered.
.It Li mem-type0 , Li mem-type1 , Li mem-type2
Forms a 3-bit number that specifies a memory type encoding:
.Bl -tag -width indent -compact
.It Li 0
UC
.It Li 1
USWC
.It Li 4
WT
.It Li 5
WP
.It Li 6
WB
.El
Bit
.Li mem-type2
is the MSB of this 3-bit number.
.El
The default qualifier has all the above bits set.
.Pp
Edge triggering using the
.Li edge
qualifier should not be used with this event when counting cycles.
.It Li p4-bsq-allocation Op Li ,mask= Ns Ar qualifier
.Pq "TS event"
Count allocations in the bus sequence unit according to the flags
specified in
.Ar qualifier ,
which is a
.Li +
separated set of the following flags:
.Bl -tag -width indent -compact
.It Li req-type0 , Li req-type1
Forms a 2-bit number used to select the request type encoding:
.Bl -tag -width indent -compact
.It Li 0
reads excluding read invalidate
.It Li 1
read invalidates
.It Li 2
writes other than writebacks
.It Li 3
writebacks
.El
Bit
.Li req-type1
is the MSB for this two bit number.
.It Li req-len0 , Li req-len1
Forms a two-bit number that specifies the request length encoding:
.Bl -tag -width indent -compact
.It Li 0
0 chunks
.It Li 1
1 chunk
.It Li 3
8 chunks
.El
Bit
.Li req-len1
is the MSB for this two bit number.
.It Li req-io-type
Count requests that are input or output requests.
.It Li req-lock-type
Count requests that lock the bus.
.It Li req-lock-cache
Count requests that lock the cache.
.It Li req-split-type
Count requests that is a bus 8-byte chunk that is split across an
8-byte boundary.
.It Li req-dem-type
Count requests that are demand (not prefetches) if set.
Count requests that are prefetches if not set.
.It Li req-ord-type
Count requests that are ordered.
.It Li mem-type0 , Li mem-type1 , Li mem-type2
Forms a 3-bit number that specifies a memory type encoding:
.Bl -tag -width indent -compact
.It Li 0
UC
.It Li 1
USWC
.It Li 4
WT
.It Li 5
WP
.It Li 6
WB
.El
Bit
.Li mem-type2
is the MSB of this 3-bit number.
.El
The default qualifier has all the above bits set.
.Pp
This event is usually used along with the
.Li edge
qualifier to avoid multiple counting.
.It Li p4-bsq-cache-reference Op Li ,mask= Ns Ar qualifier
.Pq "TS event"
Count cache references as seen by the bus unit (2nd or 3rd level
cache references).
Qualifier
.Ar qualifier
is a
.Li +
separated list of the following keywords:
.Bl -tag -width indent -compact
.It Li rd-2ndl-hits
Count 2nd level cache hits in the shared state.
.It Li rd-2ndl-hite
Count 2nd level cache hits in the exclusive state.
.It Li rd-2ndl-hitm
Count 2nd level cache hits in the modified state.
.It Li rd-3rdl-hits
Count 3rd level cache hits in the shared state.
.It Li rd-3rdl-hite
Count 3rd level cache hits in the exclusive state.
.It Li rd-3rdl-hitm
Count 3rd level cache hits in the modified state.
.It Li rd-2ndl-miss
Count 2nd level cache misses.
.It Li rd-3rdl-miss
Count 3rd level cache misses.
.It Li wr-2ndl-miss
Count write-back lookups from the data access cache that miss the 2nd
level cache.
.El
The default is to count all the above events.
.It Li p4-execution-event Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count the retirement of tagged uops selected through the execution
tagging mechanism.
Qualifier
.Ar flags
can contain the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li nbogus0 , Li nbogus1 , Li nbogus2 , Li nbogus3
The marked uops are not bogus.
.It Li bogus0 , Li bogus1 , Li bogus2 , Li bogus3
The marked uops are bogus.
.El
This event requires additional (upstream) events to be allocated to
perform the desired uop tagging.
The default is to set all the above flags.
This event can be used for precise event based sampling.
.It Li p4-front-end-event Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count the retirement of tagged uops selected through the front-end
tagging mechanism.
Qualifier
.Ar flags
can contain the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li nbogus
The marked uops are not bogus.
.It Li bogus
The marked uops are bogus.
.El
This event requires additional (upstream) events to be allocated to
perform the desired uop tagging.
The default is to select both kinds of events.
This event can be used for precise event based sampling.
.It Li p4-fsb-data-activity Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count each DBSY or DRDY event selected by qualifier
.Ar flags .
Qualifier
.Ar flags
is a
.Li +
separated set of the following flags:
.Bl -tag -width indent -compact
.It Li drdy-drv
Count when this processor is driving data onto the bus.
.It Li drdy-own
Count when this processor is reading data from the bus.
.It Li drdy-other
Count when data is on the bus but not being sampled by this processor.
.It Li dbsy-drv
Count when this processor reserves the bus for use in the next cycle
in order to drive data.
.It Li dbsy-own
Count when some agent reserves the bus for use in the next bus cycle
to drive data that this processor will sample.
.It Li dbsy-other
Count when some agent reserves the bus for use in the next bus cycle
to drive data that this processor will not sample.
.El
Flags
.Li drdy-own
and
.Li drdy-other
are mutually exclusive.
Flags
.Li dbsy-own
and
.Li dbsy-other
are mutually exclusive.
The default value for
.Ar qualifier
is
.Li drdy-drv+drdy-own+dbsy-drv+dbsy-own .
.It Li p4-global-power-events Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count cycles during which the processor is not stopped.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li running
Count cycles when the processor is active.
.El
.It Li p4-instr-retired Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count instructions retired during a clock cycle.
Qualifer
.Ar flags
comprises of the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li nbogusntag
Count non-bogus instructions that are not tagged.
.It Li nbogustag
Count non-bogus instructions that are tagged.
.It Li bogusntag
Count bogus instructions that are not tagged.
.It Li bogustag
Count bogus instructions that are tagged.
.El
The default qualifier counts all the above kinds of instructions.
.It Li p4-ioq-active-entries Xo
.Op Li ,mask= Ns Ar qualifier
.Op Li ,busreqtype= Ns Ar req-type
.Xc
.Pq "TS event"
Count the number of entries (clipped at 15) in the IOQ that are
active.
The event masks are specified by qualifier
.Ar qualifier
and
.Ar req-type .
.Pp
Qualifier
.Ar qualifier
is a
.Li +
separated set of the following flags:
.Bl -tag -width indent -compact
.It Li all-read
Count read entries.
.It Li all-write
Count write entries.
.It Li mem-uc
Count entries accessing uncacheable memory.
.It Li mem-wc
Count entries accessing write-combining memory.
.It Li mem-wt
Count entries accessing write-through memory.
.It Li mem-wp
Count entries accessing write-protected memory
.It Li mem-wb
Count entries accessing write-back memory.
.It Li own
Count store requests driven by the processor (i.e., not by other
processors or by DMA).
.It Li other
Count store requests driven by other processors or by DMA.
.It Li prefetch
Include hardware and software prefetch requests in the count.
.El
The default value for
.Ar qualifier
is to enable all the above flags.
.Pp
The
.Ar req-type
qualifier is a 5-bit number can be additionally used to select a
specific bus request type.
The default is 0.
.Pp
The
.Li edge
qualifier should not be used when counting cycles with this event.
The exact behaviour of this event depends on the processor revision.
.It Li p4-ioq-allocation Xo
.Op Li ,mask= Ns Ar qualifier
.Op Li ,busreqtype= Ns Ar req-type
.Xc
.Pq "TS event"
Count various types of transactions on the bus matching the flags set
in
.Ar qualifier
and
.Ar req-type .
.Pp
Qualifier
.Ar qualifier
is a
.Li +
separated set of the following flags:
.Bl -tag -width indent -compact
.It Li all-read
Count read entries.
.It Li all-write
Count write entries.
.It Li mem-uc
Count entries accessing uncacheable memory.
.It Li mem-wc
Count entries accessing write-combining memory.
.It Li mem-wt
Count entries accessing write-through memory.
.It Li mem-wp
Count entries accessing write-protected memory
.It Li mem-wb
Count entries accessing write-back memory.
.It Li own
Count store requests driven by the processor (i.e., not by other
processors or by DMA).
.It Li other
Count store requests driven by other processors or by DMA.
.It Li prefetch
Include hardware and software prefetch requests in the count.
.El
The default value for
.Ar qualifier
is to enable all the above flags.
.Pp
The
.Ar req-type
qualifier is a 5-bit number can be additionally used to select a
specific bus request type.
The default is 0.
.Pp
The
.Li edge
qualifier is normally used with this event to prevent multiple
counting.
The exact behaviour of this event depends on the processor revision.
.It Li p4-itlb-reference Op mask= Ns Ar qualifier
.Pq "TS event"
Count translations using the intruction translation look-aside
buffer.
The
.Ar qualifier
argument is a list of the following strings separated by
.Li +
characters.
.Bl -tag -width indent -compact
.It Li hit
Count ITLB hits.
.It Li miss
Count ITLB misses.
.It Li hit-uc
Count uncacheable ITLB hits.
.El
If no
.Ar qualifier
is specified the default is to count all the three kinds of ITLB
translations.
.It Li p4-load-port-replay Op Li ,mask= Ns Ar qualifier
.Pq "TS event"
Count replayed events at the load port.
Qualifier
.Ar qualifier
can take on one value:
.Bl -tag -width indent -compact
.It Li split-ld
Count split loads.
.El
The default value for
.Ar qualifier
is
.Li split-ld .
.It Li p4-mispred-branch-retired Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count mispredicted IA-32 branch instructions.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li nbogus
Count non-bogus retired branch instructions.
.El
.It Li p4-machine-clear Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count the number of pipeline clears seen by the processor.
Qualifer
.Ar flags
is a list of the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li clear
Count for a portion of the many cycles when the machine is being
cleared for any reason.
.It Li moclear
Count machine clears due to memory ordering issues.
.It Li smclear
Count machine clears due to self-modifying code.
.El
Use qualifier
.Li edge
to get a count of occurrences of machine clears.
The default qualifier is
.Li clear .
.It Li p4-memory-cancel Op Li ,mask= Ns Ar event-list
.Pq "TS event"
Count the cancelling of various kinds of requests in the data cache
address control unit of the CPU.
The qualifier
.Ar event-list
is a list of the following strings separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li st-rb-full
Requests cancelled because no store request buffer was available.
.It Li 64k-conf
Requests that conflict due to 64K aliasing.
.El
If
.Ar event-list
is not specified, then the default is to count both kinds of events.
.It Li p4-memory-complete Op Li ,mask= Ns Ar event-list
.Pq "TS event"
Count the completion of load split, store split, uncacheable split and
uncacheable load operations selected by qualifier
.Ar event-list .
The qualifier
.Ar event-list
is a
.Li +
separated list of the following flags:
.Bl -tag -width indent -compact
.It Li lsc
Count load splits completed, excluding loads from uncacheable or
write-combining areas.
.It Li ssc
Count any split stores completed.
.El
The default is to count both kinds of operations.
.It Li p4-mob-load-replay Op Li ,mask= Ns Ar qualifier
.Pq "TS event"
Count load replays triggered by the memory order buffer.
Qualifier
.Ar qualifier
can be a
.Li +
separated list of the following flags:
.Bl -tag -width indent -compact
.It Li no-sta
Count replays because of unknown store addresses.
.It Li no-std
Count replays because of unknown store data.
.It Li partial-data
Count replays because of partially overlapped data accesses between
load and store operations.
.It Li unalgn-addr
Count replays because of mismatches in the lower 4 bits of load and
store operations.
.El
The default qualifier is
.Ar no-sta+no-std+partial-data+unalgn-addr .
.It Li p4-packed-dp-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count packed double-precision uops.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count all uops operating on packed double-precision operands.
.El
.It Li p4-packed-sp-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count packed single-precision uops.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count all uops operating on packed single-precision operands.
.El
.It Li p4-page-walk-type Op Li ,mask= Ns Ar qualifier
.Pq "TI event"
Count page walks performed by the page miss handler.
Qualifier
.Ar qualifier
can be a
.Li +
separated list of the following keywords:
.Bl -tag -width indent -compact
.It Li dtmiss
Count page walks for data TLB misses.
.It Li itmiss
Count page walks for instruction TLB misses.
.El
The default value for
.Ar qualifier
is
.Li dtmiss+itmiss .
.It Li p4-replay-event Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count the retirement of tagged uops selected through the replay
tagging mechanism.
Qualifier
.Ar flags
contains a
.Li +
separated set of the following strings:
.Bl -tag -width indent -compact
.It Li nbogus
The marked uops are not bogus.
.It Li bogus
The marked uops are bogus.
.El
This event requires additional (upstream) events to be allocated to
perform the desired uop tagging.
The default qualifier counts both kinds of uops.
This event can be used for precise event based sampling.
.It Li p4-resource-stall Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count the occurrence or latency of stalls in the allocator.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li sbfull
A stall due to the lack of store buffers.
.El
.It Li p4-response
.Pq "TI event"
Count different types of responses.
Further documentation on this event is not available.
.It Li p4-retired-branch-type Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count branches retired.
Qualifier
.Ar flags
contains a
.Li +
separated list of strings:
.Bl -tag -width indent -compact
.It Li conditional
Count conditional jumps.
.It Li call
Count direct and indirect call branches.
.It Li return
Count return branches.
.It Li indirect
Count returns, indirect calls or indirect jumps.
.El
The default qualifier counts all the above branch types.
.It Li p4-retired-mispred-branch-type Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count mispredicted branches retired.
Qualifier
.Ar flags
contains a
.Li +
separated list of strings:
.Bl -tag -width indent -compact
.It Li conditional
Count conditional jumps.
.It Li call
Count indirect call branches.
.It Li return
Count return branches.
.It Li indirect
Count returns, indirect calls or indirect jumps.
.El
The default qualifier counts all the above branch types.
.It Li p4-scalar-dp-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count the number of scalar double-precision uops.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count the number of scalar double-precision uops.
.El
.It Li p4-scalar-sp-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count the number of scalar single-precision uops.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count all uops operating on scalar single-precision operands.
.El
.It Li p4-snoop
.Pq "TI event"
Count snoop traffic.
Further documentation on this event is not available.
.It Li p4-sse-input-assist Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count the number of times an assist is required to handle problems
with the operands for SSE and SSE2 operations.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count assists for all SSE and SSE2 uops.
.El
.It Li p4-store-port-replay Op Li ,mask= Ns Ar qualifier
.Pq "TS event"
Count events replayed at the store port.
Qualifier
.Ar qualifier
can take on one value:
.Bl -tag -width indent -compact
.It Li split-st
Count split stores.
.El
The default value for
.Ar qualifier
is
.Li split-st .
.It Li p4-tc-deliver-mode Op Li ,mask= Ns Ar qualifier
.Pq "TI event"
Count the duration in cycles of operating modes of the trace cache and
decode engine.
The desired operating mode is selected by
.Ar qualifier ,
which is a list of the following strings separated by
.Li "+"
characters:
.Bl -tag -width indent -compact
.It Li DD
Both logical processors are in deliver mode.
.It Li DB
Logical processor 0 is in deliver mode while logical processor 1 is in
build mode.
.It Li DI
Logical processor 0 is in deliver mode while logical processor 1 is
halted, or in machine clear, or transitioning to a long microcode
flow.
.It Li BD
Logical processor 0 is in build mode while logical processor 1 is in
deliver mode.
.It Li BB
Both logical processors are in build mode.
.It Li BI
Logical processor 0 is in build mode while logical processor 1 is
halted, or in machine clear or transitioning to a long microcode
flow.
.It Li ID
Logical processor 0 is halted, or in machine clear or transitioning to
a long microcode flow while logical processor 1 is in deliver mode.
.It Li IB
Logical processor 0 is halted, or in machine clear or transitioning to
a long microcode flow while logical processor 1 is in build mode.
.El
If there is only one logical processor in the processor package then
the qualifier for logical processor 1 is ignored.
If no qualifier is specified, the default qualifier is
.Li DD+DB+DI+BD+BB+BI+ID+IB .
.It Li p4-tc-ms-xfer Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count the number of times uop delivery changed from the trace cache to
MS ROM.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li cisc
Count TC to MS transfers.
.El
.It Li p4-uop-queue-writes Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count the number of valid uops written to the uop queue.
Qualifier
.Ar flags
is a list of the following strings, separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li from-tc-build
Count uops being written from the trace cache in build mode.
.It Li from-tc-deliver
Count uops being written from the trace cache in deliver mode.
.It Li from-rom
Count uops being written from microcode ROM.
.El
The default qualifier counts all the above kinds of uops.
.It Li p4-uop-type Op Li ,mask= Ns Ar flags
.Pq "TS event"
This event is used in conjunction with the front-end at-retirement
mechanism to tag load and store uops.
Qualifer
.Ar flags
comprises the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li tagloads
Mark uops that are load operations.
.It Li tagstores
Mark uops that are store operations.
.El
The default qualifier counts both kinds of uops.
.It Li p4-uops-retired Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count uops retired during a clock cycle.
Qualifier
.Ar flags
comprises the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li nbogus
Count marked uops that are not bogus.
.It Li bogus
Count marked uops that are bogus.
.El
The default qualifier counts both kinds of uops.
.It Li p4-wc-buffer Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count write-combining buffer operations.
Qualifier
.Ar flags
contains the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li wcb-evicts
WC buffer evictions due to any cause.
.It Li wcb-full-evict
WC buffer evictions due to no WC buffer being available.
.El
The default qualifer counts both kinds of evictions.
.It Li p4-x87-assist Op Li ,mask= Ns Ar flags
.Pq "TS event"
Count the retirement of x87 instructions that required special
handling.
Qualifier
.Ar flags
contains the following strings separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li fpsu
Count instructions that saw an FP stack underflow.
.It Li fpso
Count instructions that saw an FP stack overflow.
.It Li poao
Count instructions that saw an x87 output overflow.
.It Li poau
Count instructions that saw an x87 output underflow.
.It Li prea
Count instructions that needed an x87 input assist.
.El
The default qualifier counts all the above types of instruction
retirements.
.It Li p4-x87-fp-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count x87 floating-point uops.
Qualifier
.Ar flags
can take the following value (which is also the default):
.Bl -tag -width indent -compact
.It Li all
Count all x87 floating-point uops.
.El
If an instruction contains more than one x87 floating-point uops, then
all x87 floating-point uops will be counted.
This event does not count x87 floating-point data movement operations.
.It Li p4-x87-simd-moves-uop Op Li ,mask= Ns Ar flags
.Pq "TI event"
Count each x87 FPU, MMX, SSE, or SSE2 uops that load data or store
data or perform register-to-register moves.
This event does not count integer move uops.
Qualifier
.Ar flags
may contain the following keywords separated by
.Li +
characters:
.Bl -tag -width indent -compact
.It Li allp0
Count all x87 and SIMD store and move uops.
.It Li allp2
Count all x87 and SIMD load uops.
.El
The default is to count all uops.
.Pq Errata
This event may be affected by processor errata N43.
.El
.Ss "Cascading P4 PMCs"
To be filled in.
.Ss "Precise Event Based Sampling"
To be filled in.
.Sh IMPLEMENTATION NOTES
On the i386 architecture,
.Fx
has historically allowed the use of the RDTSC instruction from
user-mode (i.e., at a processor CPL of 3) by any process.
This behaviour is preserved by
.Xr hwpmc 4 .
.Sh RETURN VALUES
The
.Fn pmc_name_of_capability ,
.Fn pmc_name_of_class ,
.Fn pmc_name_of_cputype ,
.Fn pmc_name_of_disposition ,
.Fn pmc_name_of_event ,
.Fn pmc_name_of_mode ,
and
.Fn pmc_name_of_state
functions return a pointer to the human readable form of their argument.
These pointers may point to statically allocated storage and must
not be passed to
.Fn free .
In case of an error, these functions return
.Li NULL
and set the global variable
.Va errno .
.Pp
The functions
.Fn pmc_ncpu
and
.Fn pmc_npmc
return the number of CPUs and number of PMCs configured respectively;
in case of an error they return the value
.Li -1
and set the global variable
.Va errno .
.Pp
All other functions return the value
.Li 0
if successful; otherwise the value
.Li -1
is returned and the global variable
.Va errno
is set to indicate the error.
.Sh ERRORS
A call to
.Fn pmc_init
may fail with the following errors in addition to those returned by
.Xr modfind 2 ,
.Xr modstat 2
and
.Xr hwpmc 4 :
.Bl -tag -width Er
.It Bq Er ENXIO
An unknown CPU type was encountered during initialization.
.It Bq Er EPROGMISMATCH
The version number of the
.Xr hwpmc 4
kernel module did not match that compiled into the
.Xr pmc 3
library.
.El
.Pp
A call to
.Fn pmc_name_of_capability ,
.Fn pmc_name_of_disposition ,
.Fn pmc_name_of_state ,
.Fn pmc_name_of_event ,
.Fn pmc_name_of_mode
and
.Fn pmc_name_of_class
may fail with the following error:
.Bl -tag -width Er
.It Bq Er EINVAL
An invalid argument was passed to the function.
.El
.Pp
A call to
.Fn pmc_cpuinfo
or
.Fn pmc_ncpu
may fail with the following error:
.Bl -tag -width Er
.It Bq Er ENXIO
The
.Xr pmc 3
has not been initialized.
.El
.Pp
A call to
.Fn pmc_npmc
may fail with the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The argument passed in was out of range.
.It Bq Er ENXIO
The
.Xr pmc 3
library has not been initialized.
.El
.Pp
A call to
.Fn pmc_pmcinfo
may fail with the following errors, in addition to those returned by
.Xr hwpmc 4 :
.Bl -tag -width Er
.It Bq Er ENXIO
The
.Xr pmc 3
library is not yet initialized.
.El
.Pp
A call to
.Fn pmc_allocate
may fail with the following errors, in addition to those returned by
.Xr hwpmc 4 :
.Bl -tag -width Er
.It Bq Er EINVAL
The
.Fa mode
argument passed in had an illegal value, or the event specification
.Fa ctrspec
was unrecognized for this cpu type.
.El
.Pp
Calls to
.Fn pmc_attach ,
.Fn pmc_detach ,
.Fn pmc_release ,
.Fn pmc_start ,
.Fn pmc_stop ,
.Fn pmc_read ,
.Fn pmc_write ,
.Fn pmc_rw ,
.Fn pmc_set ,
.Fn pmc_configure_logfile ,
.Fn pmc_get_driver_stats ,
.Fn pmc_enable ,
.Fn pmc_disable ,
and
.Fn pmc_x86_get_msr
may fail with the errors described in
.Xr hwpmc 4 .
.Sh SEE ALSO
.Xr modfind 2 ,
.Xr modstat 2 ,
.Xr hwpmc 4 ,
.Xr pmccontrol 8 ,
.Xr pmcreport 8 ,
.Xr pmcstat 8
.Sh BUGS
The information returned by
.Fn pmc_cpuinfo ,
.Fn pmc_ncpu
and possibly
.Fn pmc_npmc
should really be available all the time, through a better designed
interface.
.Pp
The API for
.Fn pmc_cpuinfo
and
.Fn pmc_pmcinfo
expose too much of the underlying
.Xr hwpmc 4
driver's internals to userland.
|