Fix mdoc(7)/man(7) mix up.
[netbsd-mini2440.git] / lib / libpmc / pmc.3
blobe165c18f8422962509ba49fef0563af84a74f9a8
1 .\"     $NetBSD: pmc.3,v 1.5 2003/04/16 13:35:13 wiz Exp $
2 .\"
3 .\" Copyright (c) 2002 Wasabi Systems, Inc.
4 .\" All rights reserved.
5 .\"
6 .\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed for the NetBSD Project by
19 .\"     Wasabi Systems, Inc.
20 .\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
21 .\"    or promote products derived from this software without specific prior
22 .\"    written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
28 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 .\" POSSIBILITY OF SUCH DAMAGE.
35 .\"
36 .Dd August 8, 2002
37 .Dt PMC 3
38 .Os
39 .Sh NAME
40 .Nm pmc_configure_counter ,
41 .Nm pmc_start_counter ,
42 .Nm pmc_stop_counter ,
43 .Nm pmc_get_num_counters ,
44 .Nm pmc_get_counter_class ,
45 .Nm pmc_get_counter_type ,
46 .Nm pmc_get_counter_value ,
47 .Nm pmc_get_accumulated_counter_value ,
48 .Nm pmc_get_counter_class_name ,
49 .Nm pmc_get_counter_type_name ,
50 .Nm pmc_get_counter_event_name ,
51 .Nm pmc_get_counter_event_list
52 .Nd performance counter interface library
53 .Sh LIBRARY
54 .Lb libpmc
55 .Sh SYNOPSIS
56 .In pmc.h
57 .Ft int
58 .Fn pmc_configure_counter "int ctr" "const char *evname" \
59     "pmc_ctr_t reset_val" "uint32_t flags"
60 .Ft int
61 .Fn pmc_start_counter "int ctr"
62 .Ft int
63 .Fn pmc_stop_counter "int ctr"
64 .Ft int
65 .Fn pmc_get_num_counters "void"
66 .Ft int
67 .Fn pmc_get_counter_class "void"
68 .Ft int
69 .Fn pmc_get_counter_type "int ctr" "int *typep"
70 .Ft int
71 .Fn pmc_get_counter_value "int ctr" "uint64_t *valp"
72 .Ft int
73 .Fn pmc_get_accumulated_counter_value "int ctr" "uint64_t *valp"
74 .Ft const char *
75 .Fn pmc_get_counter_class_name "int class"
76 .Ft const char *
77 .Fn pmc_get_counter_type_name "int type"
78 .Ft const char *
79 .Fn pmc_get_counter_event_name "pmc_evid_t event"
80 .Ft const struct pmc_event *
81 .Fn pmc_get_counter_event_list "void"
82 .Sh DESCRIPTION
83 The
84 .Nm pmc
85 library is an interface to performance monitoring counters available
86 on some CPUs.
87 .Pp
88 The
89 .Nm pmc
90 library can count events on the following CPU families.
91 Each second-level entry describes a performance counter class.
92 A given class may apply to multiple individual CPU models.
93 Each class has one or more counter types.
94 A CPU may have more than one counter of a given type.
95 Refer to the corresponding processor programmer's manual for
96 more information about individual events.
97 .Bl -bullet
98 .It
99 ARM
100 .Bl -bullet
102 Intel i80200
103 .Pq PMC_CLASS_I80200
105 There are two types of counters available in this class:
106 .Bl -tag -width PMC_TYPE_I80200_CCNTxx
107 .It PMC_TYPE_I80200_CCNT
108 cycle counter
109 .It PMC_TYPE_I80200_PMCx
110 performance counter
113 The following events may be counted by a counter of type
114 PMC_TYPE_I80200_CCNT:
116 .Bl -item -offset indent -compact
118 clock
120 clock-div-64
123 The following events may be counted by a counter of type
124 PMC_TYPE_I80200_PMCx:
126 .Bl -item -offset indent -compact
128 insfetch-miss
130 insfetch-stall
132 datadep-stall
134 itlb-miss
136 dtlb-miss
138 branch-taken
140 branch-mispredicted
142 instruction-executed
144 dcachebufffull-stall-time
146 dcachebufffull-stall-count
148 dcache-access
150 dcache-miss
152 dcache-writeback
154 swchange-pc
156 bcu-mem-request
158 bcu-queue-full
160 bcu-queue-drain
162 bcu-ecc-no-elog
164 bcu-1bit-error
166 narrow-ecc-caused-rmw
170 i386
171 .Bl -bullet
173 Intel i586
174 .Pq PMC_CLASS_I586
176 There are two types of counters available in this class:
177 .Bl -tag -width PMC_TYPE_I586_PMCxxx
178 .It PMC_TYPE_I586_TSC
179 cycle counter
180 .It PMC_TYPE_I586_PMCx
181 performance counter
184 The following events may be counted by a counter of type
185 PMC_TYPE_I586_PMCx:
187 .Bl -item -offset indent -compact
189 tlb-data-miss
191 tlb-ins-miss
193 l1cache-ins-miss
195 l1cache-data-miss
197 l1cache-data-miss-read
199 l1cache-data-miss-write
201 l1cache-writeback
203 l1cache-writeback-hit
205 l2cache-data-snoop
207 l2cache-data-snoop-hit
209 mem-read
211 mem-write
213 mem-access
215 mem-access-both-pipes
217 mem-bank-conflicts
219 mem-misalign-ref
221 mem-uncached-read
223 seg-load-any
225 branch
227 branch-btb-hit
229 branch-taken
231 ins-read
233 ins-pipeline-flush
235 ins-executed
237 ins-executed-vpipe
239 ins-stall-agi
241 ins-stall-write
243 ins-stall-data
245 ins-stall-writeline
247 bus-utilization
249 bus-locked
251 bus-io-cycle
253 fpu-flops
255 int-hw
257 break-match0
259 break-match1
261 break-match2
263 break-match3
266 Intel i686
267 .Pq PMC_CLASS_I686
269 There are two types of counters available in this class:
270 .Bl -tag -width PMC_TYPE_I686_PMCxxx
271 .It PMC_TYPE_I686_TSC
272 cycle counter
273 .It PMC_TYPE_I686_PMCx
274 performance counter
277 The following events may be counted by a counter of type
278 PMC_TYPE_I686_PMCx:
280 .Bl -item -offset indent -compact
282 mem-refs
284 l1cache-lines
286 l1cache-mlines
288 l1cache-mlines-evict
290 l1cache-miss-wait
292 ins-fetch
294 ins-fetch-misses
296 itlb-misses
298 insfetch-mem-stall
300 insfetch-decode-stall
302 l2cache-insfetch
304 l2cache-data-loads
306 l2cache-data-stores
308 l2cache-lines
310 l2cache-lines-evict
312 l2cache-mlines
314 l2cache-mlines-evict
316 l2cache-reqs
318 l2cache-addr-strobes
320 l2cache-data-busy
322 l2cache-data-busy-read
324 bus-drdy-clocks-self
326 bus-drdy-clocks-any
328 bus-lock-clocks-self
330 bus-lock-clocks-any
332 bus-req-outstanding-self
334 bus-req-outstanding-any
336 bus-burst-reads-self
338 bus-burst-reads-any
340 bus-read-for-ownership-self
342 bus-read-for-ownership-any
344 bus-write-back-self
346 bus-write-back-any
348 bus-ins-fetches-self
350 bus-ins-fetches-any
352 bus-invalidates-self
354 bus-invalidates-any
356 bus-partial-writes-self
358 bus-partial-writes-any
360 bus-partial-trans-self
362 bus-partial-trans-any
364 bus-io-trans-self
366 bus-io-trans-any
368 bus-deferred-trans-self
370 bus-deferred-trans-any
372 bus-burst-trans-self
374 bus-burst-trans-any
376 bus-total-trans-self
378 bus-total-trans-any
380 bus-mem-trans-self
382 bus-mem-trans-any
384 bus-recv-cycles
386 bus-bnr-cycles
388 bus-hit-cycles
390 bus-hitm-cycles
392 bus-snoop-stall
394 fpu-flops
396 fpu-comp-ops
398 fpu-except-assist
400 fpu-mul
402 fpu-div
404 fpu-div-busy
406 mem-sb-blocks
408 mem-sb-drains
410 mem-misalign-ref
412 ins-pref-dispatch-nta
414 ins-pref-dispatch-t1
416 ins-pref-dispatch-t2
418 ins-pref-dispatch-weak
420 ins-pref-miss-nta
422 ins-pref-miss-t1
424 ins-pref-miss-t2
426 ins-pref-miss-weak
428 ins-retired
430 uops-retired
432 ins-decoded
434 ins-stream-retired-packed-scalar
436 ins-stream-retired-scalar
438 ins-stream-comp-retired-packed-scalar
440 ins-stream-comp-retired-scalar
442 int-hw
444 int-cycles-masked
446 int-cycles-masked-pending
448 branch-retired
450 branch-miss-retired
452 branch-taken-retired
454 branch-taken-mispred-retired
456 branch-decoded
458 branch-btb-miss
460 branch-bogus
462 branch-baclear
464 stall-resource
466 stall-partial
468 seg-loads
470 unhalted-cycles
472 mmx-exec
474 mmx-sat-exec
476 mmx-uops-exec
478 mmx-exec-packed-mul
480 mmx-exec-packed-shift
482 mmx-exec-pack-ops
484 mmx-exec-unpack-ops
486 mmx-exec-packed-logical
488 mmx-exec-packed-arith
490 mmx-trans-mmx-float
492 mmx-trans-float-mmx
494 mmx-assist
496 mmx-retire
498 seg-rename-stalls-es
500 seg-rename-stalls-ds
502 seg-rename-stalls-fs
504 seg-rename-stalls-gs
506 seg-rename-stalls-all
508 seg-rename-es
510 seg-rename-ds
512 seg-rename-fs
514 seg-rename-gs
516 seg-rename-all
518 seg-rename-retire
521 AMD Athlon / K7
522 .Pq PMC_CLASS_K7
524 There are two types of counters available in this class:
525 .Bl -tag -width PMC_TYPE_K7_PMCxxx
526 .It PMC_TYPE_K7_TSC
527 cycle counter
528 .It PMC_TYPE_K7_PMCx
529 performance counter
532 The following events may be counted by a counter of type
533 PMC_TYPE_K7_PMCx:
535 .Bl -item -offset indent -compact
537 seg-load-all
539 seg-load-es
541 seg-load-cs
543 seg-load-ss
545 seg-load-ds
547 seg-load-fs
549 seg-load-gs
551 seg-load-hs
553 seg-load-stall
555 l1cache-access
557 l1cache-miss
559 l1cache-refill
561 l1cache-refill-invalid
563 l1cache-refill-shared
565 l1cache-refill-exclusive
567 l1cache-refill-owner
569 l1cache-refill-modified
571 l1cache-load
573 l1cache-load-invalid
575 l1cache-load-shared
577 l1cache-load-exclusive
579 l1cache-load-owner
581 l1cache-load-modified
583 l1cache-writeback
585 l1cache-writeback-invalid
587 l1cache-writeback-shared
589 l1cache-writeback-exclusive
591 l1cache-writeback-owner
593 l1cache-writeback-modified
595 l2cache-access
597 l2cache-tag-read
599 l2cache-tag-write
601 l2cache-inst-read
603 l2cache-inst-load
605 l2cache-data-store
607 l2cache-data-loadmem
609 l2cache-data-write
611 l2cache-data-move
613 l2cache-access-busy
615 l2cache-hit
617 l2cache-miss
619 mem-misalign-ref
621 mem-access
623 mem-access-uc
625 mem-access-wc
627 mem-access-wt
629 mem-access-wp
631 mem-access-wb
633 ins-fetch
635 ins-fetch-miss
637 ins-refill-l2
639 ins-refill-mem
641 ins-fetch-stall
643 ins-retired
645 ins-empty
647 itlb-miss-l1
649 itlb-miss-l2
651 ops-retired
653 branch-retired
655 branch-miss-retired
657 branch-taken-retired
659 branch-taken-miss-retired
661 branch-far-retired
663 branch-resync-retired
665 branch-near-retired
667 branch-near-miss-retired
669 branch-indirect-miss-retired
671 int-hw
673 int-cycles-masked
675 int-cycles-masked-pending
677 break-match0
679 break-match1
681 break-match2
683 break-match3
689 .Nm pmc
690 library maintains a mapping between event names and the event selector
691 used by the CPU's performance monitoring hardware.
692 The mapping is described by the following structure:
693 .Bd -literal -offset indent
694 struct pmc_event {
695         const char *name;
696         pmc_evid_t val;
701 .Fn pmc_configure_counter
702 function configures the counter
703 .Fa ctr
704 to count the event
705 .Fa evname .
706 The initial value of the counter will be set to
707 .Fa reset_val ,
708 and this value will be loaded back into the counter each time it overflows.
709 There are currently no flags defined for the
710 .Fa flags
711 argument.
714 .Fn pmc_start_counter
715 function enables counting on counter
716 .Fa ctr .
719 .Fn pmc_stop_counter
720 function disables counting on counter
721 .Fa ctr .
724 .Fn pmc_get_num_counters
725 function returns the number of counters present in the CPU.
728 .Fn pmc_get_counter_class
729 function returns the counter class of the CPU.
732 .Fn pmc_get_counter_type
733 function places the counter type of counter
734 .Fa ctr
735 into
736 .Fa *typep .
739 .Fn pmc_get_counter_value
740 function places the total number of events counted by counter
741 .Fa ctr
742 into
743 .Fa *valp .
746 .Fn pmc_get_accumulated_counter_value
747 function places the total number of events counted for the current
748 process and all of its children by counter
749 .Fa ctr
750 into
751 .Fa *valp .
754 .Fn pmc_get_counter_class_name
755 function returns the name of the counter class
756 .Fa classval .
759 .Fn pmc_get_counter_type_name
760 function returns the name of the counter type
761 .Fa type .
764 .Fn pmc_get_counter_event_name
765 function returns the name of the event
766 .Fa event
767 for the current CPU's performance counter class.
770 .Fn pmc_get_counter_event_list
771 function returns an array of
772 .Em pmc_event
773 structures, listing the supported event types for the CPU.
774 The array is terminated by and entry who's
775 .Em name
776 member is NULL.
777 .Sh RETURN VALUES
779 .Fn pmc_configure_counter ,
780 .Fn pmc_start_counter ,
781 .Fn pmc_stop_counter ,
782 .Fn pmc_get_counter_type ,
783 .Fn pmc_get_counter_value ,
785 .Fn pmc_get_accumulated_counter_value
786 functions return 0 to indicate success and \-1 to indicate failure,
787 in which case
788 .Xr errno 2
789 will be set to indicate the mode of failure.
792 .Fn pmc_get_counter_class_name ,
793 .Fn pmc_get_counter_type_name ,
794 .Fn pmc_get_counter_event_name ,
796 .Fn pmc_get_counter_event_list
797 functions return NULL and set
798 .Xr errno 2
799 to indicate failure.
800 .Sh SEE ALSO
801 .Xr pmc 1 ,
802 .Xr pmc_control 2 ,
803 .Xr pmc_get_info 2 ,
804 .Xr pmc 9
805 .Sh HISTORY
807 .Nm pmc
808 library first appeared in
809 .Nx 2.0 .
810 .Sh AUTHORS
812 .Nm pmc
813 library was written by
814 .An Jason R. Thorpe
815 .Aq thorpej@wasabisystems.com
816 and contributed by Wasabi Systems, Inc.