Deleted Added
full compact
libpmc.c (228869) libpmc.c (232366)
1/*-
2 * Copyright (c) 2003-2008 Joseph Koshy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003-2008 Joseph Koshy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/lib/libpmc/libpmc.c 228869 2011-12-24 19:34:52Z jhibbits $");
28__FBSDID("$FreeBSD: head/lib/libpmc/libpmc.c 232366 2012-03-01 21:23:26Z davide $");
29
30#include <sys/types.h>
31#include <sys/module.h>
32#include <sys/pmc.h>
33#include <sys/syscall.h>
34
35#include <ctype.h>
36#include <errno.h>

--- 137 unchanged lines hidden (view full) ---

174 __PMC_EV_ALIAS_CORE2()
175};
176
177static const struct pmc_event_descr corei7_event_table[] =
178{
179 __PMC_EV_ALIAS_COREI7()
180};
181
29
30#include <sys/types.h>
31#include <sys/module.h>
32#include <sys/pmc.h>
33#include <sys/syscall.h>
34
35#include <ctype.h>
36#include <errno.h>

--- 137 unchanged lines hidden (view full) ---

174 __PMC_EV_ALIAS_CORE2()
175};
176
177static const struct pmc_event_descr corei7_event_table[] =
178{
179 __PMC_EV_ALIAS_COREI7()
180};
181
182static const struct pmc_event_descr sandybridge_event_table[] =
183{
184 __PMC_EV_ALIAS_SANDYBRIDGE()
185};
186
182static const struct pmc_event_descr westmere_event_table[] =
183{
184 __PMC_EV_ALIAS_WESTMERE()
185};
186
187static const struct pmc_event_descr corei7uc_event_table[] =
188{
189 __PMC_EV_ALIAS_COREI7UC()
190};
191
187static const struct pmc_event_descr westmere_event_table[] =
188{
189 __PMC_EV_ALIAS_WESTMERE()
190};
191
192static const struct pmc_event_descr corei7uc_event_table[] =
193{
194 __PMC_EV_ALIAS_COREI7UC()
195};
196
197static const struct pmc_event_descr sandybridgeuc_event_table[] =
198{
199 __PMC_EV_ALIAS_SANDYBRIDGEUC()
200};
201
192static const struct pmc_event_descr westmereuc_event_table[] =
193{
194 __PMC_EV_ALIAS_WESTMEREUC()
195};
196
197/*
198 * PMC_MDEP_TABLE(NAME, PRIMARYCLASS, ADDITIONAL_CLASSES...)
199 *
200 * Map a CPU to the PMC classes it supports.
201 */
202#define PMC_MDEP_TABLE(N,C,...) \
203 static const enum pmc_class N##_pmc_classes[] = { \
204 PMC_CLASS_##C, __VA_ARGS__ \
205 }
206
207PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
208PMC_MDEP_TABLE(core, IAP, PMC_CLASS_TSC);
209PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
210PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
202static const struct pmc_event_descr westmereuc_event_table[] =
203{
204 __PMC_EV_ALIAS_WESTMEREUC()
205};
206
207/*
208 * PMC_MDEP_TABLE(NAME, PRIMARYCLASS, ADDITIONAL_CLASSES...)
209 *
210 * Map a CPU to the PMC classes it supports.
211 */
212#define PMC_MDEP_TABLE(N,C,...) \
213 static const enum pmc_class N##_pmc_classes[] = { \
214 PMC_CLASS_##C, __VA_ARGS__ \
215 }
216
217PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
218PMC_MDEP_TABLE(core, IAP, PMC_CLASS_TSC);
219PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
220PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
221PMC_MDEP_TABLE(sandybridge, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
211PMC_MDEP_TABLE(westmere, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
212PMC_MDEP_TABLE(k7, K7, PMC_CLASS_TSC);
213PMC_MDEP_TABLE(k8, K8, PMC_CLASS_TSC);
214PMC_MDEP_TABLE(p4, P4, PMC_CLASS_TSC);
215PMC_MDEP_TABLE(p5, P5, PMC_CLASS_TSC);
216PMC_MDEP_TABLE(p6, P6, PMC_CLASS_TSC);
217PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_XSCALE);
218PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_MIPS24K);

--- 18 unchanged lines hidden (view full) ---

