1 .\" $NetBSD: pmc.3,v 1.5 2003/04/16 13:35:13 wiz Exp $
3 .\" Copyright (c) 2002 Wasabi Systems, Inc.
4 .\" All rights reserved.
6 .\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
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.
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.
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
58 .Fn pmc_configure_counter "int ctr" "const char *evname" \
59 "pmc_ctr_t reset_val" "uint32_t flags"
61 .Fn pmc_start_counter "int ctr"
63 .Fn pmc_stop_counter "int ctr"
65 .Fn pmc_get_num_counters "void"
67 .Fn pmc_get_counter_class "void"
69 .Fn pmc_get_counter_type "int ctr" "int *typep"
71 .Fn pmc_get_counter_value "int ctr" "uint64_t *valp"
73 .Fn pmc_get_accumulated_counter_value "int ctr" "uint64_t *valp"
75 .Fn pmc_get_counter_class_name "int class"
77 .Fn pmc_get_counter_type_name "int type"
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"
85 library is an interface to performance monitoring counters available
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.
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
109 .It PMC_TYPE_I80200_PMCx
113 The following events may be counted by a counter of type
114 PMC_TYPE_I80200_CCNT:
116 .Bl -item -offset indent -compact
123 The following events may be counted by a counter of type
124 PMC_TYPE_I80200_PMCx:
126 .Bl -item -offset indent -compact
144 dcachebufffull-stall-time
146 dcachebufffull-stall-count
166 narrow-ecc-caused-rmw
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
180 .It PMC_TYPE_I586_PMCx
184 The following events may be counted by a counter of type
187 .Bl -item -offset indent -compact
197 l1cache-data-miss-read
199 l1cache-data-miss-write
203 l1cache-writeback-hit
207 l2cache-data-snoop-hit
215 mem-access-both-pipes
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
273 .It PMC_TYPE_I686_PMCx
277 The following events may be counted by a counter of type
280 .Bl -item -offset indent -compact
300 insfetch-decode-stall
322 l2cache-data-busy-read
332 bus-req-outstanding-self
334 bus-req-outstanding-any
340 bus-read-for-ownership-self
342 bus-read-for-ownership-any
356 bus-partial-writes-self
358 bus-partial-writes-any
360 bus-partial-trans-self
362 bus-partial-trans-any
368 bus-deferred-trans-self
370 bus-deferred-trans-any
412 ins-pref-dispatch-nta
418 ins-pref-dispatch-weak
434 ins-stream-retired-packed-scalar
436 ins-stream-retired-scalar
438 ins-stream-comp-retired-packed-scalar
440 ins-stream-comp-retired-scalar
446 int-cycles-masked-pending
454 branch-taken-mispred-retired
480 mmx-exec-packed-shift
486 mmx-exec-packed-logical
488 mmx-exec-packed-arith
506 seg-rename-stalls-all
524 There are two types of counters available in this class:
525 .Bl -tag -width PMC_TYPE_K7_PMCxxx
532 The following events may be counted by a counter of type
535 .Bl -item -offset indent -compact
561 l1cache-refill-invalid
563 l1cache-refill-shared
565 l1cache-refill-exclusive
569 l1cache-refill-modified
577 l1cache-load-exclusive
581 l1cache-load-modified
585 l1cache-writeback-invalid
587 l1cache-writeback-shared
589 l1cache-writeback-exclusive
591 l1cache-writeback-owner
593 l1cache-writeback-modified
659 branch-taken-miss-retired
663 branch-resync-retired
667 branch-near-miss-retired
669 branch-indirect-miss-retired
675 int-cycles-masked-pending
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
701 .Fn pmc_configure_counter
702 function configures the counter
706 The initial value of the counter will be set to
708 and this value will be loaded back into the counter each time it overflows.
709 There are currently no flags defined for the
714 .Fn pmc_start_counter
715 function enables counting on counter
720 function disables counting on counter
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
739 .Fn pmc_get_counter_value
740 function places the total number of events counted by counter
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
754 .Fn pmc_get_counter_class_name
755 function returns the name of the counter class
759 .Fn pmc_get_counter_type_name
760 function returns the name of the counter type
764 .Fn pmc_get_counter_event_name
765 function returns the name of the event
767 for the current CPU's performance counter class.
770 .Fn pmc_get_counter_event_list
771 function returns an array of
773 structures, listing the supported event types for the CPU.
774 The array is terminated by and entry who's
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,
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
808 library first appeared in
813 library was written by
815 .Aq thorpej@wasabisystems.com
816 and contributed by Wasabi Systems, Inc.