The Gaudi Framework  master (37c0b60a)
pfmlib_intel_nhm.h
Go to the documentation of this file.
1 /*
2  * Intel Nehalem PMU
3  *
4  * Copyright (c) 2008 Google, Inc
5  * Contributed by Stephane Eranian <eranian@gmail.com>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11  * of the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef __PFMLIB_NHM_H__
25 #define __PFMLIB_NHM_H__
26 
27 #include <perfmon/pfmlib.h>
28 /*
29  * privilege level mask usage for Intel Core
30  *
31  * PFM_PLM0 = OS (kernel, hypervisor, ..)
32  * PFM_PLM1 = unused (ignored)
33  * PFM_PLM2 = unused (ignored)
34  * PFM_PLM3 = USR (user level)
35  */
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * total number of counters:
43  * - 4 generic core
44  * - 3 fixed core
45  * - 1 uncore fixed
46  * - 8 uncore generic
47  */
48 #define PMU_NHM_NUM_COUNTERS 16
49 
50 typedef union {
51  unsigned long long val; /* complete register value */
52  struct {
53  unsigned long sel_event : 8; /* event mask */
54  unsigned long sel_umask : 8; /* unit mask */
55  unsigned long sel_usr : 1; /* user level */
56  unsigned long sel_os : 1; /* system level */
57  unsigned long sel_edge : 1; /* edge detec */
58  unsigned long sel_pc : 1; /* pin control */
59  unsigned long sel_int : 1; /* enable APIC intr */
60  unsigned long sel_anythr : 1; /* measure any thread */
61  unsigned long sel_en : 1; /* enable */
62  unsigned long sel_inv : 1; /* invert counter mask */
63  unsigned long sel_cnt_mask : 8; /* counter mask */
64  unsigned long sel_res2 : 32;
65  } perfevtsel;
66  struct {
67  unsigned long usel_event : 8; /* event select */
68  unsigned long usel_umask : 8; /* event unit mask */
69  unsigned long usel_res1 : 1; /* reserved */
70  unsigned long usel_occ : 1; /* occupancy reset */
71  unsigned long usel_edge : 1; /* edge detection */
72  unsigned long usel_res2 : 1; /* reserved */
73  unsigned long usel_int : 1; /* PMI enable */
74  unsigned long usel_res3 : 1; /* reserved */
75  unsigned long usel_en : 1; /* enable */
76  unsigned long usel_inv : 1; /* invert */
77  unsigned long usel_cnt_mask : 8; /* counter mask */
78  unsigned long usel_res4 : 32; /* reserved */
79  } unc_perfevtsel;
80  struct {
81  unsigned long cpl_eq0 : 1; /* filter out branches at pl0 */
82  unsigned long cpl_neq0 : 1; /* filter out branches at pl1-pl3 */
83  unsigned long jcc : 1; /* filter out condition branches */
84  unsigned long near_rel_call : 1; /* filter out near relative calls */
85  unsigned long near_ind_call : 1; /* filter out near indirect calls */
86  unsigned long near_ret : 1; /* filter out near returns */
87  unsigned long near_ind_jmp : 1; /* filter out near unconditional jmp/calls */
88  unsigned long near_rel_jmp : 1; /* filter out near uncoditional relative jmp */
89  unsigned long far_branch : 1; /* filter out far branches */
90  unsigned long reserved1 : 23; /* reserved */
91  unsigned long reserved2 : 32; /* reserved */
92  } lbr_select;
94 
95 typedef struct {
96  unsigned long cnt_mask; /* counter mask (occurences) */
97  unsigned int flags; /* counter specific flag */
99 
100 /*
101  * flags for pfmlib_nhm_counter_t
102  */
103 #define PFM_NHM_SEL_INV 0x1 /* inverse */
104 #define PFM_NHM_SEL_EDGE 0x2 /* edge detect */
105 #define PFM_NHM_SEL_ANYTHR 0x4 /* any thread (core only) */
106 #define PFM_NHM_SEL_OCC_RST 0x8 /* reset occupancy (uncore only) */
107 
108 typedef struct {
109  unsigned int lbr_used; /* set to 1 if LBR is used */
110  unsigned int lbr_plm; /* priv level PLM0 or PLM3 */
111  unsigned int lbr_filter; /* filters */
113 
114 /*
115  * lbr_filter: filter out branches
116  * refer to IA32 SDM vol3b section 18.6.2
117  */
118 #define PFM_NHM_LBR_JCC 0x4 /* do not capture conditional branches */
119 #define PFM_NHM_LBR_NEAR_REL_CALL 0x8 /* do not capture near calls */
120 #define PFM_NHM_LBR_NEAR_IND_CALL 0x10 /* do not capture indirect calls */
121 #define PFM_NHM_LBR_NEAR_RET 0x20 /* do not capture near returns */
122 #define PFM_NHM_LBR_NEAR_IND_JMP 0x40 /* do not capture indirect jumps */
123 #define PFM_NHM_LBR_NEAR_REL_JMP 0x80 /* do not capture near relative jumps */
124 #define PFM_NHM_LBR_FAR_BRANCH 0x100 /* do not capture far branches */
125 #define PFM_NHM_LBR_ALL 0x1fc /* filter out all branches */
126 
127 /*
128  * PEBS input parameters
129  */
130 typedef struct {
131  unsigned int pebs_used; /* set to 1 if PEBS is used */
132  unsigned int ld_lat_thres; /* load latency threshold (cycles) */
134 
135 /*
136  * model-specific input parameter to pfm_dispatch_events()
137  */
138 typedef struct {
140  pfmlib_nhm_pebs_t pfp_nhm_pebs; /* PEBS settings */
141  pfmlib_nhm_lbr_t pfp_nhm_lbr; /* LBR settings */
142  uint64_t reserved[4]; /* for future use */
144 
145 /*
146  * no pfmlib_nhm_output_param_t defined
147  */
148 
149 /*
150  * Model-specific interface
151  * can be called directly
152  */
155 extern int pfm_nhm_data_src_desc( unsigned int val, char** desc );
156 
157 #ifdef __cplusplus /* extern C */
158 }
159 #endif
160 
161 #endif /* __PFMLIB_NHM_H__ */
pfm_nhm_sel_reg_t::near_rel_jmp
unsigned long near_rel_jmp
Definition: pfmlib_intel_nhm.h:88
pfm_nhm_sel_reg_t::jcc
unsigned long jcc
Definition: pfmlib_intel_nhm.h:83
pfm_nhm_sel_reg_t::usel_res3
unsigned long usel_res3
Definition: pfmlib_intel_nhm.h:74
pfmlib_nhm_counter_t
Definition: pfmlib_intel_nhm.h:95
pfm_nhm_sel_reg_t::sel_usr
unsigned long sel_usr
Definition: pfmlib_intel_nhm.h:55
pfm_nhm_sel_reg_t::usel_en
unsigned long usel_en
Definition: pfmlib_intel_nhm.h:75
pfm_nhm_is_uncore
int pfm_nhm_is_uncore(pfmlib_event_t *e)
pfm_nhm_sel_reg_t::usel_edge
unsigned long usel_edge
Definition: pfmlib_intel_nhm.h:71
pfmlib_nhm_lbr_t::lbr_used
unsigned int lbr_used
Definition: pfmlib_intel_nhm.h:109
pfm_nhm_sel_reg_t::usel_occ
unsigned long usel_occ
Definition: pfmlib_intel_nhm.h:70
pfm_nhm_is_pebs
int pfm_nhm_is_pebs(pfmlib_event_t *e)
pfm_nhm_sel_reg_t::sel_res2
unsigned long sel_res2
Definition: pfmlib_intel_nhm.h:64
pfm_nhm_sel_reg_t::usel_cnt_mask
unsigned long usel_cnt_mask
Definition: pfmlib_intel_nhm.h:77
pfm_nhm_sel_reg_t::usel_res4
unsigned long usel_res4
Definition: pfmlib_intel_nhm.h:78
pfm_nhm_sel_reg_t::sel_inv
unsigned long sel_inv
Definition: pfmlib_intel_nhm.h:62
pfm_nhm_sel_reg_t::sel_pc
unsigned long sel_pc
Definition: pfmlib_intel_nhm.h:58
PMU_NHM_NUM_COUNTERS
#define PMU_NHM_NUM_COUNTERS
Definition: pfmlib_intel_nhm.h:48
pfm_nhm_sel_reg_t::near_ret
unsigned long near_ret
Definition: pfmlib_intel_nhm.h:86
pfmlib_nhm_input_param_t::pfp_nhm_pebs
pfmlib_nhm_pebs_t pfp_nhm_pebs
Definition: pfmlib_intel_nhm.h:140
pfmlib_nhm_counter_t::flags
unsigned int flags
Definition: pfmlib_intel_nhm.h:97
pfm_nhm_sel_reg_t::cpl_neq0
unsigned long cpl_neq0
Definition: pfmlib_intel_nhm.h:82
pfm_nhm_sel_reg_t::usel_umask
unsigned long usel_umask
Definition: pfmlib_intel_nhm.h:68
pfmlib_nhm_input_param_t
Definition: pfmlib_intel_nhm.h:138
pfm_nhm_sel_reg_t::far_branch
unsigned long far_branch
Definition: pfmlib_intel_nhm.h:89
pfm_nhm_sel_reg_t::sel_anythr
unsigned long sel_anythr
Definition: pfmlib_intel_nhm.h:60
pfmlib_nhm_pebs_t::ld_lat_thres
unsigned int ld_lat_thres
Definition: pfmlib_intel_nhm.h:132
pfm_nhm_sel_reg_t::reserved1
unsigned long reserved1
Definition: pfmlib_intel_nhm.h:90
pfm_nhm_sel_reg_t::val
unsigned long long val
Definition: pfmlib_intel_nhm.h:51
pfmlib_nhm_input_param_t::pfp_nhm_lbr
pfmlib_nhm_lbr_t pfp_nhm_lbr
Definition: pfmlib_intel_nhm.h:141
pfmlib_nhm_lbr_t::lbr_filter
unsigned int lbr_filter
Definition: pfmlib_intel_nhm.h:111
pfm_nhm_sel_reg_t::sel_umask
unsigned long sel_umask
Definition: pfmlib_intel_nhm.h:54
pfmlib_nhm_counter_t::cnt_mask
unsigned long cnt_mask
Definition: pfmlib_intel_nhm.h:96
pfm_nhm_sel_reg_t::sel_edge
unsigned long sel_edge
Definition: pfmlib_intel_nhm.h:57
pfm_nhm_sel_reg_t::cpl_eq0
unsigned long cpl_eq0
Definition: pfmlib_intel_nhm.h:81
pfm_nhm_sel_reg_t::sel_cnt_mask
unsigned long sel_cnt_mask
Definition: pfmlib_intel_nhm.h:63
pfm_nhm_sel_reg_t::near_ind_jmp
unsigned long near_ind_jmp
Definition: pfmlib_intel_nhm.h:87
pfm_nhm_sel_reg_t::usel_inv
unsigned long usel_inv
Definition: pfmlib_intel_nhm.h:76
pfmlib_nhm_lbr_t::lbr_plm
unsigned int lbr_plm
Definition: pfmlib_intel_nhm.h:110
pfmlib_nhm_lbr_t
Definition: pfmlib_intel_nhm.h:108
pfm_nhm_sel_reg_t::sel_en
unsigned long sel_en
Definition: pfmlib_intel_nhm.h:61
pfm_nhm_sel_reg_t::usel_res2
unsigned long usel_res2
Definition: pfmlib_intel_nhm.h:72
pfmlib.h
pfm_nhm_sel_reg_t::sel_os
unsigned long sel_os
Definition: pfmlib_intel_nhm.h:56
pfm_nhm_sel_reg_t::near_rel_call
unsigned long near_rel_call
Definition: pfmlib_intel_nhm.h:84
pfmlib_event_t
Definition: pfmlib.h:84
pfm_nhm_sel_reg_t
Definition: pfmlib_intel_nhm.h:50
pfm_nhm_sel_reg_t::usel_res1
unsigned long usel_res1
Definition: pfmlib_intel_nhm.h:69
pfm_nhm_sel_reg_t::usel_event
unsigned long usel_event
Definition: pfmlib_intel_nhm.h:67
pfmlib_nhm_pebs_t::pebs_used
unsigned int pebs_used
Definition: pfmlib_intel_nhm.h:131
pfm_nhm_sel_reg_t::usel_int
unsigned long usel_int
Definition: pfmlib_intel_nhm.h:73
pfmlib_nhm_pebs_t
Definition: pfmlib_intel_nhm.h:130
pfm_nhm_sel_reg_t::sel_event
unsigned long sel_event
Definition: pfmlib_intel_nhm.h:53
pfm_nhm_sel_reg_t::sel_int
unsigned long sel_int
Definition: pfmlib_intel_nhm.h:59
pfm_nhm_sel_reg_t::reserved2
unsigned long reserved2
Definition: pfmlib_intel_nhm.h:91
pfm_nhm_data_src_desc
int pfm_nhm_data_src_desc(unsigned int val, char **desc)
pfm_nhm_sel_reg_t::near_ind_call
unsigned long near_ind_call
Definition: pfmlib_intel_nhm.h:85