237 }
238
239#if defined(__i386__) || defined(__amd64__)
240PMC_CLASS_TABLE_DESC(iaf, IAF, iaf, iaf);
241PMC_CLASS_TABLE_DESC(atom, IAP, atom, iap);
242PMC_CLASS_TABLE_DESC(core, IAP, core, iap);
243PMC_CLASS_TABLE_DESC(core2, IAP, core2, iap);
244PMC_CLASS_TABLE_DESC(corei7, IAP, corei7, iap);
222PMC_MDEP_TABLE(westmere, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
223PMC_MDEP_TABLE(k7, K7, PMC_CLASS_TSC);
224PMC_MDEP_TABLE(k8, K8, PMC_CLASS_TSC);
225PMC_MDEP_TABLE(p4, P4, PMC_CLASS_TSC);
226PMC_MDEP_TABLE(p5, P5, PMC_CLASS_TSC);
227PMC_MDEP_TABLE(p6, P6, PMC_CLASS_TSC);
228PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_XSCALE);
229PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_MIPS24K);

--- 18 unchanged lines hidden (view full) ---

248 }
249
250#if defined(__i386__) || defined(__amd64__)
251PMC_CLASS_TABLE_DESC(iaf, IAF, iaf, iaf);
252PMC_CLASS_TABLE_DESC(atom, IAP, atom, iap);
253PMC_CLASS_TABLE_DESC(core, IAP, core, iap);
254PMC_CLASS_TABLE_DESC(core2, IAP, core2, iap);
255PMC_CLASS_TABLE_DESC(corei7, IAP, corei7, iap);
256PMC_CLASS_TABLE_DESC(sandybridge, IAP, sandybridge, iap);
245PMC_CLASS_TABLE_DESC(westmere, IAP, westmere, iap);
246PMC_CLASS_TABLE_DESC(ucf, UCF, ucf, ucf);
247PMC_CLASS_TABLE_DESC(corei7uc, UCP, corei7uc, ucp);
257PMC_CLASS_TABLE_DESC(westmere, IAP, westmere, iap);
258PMC_CLASS_TABLE_DESC(ucf, UCF, ucf, ucf);
259PMC_CLASS_TABLE_DESC(corei7uc, UCP, corei7uc, ucp);
260PMC_CLASS_TABLE_DESC(sandybridgeuc, UCP, sandybridgeuc, ucp);
248PMC_CLASS_TABLE_DESC(westmereuc, UCP, westmereuc, ucp);
249#endif
250#if defined(__i386__)
251PMC_CLASS_TABLE_DESC(k7, K7, k7, k7);
252#endif
253#if defined(__i386__) || defined(__amd64__)
254PMC_CLASS_TABLE_DESC(k8, K8, k8, k8);
255PMC_CLASS_TABLE_DESC(p4, P4, p4, p4);

--- 269 unchanged lines hidden (view full) ---

525 EV_ALIAS("unhalted-cycles", "iap-cpu-clk-unhalted.core_p"),
526 EV_ALIAS(NULL, NULL)
527};
528
529#define atom_aliases core2_aliases
530#define atom_aliases_without_iaf core2_aliases_without_iaf
531#define corei7_aliases core2_aliases
532#define corei7_aliases_without_iaf core2_aliases_without_iaf
261PMC_CLASS_TABLE_DESC(westmereuc, UCP, westmereuc, ucp);
262#endif
263#if defined(__i386__)
264PMC_CLASS_TABLE_DESC(k7, K7, k7, k7);
265#endif
266#if defined(__i386__) || defined(__amd64__)
267PMC_CLASS_TABLE_DESC(k8, K8, k8, k8);
268PMC_CLASS_TABLE_DESC(p4, P4, p4, p4);

--- 269 unchanged lines hidden (view full) ---

