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