| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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;
93 } pfm_nhm_sel_reg_t;
94
95 typedef struct {
96 unsigned long cnt_mask; /* counter mask (occurences) */
97 unsigned int flags; /* counter specific flag */
98 } pfmlib_nhm_counter_t;
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 */
112 } pfmlib_nhm_lbr_t;
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) */
133 } pfmlib_nhm_pebs_t;
134
135
136 /*
137 * model-specific input parameter to pfm_dispatch_events()
138 */
139 typedef struct {
140 pfmlib_nhm_counter_t pfp_nhm_counters[PMU_NHM_NUM_COUNTERS];
141 pfmlib_nhm_pebs_t pfp_nhm_pebs; /* PEBS settings */
142 pfmlib_nhm_lbr_t pfp_nhm_lbr; /* LBR settings */
143 uint64_t reserved[4]; /* for future use */
144 } pfmlib_nhm_input_param_t;
145
146 /*
147 * no pfmlib_nhm_output_param_t defined
148 */
149
150 /*
151 * Model-specific interface
152 * can be called directly
153 */
154 extern int pfm_nhm_is_pebs(pfmlib_event_t *e);
155 extern int pfm_nhm_is_uncore(pfmlib_event_t *e);
156 extern int pfm_nhm_data_src_desc(unsigned int val, char **desc);
157
158 #ifdef __cplusplus /* extern C */
159 }
160 #endif
161
162 #endif /* __PFMLIB_NHM_H__ */
pfmlib_event_t
Definition: pfmlib.h:85
pfmlib_nhm_pebs_t
Definition: pfmlib_intel_nhm.h:130
uint64_t
unsigned long long uint64_t
Definition: instrset.h:144
pfmlib_nhm_input_param_t::pfp_nhm_lbr
pfmlib_nhm_lbr_t pfp_nhm_lbr
Definition: pfmlib_intel_nhm.h:142
pfm_nhm_data_src_desc
int pfm_nhm_data_src_desc(unsigned int val, char **desc)
pfmlib_nhm_pebs_t::ld_lat_thres
unsigned int ld_lat_thres
Definition: pfmlib_intel_nhm.h:132
pfmlib_nhm_counter_t
Definition: pfmlib_intel_nhm.h:95
pfmlib_nhm_lbr_t::lbr_used
unsigned int lbr_used
Definition: pfmlib_intel_nhm.h:109
PMU_NHM_NUM_COUNTERS
#define PMU_NHM_NUM_COUNTERS
Definition: pfmlib_intel_nhm.h:48
pfmlib_nhm_pebs_t::pebs_used
unsigned int pebs_used
Definition: pfmlib_intel_nhm.h:131
pfmlib_nhm_lbr_t::lbr_filter
unsigned int lbr_filter
Definition: pfmlib_intel_nhm.h:111
pfmlib_nhm_input_param_t::pfp_nhm_pebs
pfmlib_nhm_pebs_t pfp_nhm_pebs
Definition: pfmlib_intel_nhm.h:141
pfmlib_nhm_counter_t::flags
unsigned int flags
Definition: pfmlib_intel_nhm.h:97
pfmlib_nhm_input_param_t
Definition: pfmlib_intel_nhm.h:139
pfmlib.h
pfmlib_nhm_lbr_t
Definition: pfmlib_intel_nhm.h:108
pfmlib_nhm_lbr_t::lbr_plm
unsigned int lbr_plm
Definition: pfmlib_intel_nhm.h:110
pfmlib_nhm_counter_t::cnt_mask
unsigned long cnt_mask
Definition: pfmlib_intel_nhm.h:96
pfm_nhm_is_uncore
int pfm_nhm_is_uncore(pfmlib_event_t *e)
pfm_nhm_sel_reg_t::val
unsigned long long val
Definition: pfmlib_intel_nhm.h:51
pfm_nhm_is_pebs
int pfm_nhm_is_pebs(pfmlib_event_t *e)
pfm_nhm_sel_reg_t
Definition: pfmlib_intel_nhm.h:50