538 EV_ALIAS("unhalted-cycles", "iap-cpu-clk-unhalted.core_p"),
539 EV_ALIAS(NULL, NULL)
540};
541
542#define atom_aliases core2_aliases
543#define atom_aliases_without_iaf core2_aliases_without_iaf
544#define corei7_aliases core2_aliases
545#define corei7_aliases_without_iaf core2_aliases_without_iaf
546#define sandybridge_aliases core2_aliases
547#define sandybridge_aliases_without_iaf core2_aliases_without_iaf
533#define westmere_aliases core2_aliases
534#define westmere_aliases_without_iaf core2_aliases_without_iaf
535
536#define IAF_KW_OS "os"
537#define IAF_KW_USR "usr"
538#define IAF_KW_ANYTHREAD "anythread"
539
540/*

--- 2016 unchanged lines hidden (view full) ---

2557 case PMC_CPU_INTEL_CORE2EXTREME:
2558 ev = core2_event_table;
2559 count = PMC_EVENT_TABLE_SIZE(core2);
2560 break;
2561 case PMC_CPU_INTEL_COREI7:
2562 ev = corei7_event_table;
2563 count = PMC_EVENT_TABLE_SIZE(corei7);
2564 break;
548#define westmere_aliases core2_aliases
549#define westmere_aliases_without_iaf core2_aliases_without_iaf
550
551#define IAF_KW_OS "os"
552#define IAF_KW_USR "usr"
553#define IAF_KW_ANYTHREAD "anythread"
554
555/*

--- 2016 unchanged lines hidden (view full) ---

2572 case PMC_CPU_INTEL_CORE2EXTREME:
2573 ev = core2_event_table;
2574 count = PMC_EVENT_TABLE_SIZE(core2);
2575 break;
2576 case PMC_CPU_INTEL_COREI7:
2577 ev = corei7_event_table;
2578 count = PMC_EVENT_TABLE_SIZE(corei7);
2579 break;
2580 case PMC_CPU_INTEL_SANDYBRIDGE:
2581 ev = sandybridge_event_table;
2582 count = PMC_EVENT_TABLE_SIZE(sandybridge);
2583 break;
2565 case PMC_CPU_INTEL_WESTMERE:
2566 ev = westmere_event_table;
2567 count = PMC_EVENT_TABLE_SIZE(westmere);
2568 break;
2569 }
2570 break;
2571 case PMC_CLASS_UCF:
2572 ev = ucf_event_table;

--- 5 unchanged lines hidden (view full) ---

2578 * spellings for the current CPU.
2579 */
2580 switch (cpu_info.pm_cputype) {
2581 default:
2582 case PMC_CPU_INTEL_COREI7:
2583 ev = corei7uc_event_table;
2584 count = PMC_EVENT_TABLE_SIZE(corei7uc);
2585 break;
2584 case PMC_CPU_INTEL_WESTMERE:
2585 ev = westmere_event_table;
2586 count = PMC_EVENT_TABLE_SIZE(westmere);
2587 break;
2588 }
2589 break;
2590 case PMC_CLASS_UCF:
2591 ev = ucf_event_table;

--- 5 unchanged lines hidden (view full) ---

2597 * spellings for the current CPU.
2598 */
2599 switch (cpu_info.pm_cputype) {
2600 default:
2601 case PMC_CPU_INTEL_COREI7:
2602 ev = corei7uc_event_table;
2603 count = PMC_EVENT_TABLE_SIZE(corei7uc);
2604 break;
2605 case PMC_CPU_INTEL_SANDYBRIDGE:
2606 ev = sandybridgeuc_event_table;
2607 count = PMC_EVENT_TABLE_SIZE(sandybridgeuc);
2608 break;
2586 case PMC_CPU_INTEL_WESTMERE:
2587 ev = westmereuc_event_table;
2588 count = PMC_EVENT_TABLE_SIZE(westmereuc);
2589 break;
2590 }
2591 break;
2592 case PMC_CLASS_TSC:
2593 ev = tsc_event_table;

--- 215 unchanged lines hidden (view full) ---

2809 case PMC_CPU_INTEL_CORE2EXTREME:
2810 PMC_MDEP_INIT_INTEL_V2(core2);
2811 break;
2812 case PMC_CPU_INTEL_COREI7:
2813 pmc_class_table[n++] = &ucf_class_table_descr;
2814 pmc_class_table[n++] = &corei7uc_class_table_descr;
2815 PMC_MDEP_INIT_INTEL_V2(corei7);
2816 break;
2609 case PMC_CPU_INTEL_WESTMERE:
2610 ev = westmereuc_event_table;
2611 count = PMC_EVENT_TABLE_SIZE(westmereuc);
2612 break;
2613 }
2614 break;
2615 case PMC_CLASS_TSC:
2616 ev = tsc_event_table;

--- 215 unchanged lines hidden (view full) ---

2832 case PMC_CPU_INTEL_CORE2EXTREME:
2833 PMC_MDEP_INIT_INTEL_V2(core2);
2834 break;
2835 case PMC_CPU_INTEL_COREI7:
2836 pmc_class_table[n++] = &ucf_class_table_descr;
2837 pmc_class_table[n++] = &corei7uc_class_table_descr;
2838 PMC_MDEP_INIT_INTEL_V2(corei7);
2839 break;
2840 case PMC_CPU_INTEL_SANDYBRIDGE:
2841 pmc_class_table[n++] = &ucf_class_table_descr;
2842 pmc_class_table[n++] = &sandybridgeuc_class_table_descr;
2843 PMC_MDEP_INIT_INTEL_V2(sandybridge);
2844 break;
2817 case PMC_CPU_INTEL_WESTMERE:
2818 pmc_class_table[n++] = &ucf_class_table_descr;
2819 pmc_class_table[n++] = &westmereuc_class_table_descr;
2820 PMC_MDEP_INIT_INTEL_V2(westmere);
2821 break;
2822 case PMC_CPU_INTEL_PIV:
2823 PMC_MDEP_INIT(p4);
2824 pmc_class_table[n] = &p4_class_table_descr;

