Deleted Added
full compact
libpmc.c (261342) libpmc.c (263446)
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 261342 2014-02-01 02:03:50Z jhibbits $");
28__FBSDID("$FreeBSD: head/lib/libpmc/libpmc.c 263446 2014-03-20 20:51:08Z hiren $");
29
30#include <sys/types.h>
31#include <sys/param.h>
32#include <sys/module.h>
33#include <sys/pmc.h>
34#include <sys/syscall.h>
35
36#include <ctype.h>

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

164#undef __PMC_EV_ALIAS
165#define __PMC_EV_ALIAS(N,CODE) { N, PMC_EV_##CODE },
166
167static const struct pmc_event_descr atom_event_table[] =
168{
169 __PMC_EV_ALIAS_ATOM()
170};
171
29
30#include <sys/types.h>
31#include <sys/param.h>
32#include <sys/module.h>
33#include <sys/pmc.h>
34#include <sys/syscall.h>
35
36#include <ctype.h>

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

164#undef __PMC_EV_ALIAS
165#define __PMC_EV_ALIAS(N,CODE) { N, PMC_EV_##CODE },
166
167static const struct pmc_event_descr atom_event_table[] =
168{
169 __PMC_EV_ALIAS_ATOM()
170};
171
172static const struct pmc_event_descr atom_silvermont_event_table[] =
173{
174 __PMC_EV_ALIAS_ATOM_SILVERMONT()
175};
176
172static const struct pmc_event_descr core_event_table[] =
173{
174 __PMC_EV_ALIAS_CORE()
175};
176
177
178static const struct pmc_event_descr core2_event_table[] =
179{

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

241 * Map a CPU to the PMC classes it supports.
242 */
243#define PMC_MDEP_TABLE(N,C,...) \
244 static const enum pmc_class N##_pmc_classes[] = { \
245 PMC_CLASS_##C, __VA_ARGS__ \
246 }
247
248PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
177static const struct pmc_event_descr core_event_table[] =
178{
179 __PMC_EV_ALIAS_CORE()
180};
181
182
183static const struct pmc_event_descr core2_event_table[] =
184{

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

246 * Map a CPU to the PMC classes it supports.
247 */
248#define PMC_MDEP_TABLE(N,C,...) \
249 static const enum pmc_class N##_pmc_classes[] = { \
250 PMC_CLASS_##C, __VA_ARGS__ \
251 }
252
253PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
254PMC_MDEP_TABLE(atom_silvermont, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
249PMC_MDEP_TABLE(core, IAP, PMC_CLASS_SOFT, PMC_CLASS_TSC);
250PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
251PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
252PMC_MDEP_TABLE(haswell, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
253PMC_MDEP_TABLE(ivybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
254PMC_MDEP_TABLE(ivybridge_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
255PMC_MDEP_TABLE(sandybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
256PMC_MDEP_TABLE(sandybridge_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);

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

283 .pm_evc_event_table_size = \
284 PMC_EVENT_TABLE_SIZE(EVENTS), \
285 .pm_evc_allocate_pmc = ALLOCATOR##_allocate_pmc \
286 }
287
288#if defined(__i386__) || defined(__amd64__)
289PMC_CLASS_TABLE_DESC(iaf, IAF, iaf, iaf);
290PMC_CLASS_TABLE_DESC(atom, IAP, atom, iap);
255PMC_MDEP_TABLE(core, IAP, PMC_CLASS_SOFT, PMC_CLASS_TSC);
256PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
257PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
258PMC_MDEP_TABLE(haswell, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
259PMC_MDEP_TABLE(ivybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
260PMC_MDEP_TABLE(ivybridge_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
261PMC_MDEP_TABLE(sandybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
262PMC_MDEP_TABLE(sandybridge_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);

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

289 .pm_evc_event_table_size = \
290 PMC_EVENT_TABLE_SIZE(EVENTS), \
291 .pm_evc_allocate_pmc = ALLOCATOR##_allocate_pmc \
292 }
293
294#if defined(__i386__) || defined(__amd64__)
295PMC_CLASS_TABLE_DESC(iaf, IAF, iaf, iaf);
296PMC_CLASS_TABLE_DESC(atom, IAP, atom, iap);
297PMC_CLASS_TABLE_DESC(atom_silvermont, IAP, atom_silvermont, iap);
291PMC_CLASS_TABLE_DESC(core, IAP, core, iap);
292PMC_CLASS_TABLE_DESC(core2, IAP, core2, iap);
293PMC_CLASS_TABLE_DESC(corei7, IAP, corei7, iap);
294PMC_CLASS_TABLE_DESC(haswell, IAP, haswell, iap);
295PMC_CLASS_TABLE_DESC(ivybridge, IAP, ivybridge, iap);
296PMC_CLASS_TABLE_DESC(ivybridge_xeon, IAP, ivybridge_xeon, iap);
297PMC_CLASS_TABLE_DESC(sandybridge, IAP, sandybridge, iap);
298PMC_CLASS_TABLE_DESC(sandybridge_xeon, IAP, sandybridge_xeon, iap);

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

592 EV_ALIAS("instructions", "iap-inst-retired.any_p"),
593 EV_ALIAS("interrupts", "iap-hw-int-rcv"),
594 EV_ALIAS("unhalted-cycles", "iap-cpu-clk-unhalted.core_p"),
595 EV_ALIAS(NULL, NULL)
596};
597
598#define atom_aliases core2_aliases
599#define atom_aliases_without_iaf core2_aliases_without_iaf
298PMC_CLASS_TABLE_DESC(core, IAP, core, iap);
299PMC_CLASS_TABLE_DESC(core2, IAP, core2, iap);
300PMC_CLASS_TABLE_DESC(corei7, IAP, corei7, iap);
301PMC_CLASS_TABLE_DESC(haswell, IAP, haswell, iap);
302PMC_CLASS_TABLE_DESC(ivybridge, IAP, ivybridge, iap);
303PMC_CLASS_TABLE_DESC(ivybridge_xeon, IAP, ivybridge_xeon, iap);
304PMC_CLASS_TABLE_DESC(sandybridge, IAP, sandybridge, iap);
305PMC_CLASS_TABLE_DESC(sandybridge_xeon, IAP, sandybridge_xeon, iap);

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

599 EV_ALIAS("instructions", "iap-inst-retired.any_p"),
600 EV_ALIAS("interrupts", "iap-hw-int-rcv"),
601 EV_ALIAS("unhalted-cycles", "iap-cpu-clk-unhalted.core_p"),
602 EV_ALIAS(NULL, NULL)
603};
604
605#define atom_aliases core2_aliases
606#define atom_aliases_without_iaf core2_aliases_without_iaf
607#define atom_silvermont_aliases core2_aliases
608#define atom_silvermont_aliases_without_iaf core2_aliases_without_iaf
600#define corei7_aliases core2_aliases
601#define corei7_aliases_without_iaf core2_aliases_without_iaf
602#define haswell_aliases core2_aliases
603#define haswell_aliases_without_iaf core2_aliases_without_iaf
604#define ivybridge_aliases core2_aliases
605#define ivybridge_aliases_without_iaf core2_aliases_without_iaf
606#define ivybridge_xeon_aliases core2_aliases
607#define ivybridge_xeon_aliases_without_iaf core2_aliases_without_iaf

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

837 } else if (KWPREFIXMATCH(p, IAP_KW_CACHESTATE "=")) {
838 n = pmc_parse_mask(iap_cachestate_mask, p, &cachestate);
839 } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_CORE &&
840 KWPREFIXMATCH(p, IAP_KW_TRANSITION "=")) {
841 n = pmc_parse_mask(iap_transition_mask, p, &evmask);
842 if (n != 1)
843 return (-1);
844 } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_ATOM ||
609#define corei7_aliases core2_aliases
610#define corei7_aliases_without_iaf core2_aliases_without_iaf
611#define haswell_aliases core2_aliases
612#define haswell_aliases_without_iaf core2_aliases_without_iaf
613#define ivybridge_aliases core2_aliases
614#define ivybridge_aliases_without_iaf core2_aliases_without_iaf
615#define ivybridge_xeon_aliases core2_aliases
616#define ivybridge_xeon_aliases_without_iaf core2_aliases_without_iaf

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

846 } else if (KWPREFIXMATCH(p, IAP_KW_CACHESTATE "=")) {
847 n = pmc_parse_mask(iap_cachestate_mask, p, &cachestate);
848 } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_CORE &&
849 KWPREFIXMATCH(p, IAP_KW_TRANSITION "=")) {
850 n = pmc_parse_mask(iap_transition_mask, p, &evmask);
851 if (n != 1)
852 return (-1);
853 } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_ATOM ||
854 cpu_info.pm_cputype == PMC_CPU_INTEL_ATOM_SILVERMONT ||
845 cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2 ||
846 cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2EXTREME) {
847 if (KWPREFIXMATCH(p, IAP_KW_SNOOPRESPONSE "=")) {
848 n = pmc_parse_mask(iap_snoopresponse_mask, p,
849 &evmask);
850 } else if (KWPREFIXMATCH(p, IAP_KW_SNOOPTYPE "=")) {
851 n = pmc_parse_mask(iap_snooptype_mask, p,
852 &evmask);

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

2728 * spellings for the current CPU.
2729 */
2730 switch (cpu_info.pm_cputype) {
2731 default:
2732 case PMC_CPU_INTEL_ATOM:
2733 ev = atom_event_table;
2734 count = PMC_EVENT_TABLE_SIZE(atom);
2735 break;
855 cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2 ||
856 cpu_info.pm_cputype == PMC_CPU_INTEL_CORE2EXTREME) {
857 if (KWPREFIXMATCH(p, IAP_KW_SNOOPRESPONSE "=")) {
858 n = pmc_parse_mask(iap_snoopresponse_mask, p,
859 &evmask);
860 } else if (KWPREFIXMATCH(p, IAP_KW_SNOOPTYPE "=")) {
861 n = pmc_parse_mask(iap_snooptype_mask, p,
862 &evmask);

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

2738 * spellings for the current CPU.
2739 */
2740 switch (cpu_info.pm_cputype) {
2741 default:
2742 case PMC_CPU_INTEL_ATOM:
2743 ev = atom_event_table;
2744 count = PMC_EVENT_TABLE_SIZE(atom);
2745 break;
2746 case PMC_CPU_INTEL_ATOM_SILVERMONT:
2747 ev = atom_silvermont_event_table;
2748 count = PMC_EVENT_TABLE_SIZE(atom_silvermont);
2749 break;
2736 case PMC_CPU_INTEL_CORE:
2737 ev = core_event_table;
2738 count = PMC_EVENT_TABLE_SIZE(core);
2739 break;
2740 case PMC_CPU_INTEL_CORE2:
2741 case PMC_CPU_INTEL_CORE2EXTREME:
2742 ev = core2_event_table;
2743 count = PMC_EVENT_TABLE_SIZE(core2);

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

3044#if defined(__amd64__) || defined(__i386__)
3045 case PMC_CPU_AMD_K8:
3046 PMC_MDEP_INIT(k8);
3047 pmc_class_table[n] = &k8_class_table_descr;
3048 break;
3049 case PMC_CPU_INTEL_ATOM:
3050 PMC_MDEP_INIT_INTEL_V2(atom);
3051 break;
2750 case PMC_CPU_INTEL_CORE:
2751 ev = core_event_table;
2752 count = PMC_EVENT_TABLE_SIZE(core);
2753 break;
2754 case PMC_CPU_INTEL_CORE2:
2755 case PMC_CPU_INTEL_CORE2EXTREME:
2756 ev = core2_event_table;
2757 count = PMC_EVENT_TABLE_SIZE(core2);

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

3058#if defined(__amd64__) || defined(__i386__)
3059 case PMC_CPU_AMD_K8:
3060 PMC_MDEP_INIT(k8);
3061 pmc_class_table[n] = &k8_class_table_descr;
3062 break;
3063 case PMC_CPU_INTEL_ATOM:
3064 PMC_MDEP_INIT_INTEL_V2(atom);
3065 break;
3066 case PMC_CPU_INTEL_ATOM_SILVERMONT:
3067 PMC_MDEP_INIT_INTEL_V2(atom_silvermont);
3068 break;
3052 case PMC_CPU_INTEL_CORE:
3053 PMC_MDEP_INIT(core);
3054 pmc_class_table[n] = &core_class_table_descr;
3055 break;
3056 case PMC_CPU_INTEL_CORE2:
3057 case PMC_CPU_INTEL_CORE2EXTREME:
3058 PMC_MDEP_INIT_INTEL_V2(core2);
3059 break;

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

3197 ev = iaf_event_table;
3198 evfence = iaf_event_table + PMC_EVENT_TABLE_SIZE(iaf);
3199 } else if (pe >= PMC_EV_IAP_FIRST && pe <= PMC_EV_IAP_LAST) {
3200 switch (cpu) {
3201 case PMC_CPU_INTEL_ATOM:
3202 ev = atom_event_table;
3203 evfence = atom_event_table + PMC_EVENT_TABLE_SIZE(atom);
3204 break;
3069 case PMC_CPU_INTEL_CORE:
3070 PMC_MDEP_INIT(core);
3071 pmc_class_table[n] = &core_class_table_descr;
3072 break;
3073 case PMC_CPU_INTEL_CORE2:
3074 case PMC_CPU_INTEL_CORE2EXTREME:
3075 PMC_MDEP_INIT_INTEL_V2(core2);
3076 break;

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

3214 ev = iaf_event_table;
3215 evfence = iaf_event_table + PMC_EVENT_TABLE_SIZE(iaf);
3216 } else if (pe >= PMC_EV_IAP_FIRST && pe <= PMC_EV_IAP_LAST) {
3217 switch (cpu) {
3218 case PMC_CPU_INTEL_ATOM:
3219 ev = atom_event_table;
3220 evfence = atom_event_table + PMC_EVENT_TABLE_SIZE(atom);
3221 break;
3222 case PMC_CPU_INTEL_ATOM_SILVERMONT:
3223 ev = atom_silvermont_event_table;
3224 evfence = atom_silvermont_event_table +
3225 PMC_EVENT_TABLE_SIZE(atom_silvermont);
3226 break;
3205 case PMC_CPU_INTEL_CORE:
3206 ev = core_event_table;
3207 evfence = core_event_table + PMC_EVENT_TABLE_SIZE(core);
3208 break;
3209 case PMC_CPU_INTEL_CORE2:
3210 case PMC_CPU_INTEL_CORE2EXTREME:
3211 ev = core2_event_table;
3212 evfence = core2_event_table + PMC_EVENT_TABLE_SIZE(core2);

--- 292 unchanged lines hidden ---
3227 case PMC_CPU_INTEL_CORE:
3228 ev = core_event_table;
3229 evfence = core_event_table + PMC_EVENT_TABLE_SIZE(core);
3230 break;
3231 case PMC_CPU_INTEL_CORE2:
3232 case PMC_CPU_INTEL_CORE2EXTREME:
3233 ev = core2_event_table;
3234 evfence = core2_event_table + PMC_EVENT_TABLE_SIZE(core2);

--- 292 unchanged lines hidden ---