--- 107 unchanged lines hidden (view full) ---

2932 case PMC_CPU_INTEL_CORE2EXTREME:
2933 ev = core2_event_table;
2934 evfence = core2_event_table + PMC_EVENT_TABLE_SIZE(core2);
2935 break;
2936 case PMC_CPU_INTEL_COREI7:
2937 ev = corei7_event_table;
2938 evfence = corei7_event_table + PMC_EVENT_TABLE_SIZE(corei7);
2939 break;
2845 case PMC_CPU_INTEL_WESTMERE:
2846 pmc_class_table[n++] = &ucf_class_table_descr;
2847 pmc_class_table[n++] = &westmereuc_class_table_descr;
2848 PMC_MDEP_INIT_INTEL_V2(westmere);
2849 break;
2850 case PMC_CPU_INTEL_PIV:
2851 PMC_MDEP_INIT(p4);
2852 pmc_class_table[n] = &p4_class_table_descr;

--- 107 unchanged lines hidden (view full) ---

2960 case PMC_CPU_INTEL_CORE2EXTREME:
2961 ev = core2_event_table;
2962 evfence = core2_event_table + PMC_EVENT_TABLE_SIZE(core2);
2963 break;
2964 case PMC_CPU_INTEL_COREI7:
2965 ev = corei7_event_table;
2966 evfence = corei7_event_table + PMC_EVENT_TABLE_SIZE(corei7);
2967 break;
2968 case PMC_CPU_INTEL_SANDYBRIDGE:
2969 ev = sandybridge_event_table;
2970 evfence = sandybridge_event_table + PMC_EVENT_TABLE_SIZE(sandybridge);
2971 break;
2940 case PMC_CPU_INTEL_WESTMERE:
2941 ev = westmere_event_table;
2942 evfence = westmere_event_table + PMC_EVENT_TABLE_SIZE(westmere);
2943 break;
2944 default: /* Unknown CPU type. */
2945 break;
2946 }
2947 } else if (pe >= PMC_EV_UCF_FIRST && pe <= PMC_EV_UCF_LAST) {
2948 ev = ucf_event_table;
2949 evfence = ucf_event_table + PMC_EVENT_TABLE_SIZE(ucf);
2950 } else if (pe >= PMC_EV_UCP_FIRST && pe <= PMC_EV_UCP_LAST) {
2951 switch (cpu) {
2952 case PMC_CPU_INTEL_COREI7:
2953 ev = corei7uc_event_table;
2954 evfence = corei7uc_event_table + PMC_EVENT_TABLE_SIZE(corei7uc);
2955 break;
2972 case PMC_CPU_INTEL_WESTMERE:
2973 ev = westmere_event_table;
2974 evfence = westmere_event_table + PMC_EVENT_TABLE_SIZE(westmere);
2975 break;
2976 default: /* Unknown CPU type. */
2977 break;
2978 }
2979 } else if (pe >= PMC_EV_UCF_FIRST && pe <= PMC_EV_UCF_LAST) {
2980 ev = ucf_event_table;
2981 evfence = ucf_event_table + PMC_EVENT_TABLE_SIZE(ucf);
2982 } else if (pe >= PMC_EV_UCP_FIRST && pe <= PMC_EV_UCP_LAST) {
2983 switch (cpu) {
2984 case PMC_CPU_INTEL_COREI7:
2985 ev = corei7uc_event_table;
2986 evfence = corei7uc_event_table + PMC_EVENT_TABLE_SIZE(corei7uc);
2987 break;
2988 case PMC_CPU_INTEL_SANDYBRIDGE:
2989 ev = sandybridgeuc_event_table;
2990 evfence = sandybridgeuc_event_table + PMC_EVENT_TABLE_SIZE(sandybridgeuc);
2991 break;
2956 case PMC_CPU_INTEL_WESTMERE:
2957 ev = westmereuc_event_table;
2958 evfence = westmereuc_event_table + PMC_EVENT_TABLE_SIZE(westmereuc);
2959 break;
2960 default: /* Unknown CPU type. */
2961 break;
2962 }
2963 } else if (pe >= PMC_EV_K7_FIRST && pe <= PMC_EV_K7_LAST) {

--- 232 unchanged lines hidden ---
2992 case PMC_CPU_INTEL_WESTMERE:
2993 ev = westmereuc_event_table;
2994 evfence = westmereuc_event_table + PMC_EVENT_TABLE_SIZE(westmereuc);
2995 break;
2996 default: /* Unknown CPU type. */
2997 break;
2998 }
2999 } else if (pe >= PMC_EV_K7_FIRST && pe <= PMC_EV_K7_LAST) {

--- 232 unchanged lines hidden ---