perf_event_intel.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. #ifdef CONFIG_CPU_SUP_INTEL
  2. /*
  3. * Intel PerfMon, used on Core and later.
  4. */
  5. static const u64 intel_perfmon_event_map[] =
  6. {
  7. [PERF_COUNT_HW_CPU_CYCLES] = 0x003c,
  8. [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
  9. [PERF_COUNT_HW_CACHE_REFERENCES] = 0x4f2e,
  10. [PERF_COUNT_HW_CACHE_MISSES] = 0x412e,
  11. [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4,
  12. [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5,
  13. [PERF_COUNT_HW_BUS_CYCLES] = 0x013c,
  14. };
  15. static struct event_constraint intel_core_event_constraints[] =
  16. {
  17. INTEL_EVENT_CONSTRAINT(0x11, 0x2), /* FP_ASSIST */
  18. INTEL_EVENT_CONSTRAINT(0x12, 0x2), /* MUL */
  19. INTEL_EVENT_CONSTRAINT(0x13, 0x2), /* DIV */
  20. INTEL_EVENT_CONSTRAINT(0x14, 0x1), /* CYCLES_DIV_BUSY */
  21. INTEL_EVENT_CONSTRAINT(0x19, 0x2), /* DELAYED_BYPASS */
  22. INTEL_EVENT_CONSTRAINT(0xc1, 0x1), /* FP_COMP_INSTR_RET */
  23. EVENT_CONSTRAINT_END
  24. };
  25. static struct event_constraint intel_core2_event_constraints[] =
  26. {
  27. FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
  28. FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
  29. /*
  30. * Core2 has Fixed Counter 2 listed as CPU_CLK_UNHALTED.REF and event
  31. * 0x013c as CPU_CLK_UNHALTED.BUS and specifies there is a fixed
  32. * ratio between these counters.
  33. */
  34. /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */
  35. INTEL_EVENT_CONSTRAINT(0x10, 0x1), /* FP_COMP_OPS_EXE */
  36. INTEL_EVENT_CONSTRAINT(0x11, 0x2), /* FP_ASSIST */
  37. INTEL_EVENT_CONSTRAINT(0x12, 0x2), /* MUL */
  38. INTEL_EVENT_CONSTRAINT(0x13, 0x2), /* DIV */
  39. INTEL_EVENT_CONSTRAINT(0x14, 0x1), /* CYCLES_DIV_BUSY */
  40. INTEL_EVENT_CONSTRAINT(0x18, 0x1), /* IDLE_DURING_DIV */
  41. INTEL_EVENT_CONSTRAINT(0x19, 0x2), /* DELAYED_BYPASS */
  42. INTEL_EVENT_CONSTRAINT(0xa1, 0x1), /* RS_UOPS_DISPATCH_CYCLES */
  43. INTEL_EVENT_CONSTRAINT(0xc9, 0x1), /* ITLB_MISS_RETIRED (T30-9) */
  44. INTEL_EVENT_CONSTRAINT(0xcb, 0x1), /* MEM_LOAD_RETIRED */
  45. EVENT_CONSTRAINT_END
  46. };
  47. static struct event_constraint intel_nehalem_event_constraints[] =
  48. {
  49. FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
  50. FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
  51. /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */
  52. INTEL_EVENT_CONSTRAINT(0x40, 0x3), /* L1D_CACHE_LD */
  53. INTEL_EVENT_CONSTRAINT(0x41, 0x3), /* L1D_CACHE_ST */
  54. INTEL_EVENT_CONSTRAINT(0x42, 0x3), /* L1D_CACHE_LOCK */
  55. INTEL_EVENT_CONSTRAINT(0x43, 0x3), /* L1D_ALL_REF */
  56. INTEL_EVENT_CONSTRAINT(0x48, 0x3), /* L1D_PEND_MISS */
  57. INTEL_EVENT_CONSTRAINT(0x4e, 0x3), /* L1D_PREFETCH */
  58. INTEL_EVENT_CONSTRAINT(0x51, 0x3), /* L1D */
  59. INTEL_EVENT_CONSTRAINT(0x63, 0x3), /* CACHE_LOCK_CYCLES */
  60. EVENT_CONSTRAINT_END
  61. };
  62. static struct event_constraint intel_westmere_event_constraints[] =
  63. {
  64. FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
  65. FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
  66. /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */
  67. INTEL_EVENT_CONSTRAINT(0x51, 0x3), /* L1D */
  68. INTEL_EVENT_CONSTRAINT(0x60, 0x1), /* OFFCORE_REQUESTS_OUTSTANDING */
  69. INTEL_EVENT_CONSTRAINT(0x63, 0x3), /* CACHE_LOCK_CYCLES */
  70. INTEL_EVENT_CONSTRAINT(0xb3, 0x1), /* SNOOPQ_REQUEST_OUTSTANDING */
  71. EVENT_CONSTRAINT_END
  72. };
  73. static struct event_constraint intel_gen_event_constraints[] =
  74. {
  75. FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
  76. FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
  77. /* FIXED_EVENT_CONSTRAINT(0x013c, 2), CPU_CLK_UNHALTED.REF */
  78. EVENT_CONSTRAINT_END
  79. };
  80. static u64 intel_pmu_event_map(int hw_event)
  81. {
  82. return intel_perfmon_event_map[hw_event];
  83. }
  84. static __initconst const u64 westmere_hw_cache_event_ids
  85. [PERF_COUNT_HW_CACHE_MAX]
  86. [PERF_COUNT_HW_CACHE_OP_MAX]
  87. [PERF_COUNT_HW_CACHE_RESULT_MAX] =
  88. {
  89. [ C(L1D) ] = {
  90. [ C(OP_READ) ] = {
  91. [ C(RESULT_ACCESS) ] = 0x010b, /* MEM_INST_RETIRED.LOADS */
  92. [ C(RESULT_MISS) ] = 0x0151, /* L1D.REPL */
  93. },
  94. [ C(OP_WRITE) ] = {
  95. [ C(RESULT_ACCESS) ] = 0x020b, /* MEM_INST_RETURED.STORES */
  96. [ C(RESULT_MISS) ] = 0x0251, /* L1D.M_REPL */
  97. },
  98. [ C(OP_PREFETCH) ] = {
  99. [ C(RESULT_ACCESS) ] = 0x014e, /* L1D_PREFETCH.REQUESTS */
  100. [ C(RESULT_MISS) ] = 0x024e, /* L1D_PREFETCH.MISS */
  101. },
  102. },
  103. [ C(L1I ) ] = {
  104. [ C(OP_READ) ] = {
  105. [ C(RESULT_ACCESS) ] = 0x0380, /* L1I.READS */
  106. [ C(RESULT_MISS) ] = 0x0280, /* L1I.MISSES */
  107. },
  108. [ C(OP_WRITE) ] = {
  109. [ C(RESULT_ACCESS) ] = -1,
  110. [ C(RESULT_MISS) ] = -1,
  111. },
  112. [ C(OP_PREFETCH) ] = {
  113. [ C(RESULT_ACCESS) ] = 0x0,
  114. [ C(RESULT_MISS) ] = 0x0,
  115. },
  116. },
  117. [ C(LL ) ] = {
  118. [ C(OP_READ) ] = {
  119. [ C(RESULT_ACCESS) ] = 0x0324, /* L2_RQSTS.LOADS */
  120. [ C(RESULT_MISS) ] = 0x0224, /* L2_RQSTS.LD_MISS */
  121. },
  122. [ C(OP_WRITE) ] = {
  123. [ C(RESULT_ACCESS) ] = 0x0c24, /* L2_RQSTS.RFOS */
  124. [ C(RESULT_MISS) ] = 0x0824, /* L2_RQSTS.RFO_MISS */
  125. },
  126. [ C(OP_PREFETCH) ] = {
  127. [ C(RESULT_ACCESS) ] = 0x4f2e, /* LLC Reference */
  128. [ C(RESULT_MISS) ] = 0x412e, /* LLC Misses */
  129. },
  130. },
  131. [ C(DTLB) ] = {
  132. [ C(OP_READ) ] = {
  133. [ C(RESULT_ACCESS) ] = 0x010b, /* MEM_INST_RETIRED.LOADS */
  134. [ C(RESULT_MISS) ] = 0x0108, /* DTLB_LOAD_MISSES.ANY */
  135. },
  136. [ C(OP_WRITE) ] = {
  137. [ C(RESULT_ACCESS) ] = 0x020b, /* MEM_INST_RETURED.STORES */
  138. [ C(RESULT_MISS) ] = 0x010c, /* MEM_STORE_RETIRED.DTLB_MISS */
  139. },
  140. [ C(OP_PREFETCH) ] = {
  141. [ C(RESULT_ACCESS) ] = 0x0,
  142. [ C(RESULT_MISS) ] = 0x0,
  143. },
  144. },
  145. [ C(ITLB) ] = {
  146. [ C(OP_READ) ] = {
  147. [ C(RESULT_ACCESS) ] = 0x01c0, /* INST_RETIRED.ANY_P */
  148. [ C(RESULT_MISS) ] = 0x0185, /* ITLB_MISSES.ANY */
  149. },
  150. [ C(OP_WRITE) ] = {
  151. [ C(RESULT_ACCESS) ] = -1,
  152. [ C(RESULT_MISS) ] = -1,
  153. },
  154. [ C(OP_PREFETCH) ] = {
  155. [ C(RESULT_ACCESS) ] = -1,
  156. [ C(RESULT_MISS) ] = -1,
  157. },
  158. },
  159. [ C(BPU ) ] = {
  160. [ C(OP_READ) ] = {
  161. [ C(RESULT_ACCESS) ] = 0x00c4, /* BR_INST_RETIRED.ALL_BRANCHES */
  162. [ C(RESULT_MISS) ] = 0x03e8, /* BPU_CLEARS.ANY */
  163. },
  164. [ C(OP_WRITE) ] = {
  165. [ C(RESULT_ACCESS) ] = -1,
  166. [ C(RESULT_MISS) ] = -1,
  167. },
  168. [ C(OP_PREFETCH) ] = {
  169. [ C(RESULT_ACCESS) ] = -1,
  170. [ C(RESULT_MISS) ] = -1,
  171. },
  172. },
  173. };
  174. static __initconst const u64 nehalem_hw_cache_event_ids
  175. [PERF_COUNT_HW_CACHE_MAX]
  176. [PERF_COUNT_HW_CACHE_OP_MAX]
  177. [PERF_COUNT_HW_CACHE_RESULT_MAX] =
  178. {
  179. [ C(L1D) ] = {
  180. [ C(OP_READ) ] = {
  181. [ C(RESULT_ACCESS) ] = 0x0f40, /* L1D_CACHE_LD.MESI */
  182. [ C(RESULT_MISS) ] = 0x0140, /* L1D_CACHE_LD.I_STATE */
  183. },
  184. [ C(OP_WRITE) ] = {
  185. [ C(RESULT_ACCESS) ] = 0x0f41, /* L1D_CACHE_ST.MESI */
  186. [ C(RESULT_MISS) ] = 0x0141, /* L1D_CACHE_ST.I_STATE */
  187. },
  188. [ C(OP_PREFETCH) ] = {
  189. [ C(RESULT_ACCESS) ] = 0x014e, /* L1D_PREFETCH.REQUESTS */
  190. [ C(RESULT_MISS) ] = 0x024e, /* L1D_PREFETCH.MISS */
  191. },
  192. },
  193. [ C(L1I ) ] = {
  194. [ C(OP_READ) ] = {
  195. [ C(RESULT_ACCESS) ] = 0x0380, /* L1I.READS */
  196. [ C(RESULT_MISS) ] = 0x0280, /* L1I.MISSES */
  197. },
  198. [ C(OP_WRITE) ] = {
  199. [ C(RESULT_ACCESS) ] = -1,
  200. [ C(RESULT_MISS) ] = -1,
  201. },
  202. [ C(OP_PREFETCH) ] = {
  203. [ C(RESULT_ACCESS) ] = 0x0,
  204. [ C(RESULT_MISS) ] = 0x0,
  205. },
  206. },
  207. [ C(LL ) ] = {
  208. [ C(OP_READ) ] = {
  209. [ C(RESULT_ACCESS) ] = 0x0324, /* L2_RQSTS.LOADS */
  210. [ C(RESULT_MISS) ] = 0x0224, /* L2_RQSTS.LD_MISS */
  211. },
  212. [ C(OP_WRITE) ] = {
  213. [ C(RESULT_ACCESS) ] = 0x0c24, /* L2_RQSTS.RFOS */
  214. [ C(RESULT_MISS) ] = 0x0824, /* L2_RQSTS.RFO_MISS */
  215. },
  216. [ C(OP_PREFETCH) ] = {
  217. [ C(RESULT_ACCESS) ] = 0x4f2e, /* LLC Reference */
  218. [ C(RESULT_MISS) ] = 0x412e, /* LLC Misses */
  219. },
  220. },
  221. [ C(DTLB) ] = {
  222. [ C(OP_READ) ] = {
  223. [ C(RESULT_ACCESS) ] = 0x0f40, /* L1D_CACHE_LD.MESI (alias) */
  224. [ C(RESULT_MISS) ] = 0x0108, /* DTLB_LOAD_MISSES.ANY */
  225. },
  226. [ C(OP_WRITE) ] = {
  227. [ C(RESULT_ACCESS) ] = 0x0f41, /* L1D_CACHE_ST.MESI (alias) */
  228. [ C(RESULT_MISS) ] = 0x010c, /* MEM_STORE_RETIRED.DTLB_MISS */
  229. },
  230. [ C(OP_PREFETCH) ] = {
  231. [ C(RESULT_ACCESS) ] = 0x0,
  232. [ C(RESULT_MISS) ] = 0x0,
  233. },
  234. },
  235. [ C(ITLB) ] = {
  236. [ C(OP_READ) ] = {
  237. [ C(RESULT_ACCESS) ] = 0x01c0, /* INST_RETIRED.ANY_P */
  238. [ C(RESULT_MISS) ] = 0x20c8, /* ITLB_MISS_RETIRED */
  239. },
  240. [ C(OP_WRITE) ] = {
  241. [ C(RESULT_ACCESS) ] = -1,
  242. [ C(RESULT_MISS) ] = -1,
  243. },
  244. [ C(OP_PREFETCH) ] = {
  245. [ C(RESULT_ACCESS) ] = -1,
  246. [ C(RESULT_MISS) ] = -1,
  247. },
  248. },
  249. [ C(BPU ) ] = {
  250. [ C(OP_READ) ] = {
  251. [ C(RESULT_ACCESS) ] = 0x00c4, /* BR_INST_RETIRED.ALL_BRANCHES */
  252. [ C(RESULT_MISS) ] = 0x03e8, /* BPU_CLEARS.ANY */
  253. },
  254. [ C(OP_WRITE) ] = {
  255. [ C(RESULT_ACCESS) ] = -1,
  256. [ C(RESULT_MISS) ] = -1,
  257. },
  258. [ C(OP_PREFETCH) ] = {
  259. [ C(RESULT_ACCESS) ] = -1,
  260. [ C(RESULT_MISS) ] = -1,
  261. },
  262. },
  263. };
  264. static __initconst const u64 core2_hw_cache_event_ids
  265. [PERF_COUNT_HW_CACHE_MAX]
  266. [PERF_COUNT_HW_CACHE_OP_MAX]
  267. [PERF_COUNT_HW_CACHE_RESULT_MAX] =
  268. {
  269. [ C(L1D) ] = {
  270. [ C(OP_READ) ] = {
  271. [ C(RESULT_ACCESS) ] = 0x0f40, /* L1D_CACHE_LD.MESI */
  272. [ C(RESULT_MISS) ] = 0x0140, /* L1D_CACHE_LD.I_STATE */
  273. },
  274. [ C(OP_WRITE) ] = {
  275. [ C(RESULT_ACCESS) ] = 0x0f41, /* L1D_CACHE_ST.MESI */
  276. [ C(RESULT_MISS) ] = 0x0141, /* L1D_CACHE_ST.I_STATE */
  277. },
  278. [ C(OP_PREFETCH) ] = {
  279. [ C(RESULT_ACCESS) ] = 0x104e, /* L1D_PREFETCH.REQUESTS */
  280. [ C(RESULT_MISS) ] = 0,
  281. },
  282. },
  283. [ C(L1I ) ] = {
  284. [ C(OP_READ) ] = {
  285. [ C(RESULT_ACCESS) ] = 0x0080, /* L1I.READS */
  286. [ C(RESULT_MISS) ] = 0x0081, /* L1I.MISSES */
  287. },
  288. [ C(OP_WRITE) ] = {
  289. [ C(RESULT_ACCESS) ] = -1,
  290. [ C(RESULT_MISS) ] = -1,
  291. },
  292. [ C(OP_PREFETCH) ] = {
  293. [ C(RESULT_ACCESS) ] = 0,
  294. [ C(RESULT_MISS) ] = 0,
  295. },
  296. },
  297. [ C(LL ) ] = {
  298. [ C(OP_READ) ] = {
  299. [ C(RESULT_ACCESS) ] = 0x4f29, /* L2_LD.MESI */
  300. [ C(RESULT_MISS) ] = 0x4129, /* L2_LD.ISTATE */
  301. },
  302. [ C(OP_WRITE) ] = {
  303. [ C(RESULT_ACCESS) ] = 0x4f2A, /* L2_ST.MESI */
  304. [ C(RESULT_MISS) ] = 0x412A, /* L2_ST.ISTATE */
  305. },
  306. [ C(OP_PREFETCH) ] = {
  307. [ C(RESULT_ACCESS) ] = 0,
  308. [ C(RESULT_MISS) ] = 0,
  309. },
  310. },
  311. [ C(DTLB) ] = {
  312. [ C(OP_READ) ] = {
  313. [ C(RESULT_ACCESS) ] = 0x0f40, /* L1D_CACHE_LD.MESI (alias) */
  314. [ C(RESULT_MISS) ] = 0x0208, /* DTLB_MISSES.MISS_LD */
  315. },
  316. [ C(OP_WRITE) ] = {
  317. [ C(RESULT_ACCESS) ] = 0x0f41, /* L1D_CACHE_ST.MESI (alias) */
  318. [ C(RESULT_MISS) ] = 0x0808, /* DTLB_MISSES.MISS_ST */
  319. },
  320. [ C(OP_PREFETCH) ] = {
  321. [ C(RESULT_ACCESS) ] = 0,
  322. [ C(RESULT_MISS) ] = 0,
  323. },
  324. },
  325. [ C(ITLB) ] = {
  326. [ C(OP_READ) ] = {
  327. [ C(RESULT_ACCESS) ] = 0x00c0, /* INST_RETIRED.ANY_P */
  328. [ C(RESULT_MISS) ] = 0x1282, /* ITLBMISSES */
  329. },
  330. [ C(OP_WRITE) ] = {
  331. [ C(RESULT_ACCESS) ] = -1,
  332. [ C(RESULT_MISS) ] = -1,
  333. },
  334. [ C(OP_PREFETCH) ] = {
  335. [ C(RESULT_ACCESS) ] = -1,
  336. [ C(RESULT_MISS) ] = -1,
  337. },
  338. },
  339. [ C(BPU ) ] = {
  340. [ C(OP_READ) ] = {
  341. [ C(RESULT_ACCESS) ] = 0x00c4, /* BR_INST_RETIRED.ANY */
  342. [ C(RESULT_MISS) ] = 0x00c5, /* BP_INST_RETIRED.MISPRED */
  343. },
  344. [ C(OP_WRITE) ] = {
  345. [ C(RESULT_ACCESS) ] = -1,
  346. [ C(RESULT_MISS) ] = -1,
  347. },
  348. [ C(OP_PREFETCH) ] = {
  349. [ C(RESULT_ACCESS) ] = -1,
  350. [ C(RESULT_MISS) ] = -1,
  351. },
  352. },
  353. };
  354. static __initconst const u64 atom_hw_cache_event_ids
  355. [PERF_COUNT_HW_CACHE_MAX]
  356. [PERF_COUNT_HW_CACHE_OP_MAX]
  357. [PERF_COUNT_HW_CACHE_RESULT_MAX] =
  358. {
  359. [ C(L1D) ] = {
  360. [ C(OP_READ) ] = {
  361. [ C(RESULT_ACCESS) ] = 0x2140, /* L1D_CACHE.LD */
  362. [ C(RESULT_MISS) ] = 0,
  363. },
  364. [ C(OP_WRITE) ] = {
  365. [ C(RESULT_ACCESS) ] = 0x2240, /* L1D_CACHE.ST */
  366. [ C(RESULT_MISS) ] = 0,
  367. },
  368. [ C(OP_PREFETCH) ] = {
  369. [ C(RESULT_ACCESS) ] = 0x0,
  370. [ C(RESULT_MISS) ] = 0,
  371. },
  372. },
  373. [ C(L1I ) ] = {
  374. [ C(OP_READ) ] = {
  375. [ C(RESULT_ACCESS) ] = 0x0380, /* L1I.READS */
  376. [ C(RESULT_MISS) ] = 0x0280, /* L1I.MISSES */
  377. },
  378. [ C(OP_WRITE) ] = {
  379. [ C(RESULT_ACCESS) ] = -1,
  380. [ C(RESULT_MISS) ] = -1,
  381. },
  382. [ C(OP_PREFETCH) ] = {
  383. [ C(RESULT_ACCESS) ] = 0,
  384. [ C(RESULT_MISS) ] = 0,
  385. },
  386. },
  387. [ C(LL ) ] = {
  388. [ C(OP_READ) ] = {
  389. [ C(RESULT_ACCESS) ] = 0x4f29, /* L2_LD.MESI */
  390. [ C(RESULT_MISS) ] = 0x4129, /* L2_LD.ISTATE */
  391. },
  392. [ C(OP_WRITE) ] = {
  393. [ C(RESULT_ACCESS) ] = 0x4f2A, /* L2_ST.MESI */
  394. [ C(RESULT_MISS) ] = 0x412A, /* L2_ST.ISTATE */
  395. },
  396. [ C(OP_PREFETCH) ] = {
  397. [ C(RESULT_ACCESS) ] = 0,
  398. [ C(RESULT_MISS) ] = 0,
  399. },
  400. },
  401. [ C(DTLB) ] = {
  402. [ C(OP_READ) ] = {
  403. [ C(RESULT_ACCESS) ] = 0x2140, /* L1D_CACHE_LD.MESI (alias) */
  404. [ C(RESULT_MISS) ] = 0x0508, /* DTLB_MISSES.MISS_LD */
  405. },
  406. [ C(OP_WRITE) ] = {
  407. [ C(RESULT_ACCESS) ] = 0x2240, /* L1D_CACHE_ST.MESI (alias) */
  408. [ C(RESULT_MISS) ] = 0x0608, /* DTLB_MISSES.MISS_ST */
  409. },
  410. [ C(OP_PREFETCH) ] = {
  411. [ C(RESULT_ACCESS) ] = 0,
  412. [ C(RESULT_MISS) ] = 0,
  413. },
  414. },
  415. [ C(ITLB) ] = {
  416. [ C(OP_READ) ] = {
  417. [ C(RESULT_ACCESS) ] = 0x00c0, /* INST_RETIRED.ANY_P */
  418. [ C(RESULT_MISS) ] = 0x0282, /* ITLB.MISSES */
  419. },
  420. [ C(OP_WRITE) ] = {
  421. [ C(RESULT_ACCESS) ] = -1,
  422. [ C(RESULT_MISS) ] = -1,
  423. },
  424. [ C(OP_PREFETCH) ] = {
  425. [ C(RESULT_ACCESS) ] = -1,
  426. [ C(RESULT_MISS) ] = -1,
  427. },
  428. },
  429. [ C(BPU ) ] = {
  430. [ C(OP_READ) ] = {
  431. [ C(RESULT_ACCESS) ] = 0x00c4, /* BR_INST_RETIRED.ANY */
  432. [ C(RESULT_MISS) ] = 0x00c5, /* BP_INST_RETIRED.MISPRED */
  433. },
  434. [ C(OP_WRITE) ] = {
  435. [ C(RESULT_ACCESS) ] = -1,
  436. [ C(RESULT_MISS) ] = -1,
  437. },
  438. [ C(OP_PREFETCH) ] = {
  439. [ C(RESULT_ACCESS) ] = -1,
  440. [ C(RESULT_MISS) ] = -1,
  441. },
  442. },
  443. };
  444. static void intel_pmu_disable_all(void)
  445. {
  446. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  447. wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);
  448. if (test_bit(X86_PMC_IDX_FIXED_BTS, cpuc->active_mask))
  449. intel_pmu_disable_bts();
  450. intel_pmu_pebs_disable_all();
  451. intel_pmu_lbr_disable_all();
  452. }
  453. static void intel_pmu_enable_all(int added)
  454. {
  455. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  456. intel_pmu_pebs_enable_all();
  457. intel_pmu_lbr_enable_all();
  458. wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
  459. if (test_bit(X86_PMC_IDX_FIXED_BTS, cpuc->active_mask)) {
  460. struct perf_event *event =
  461. cpuc->events[X86_PMC_IDX_FIXED_BTS];
  462. if (WARN_ON_ONCE(!event))
  463. return;
  464. intel_pmu_enable_bts(event->hw.config);
  465. }
  466. }
  467. /*
  468. * Workaround for:
  469. * Intel Errata AAK100 (model 26)
  470. * Intel Errata AAP53 (model 30)
  471. * Intel Errata BD53 (model 44)
  472. *
  473. * The official story:
  474. * These chips need to be 'reset' when adding counters by programming the
  475. * magic three (non-counting) events 0x4300B5, 0x4300D2, and 0x4300B1 either
  476. * in sequence on the same PMC or on different PMCs.
  477. *
  478. * In practise it appears some of these events do in fact count, and
  479. * we need to programm all 4 events.
  480. */
  481. static void intel_pmu_nhm_workaround(void)
  482. {
  483. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  484. static const unsigned long nhm_magic[4] = {
  485. 0x4300B5,
  486. 0x4300D2,
  487. 0x4300B1,
  488. 0x4300B1
  489. };
  490. struct perf_event *event;
  491. int i;
  492. /*
  493. * The Errata requires below steps:
  494. * 1) Clear MSR_IA32_PEBS_ENABLE and MSR_CORE_PERF_GLOBAL_CTRL;
  495. * 2) Configure 4 PERFEVTSELx with the magic events and clear
  496. * the corresponding PMCx;
  497. * 3) set bit0~bit3 of MSR_CORE_PERF_GLOBAL_CTRL;
  498. * 4) Clear MSR_CORE_PERF_GLOBAL_CTRL;
  499. * 5) Clear 4 pairs of ERFEVTSELx and PMCx;
  500. */
  501. /*
  502. * The real steps we choose are a little different from above.
  503. * A) To reduce MSR operations, we don't run step 1) as they
  504. * are already cleared before this function is called;
  505. * B) Call x86_perf_event_update to save PMCx before configuring
  506. * PERFEVTSELx with magic number;
  507. * C) With step 5), we do clear only when the PERFEVTSELx is
  508. * not used currently.
  509. * D) Call x86_perf_event_set_period to restore PMCx;
  510. */
  511. /* We always operate 4 pairs of PERF Counters */
  512. for (i = 0; i < 4; i++) {
  513. event = cpuc->events[i];
  514. if (event)
  515. x86_perf_event_update(event);
  516. }
  517. for (i = 0; i < 4; i++) {
  518. wrmsrl(MSR_ARCH_PERFMON_EVENTSEL0 + i, nhm_magic[i]);
  519. wrmsrl(MSR_ARCH_PERFMON_PERFCTR0 + i, 0x0);
  520. }
  521. wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0xf);
  522. wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0x0);
  523. for (i = 0; i < 4; i++) {
  524. event = cpuc->events[i];
  525. if (event) {
  526. x86_perf_event_set_period(event);
  527. __x86_pmu_enable_event(&event->hw,
  528. ARCH_PERFMON_EVENTSEL_ENABLE);
  529. } else
  530. wrmsrl(MSR_ARCH_PERFMON_EVENTSEL0 + i, 0x0);
  531. }
  532. }
  533. static void intel_pmu_nhm_enable_all(int added)
  534. {
  535. if (added)
  536. intel_pmu_nhm_workaround();
  537. intel_pmu_enable_all(added);
  538. }
  539. static inline u64 intel_pmu_get_status(void)
  540. {
  541. u64 status;
  542. rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status);
  543. return status;
  544. }
  545. static inline void intel_pmu_ack_status(u64 ack)
  546. {
  547. wrmsrl(MSR_CORE_PERF_GLOBAL_OVF_CTRL, ack);
  548. }
  549. static void intel_pmu_disable_fixed(struct hw_perf_event *hwc)
  550. {
  551. int idx = hwc->idx - X86_PMC_IDX_FIXED;
  552. u64 ctrl_val, mask;
  553. mask = 0xfULL << (idx * 4);
  554. rdmsrl(hwc->config_base, ctrl_val);
  555. ctrl_val &= ~mask;
  556. wrmsrl(hwc->config_base, ctrl_val);
  557. }
  558. static void intel_pmu_disable_event(struct perf_event *event)
  559. {
  560. struct hw_perf_event *hwc = &event->hw;
  561. if (unlikely(hwc->idx == X86_PMC_IDX_FIXED_BTS)) {
  562. intel_pmu_disable_bts();
  563. intel_pmu_drain_bts_buffer();
  564. return;
  565. }
  566. if (unlikely(hwc->config_base == MSR_ARCH_PERFMON_FIXED_CTR_CTRL)) {
  567. intel_pmu_disable_fixed(hwc);
  568. return;
  569. }
  570. x86_pmu_disable_event(event);
  571. if (unlikely(event->attr.precise_ip))
  572. intel_pmu_pebs_disable(event);
  573. }
  574. static void intel_pmu_enable_fixed(struct hw_perf_event *hwc)
  575. {
  576. int idx = hwc->idx - X86_PMC_IDX_FIXED;
  577. u64 ctrl_val, bits, mask;
  578. /*
  579. * Enable IRQ generation (0x8),
  580. * and enable ring-3 counting (0x2) and ring-0 counting (0x1)
  581. * if requested:
  582. */
  583. bits = 0x8ULL;
  584. if (hwc->config & ARCH_PERFMON_EVENTSEL_USR)
  585. bits |= 0x2;
  586. if (hwc->config & ARCH_PERFMON_EVENTSEL_OS)
  587. bits |= 0x1;
  588. /*
  589. * ANY bit is supported in v3 and up
  590. */
  591. if (x86_pmu.version > 2 && hwc->config & ARCH_PERFMON_EVENTSEL_ANY)
  592. bits |= 0x4;
  593. bits <<= (idx * 4);
  594. mask = 0xfULL << (idx * 4);
  595. rdmsrl(hwc->config_base, ctrl_val);
  596. ctrl_val &= ~mask;
  597. ctrl_val |= bits;
  598. wrmsrl(hwc->config_base, ctrl_val);
  599. }
  600. static void intel_pmu_enable_event(struct perf_event *event)
  601. {
  602. struct hw_perf_event *hwc = &event->hw;
  603. if (unlikely(hwc->idx == X86_PMC_IDX_FIXED_BTS)) {
  604. if (!__this_cpu_read(cpu_hw_events.enabled))
  605. return;
  606. intel_pmu_enable_bts(hwc->config);
  607. return;
  608. }
  609. if (unlikely(hwc->config_base == MSR_ARCH_PERFMON_FIXED_CTR_CTRL)) {
  610. intel_pmu_enable_fixed(hwc);
  611. return;
  612. }
  613. if (unlikely(event->attr.precise_ip))
  614. intel_pmu_pebs_enable(event);
  615. __x86_pmu_enable_event(hwc, ARCH_PERFMON_EVENTSEL_ENABLE);
  616. }
  617. /*
  618. * Save and restart an expired event. Called by NMI contexts,
  619. * so it has to be careful about preempting normal event ops:
  620. */
  621. static int intel_pmu_save_and_restart(struct perf_event *event)
  622. {
  623. x86_perf_event_update(event);
  624. return x86_perf_event_set_period(event);
  625. }
  626. static void intel_pmu_reset(void)
  627. {
  628. struct debug_store *ds = __this_cpu_read(cpu_hw_events.ds);
  629. unsigned long flags;
  630. int idx;
  631. if (!x86_pmu.num_counters)
  632. return;
  633. local_irq_save(flags);
  634. printk("clearing PMU state on CPU#%d\n", smp_processor_id());
  635. for (idx = 0; idx < x86_pmu.num_counters; idx++) {
  636. checking_wrmsrl(x86_pmu.eventsel + idx, 0ull);
  637. checking_wrmsrl(x86_pmu.perfctr + idx, 0ull);
  638. }
  639. for (idx = 0; idx < x86_pmu.num_counters_fixed; idx++)
  640. checking_wrmsrl(MSR_ARCH_PERFMON_FIXED_CTR0 + idx, 0ull);
  641. if (ds)
  642. ds->bts_index = ds->bts_buffer_base;
  643. local_irq_restore(flags);
  644. }
  645. /*
  646. * This handler is triggered by the local APIC, so the APIC IRQ handling
  647. * rules apply:
  648. */
  649. static int intel_pmu_handle_irq(struct pt_regs *regs)
  650. {
  651. struct perf_sample_data data;
  652. struct cpu_hw_events *cpuc;
  653. int bit, loops;
  654. u64 status;
  655. int handled;
  656. perf_sample_data_init(&data, 0);
  657. cpuc = &__get_cpu_var(cpu_hw_events);
  658. intel_pmu_disable_all();
  659. handled = intel_pmu_drain_bts_buffer();
  660. status = intel_pmu_get_status();
  661. if (!status) {
  662. intel_pmu_enable_all(0);
  663. return handled;
  664. }
  665. loops = 0;
  666. again:
  667. intel_pmu_ack_status(status);
  668. if (++loops > 100) {
  669. WARN_ONCE(1, "perfevents: irq loop stuck!\n");
  670. perf_event_print_debug();
  671. intel_pmu_reset();
  672. goto done;
  673. }
  674. inc_irq_stat(apic_perf_irqs);
  675. intel_pmu_lbr_read();
  676. /*
  677. * PEBS overflow sets bit 62 in the global status register
  678. */
  679. if (__test_and_clear_bit(62, (unsigned long *)&status)) {
  680. handled++;
  681. x86_pmu.drain_pebs(regs);
  682. }
  683. for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) {
  684. struct perf_event *event = cpuc->events[bit];
  685. handled++;
  686. if (!test_bit(bit, cpuc->active_mask))
  687. continue;
  688. if (!intel_pmu_save_and_restart(event))
  689. continue;
  690. data.period = event->hw.last_period;
  691. if (perf_event_overflow(event, 1, &data, regs))
  692. x86_pmu_stop(event, 0);
  693. }
  694. /*
  695. * Repeat if there is more work to be done:
  696. */
  697. status = intel_pmu_get_status();
  698. if (status)
  699. goto again;
  700. done:
  701. intel_pmu_enable_all(0);
  702. return handled;
  703. }
  704. static struct event_constraint *
  705. intel_bts_constraints(struct perf_event *event)
  706. {
  707. struct hw_perf_event *hwc = &event->hw;
  708. unsigned int hw_event, bts_event;
  709. hw_event = hwc->config & INTEL_ARCH_EVENT_MASK;
  710. bts_event = x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS);
  711. if (unlikely(hw_event == bts_event && hwc->sample_period == 1))
  712. return &bts_constraint;
  713. return NULL;
  714. }
  715. static struct event_constraint *
  716. intel_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
  717. {
  718. struct event_constraint *c;
  719. c = intel_bts_constraints(event);
  720. if (c)
  721. return c;
  722. c = intel_pebs_constraints(event);
  723. if (c)
  724. return c;
  725. return x86_get_event_constraints(cpuc, event);
  726. }
  727. static int intel_pmu_hw_config(struct perf_event *event)
  728. {
  729. int ret = x86_pmu_hw_config(event);
  730. if (ret)
  731. return ret;
  732. if (event->attr.precise_ip &&
  733. (event->hw.config & X86_RAW_EVENT_MASK) == 0x003c) {
  734. /*
  735. * Use an alternative encoding for CPU_CLK_UNHALTED.THREAD_P
  736. * (0x003c) so that we can use it with PEBS.
  737. *
  738. * The regular CPU_CLK_UNHALTED.THREAD_P event (0x003c) isn't
  739. * PEBS capable. However we can use INST_RETIRED.ANY_P
  740. * (0x00c0), which is a PEBS capable event, to get the same
  741. * count.
  742. *
  743. * INST_RETIRED.ANY_P counts the number of cycles that retires
  744. * CNTMASK instructions. By setting CNTMASK to a value (16)
  745. * larger than the maximum number of instructions that can be
  746. * retired per cycle (4) and then inverting the condition, we
  747. * count all cycles that retire 16 or less instructions, which
  748. * is every cycle.
  749. *
  750. * Thereby we gain a PEBS capable cycle counter.
  751. */
  752. u64 alt_config = 0x108000c0; /* INST_RETIRED.TOTAL_CYCLES */
  753. alt_config |= (event->hw.config & ~X86_RAW_EVENT_MASK);
  754. event->hw.config = alt_config;
  755. }
  756. if (event->attr.type != PERF_TYPE_RAW)
  757. return 0;
  758. if (!(event->attr.config & ARCH_PERFMON_EVENTSEL_ANY))
  759. return 0;
  760. if (x86_pmu.version < 3)
  761. return -EINVAL;
  762. if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
  763. return -EACCES;
  764. event->hw.config |= ARCH_PERFMON_EVENTSEL_ANY;
  765. return 0;
  766. }
  767. static __initconst const struct x86_pmu core_pmu = {
  768. .name = "core",
  769. .handle_irq = x86_pmu_handle_irq,
  770. .disable_all = x86_pmu_disable_all,
  771. .enable_all = x86_pmu_enable_all,
  772. .enable = x86_pmu_enable_event,
  773. .disable = x86_pmu_disable_event,
  774. .hw_config = x86_pmu_hw_config,
  775. .schedule_events = x86_schedule_events,
  776. .eventsel = MSR_ARCH_PERFMON_EVENTSEL0,
  777. .perfctr = MSR_ARCH_PERFMON_PERFCTR0,
  778. .event_map = intel_pmu_event_map,
  779. .max_events = ARRAY_SIZE(intel_perfmon_event_map),
  780. .apic = 1,
  781. /*
  782. * Intel PMCs cannot be accessed sanely above 32 bit width,
  783. * so we install an artificial 1<<31 period regardless of
  784. * the generic event period:
  785. */
  786. .max_period = (1ULL << 31) - 1,
  787. .get_event_constraints = intel_get_event_constraints,
  788. .event_constraints = intel_core_event_constraints,
  789. };
  790. static void intel_pmu_cpu_starting(int cpu)
  791. {
  792. init_debug_store_on_cpu(cpu);
  793. /*
  794. * Deal with CPUs that don't clear their LBRs on power-up.
  795. */
  796. intel_pmu_lbr_reset();
  797. }
  798. static void intel_pmu_cpu_dying(int cpu)
  799. {
  800. fini_debug_store_on_cpu(cpu);
  801. }
  802. static __initconst const struct x86_pmu intel_pmu = {
  803. .name = "Intel",
  804. .handle_irq = intel_pmu_handle_irq,
  805. .disable_all = intel_pmu_disable_all,
  806. .enable_all = intel_pmu_enable_all,
  807. .enable = intel_pmu_enable_event,
  808. .disable = intel_pmu_disable_event,
  809. .hw_config = intel_pmu_hw_config,
  810. .schedule_events = x86_schedule_events,
  811. .eventsel = MSR_ARCH_PERFMON_EVENTSEL0,
  812. .perfctr = MSR_ARCH_PERFMON_PERFCTR0,
  813. .event_map = intel_pmu_event_map,
  814. .max_events = ARRAY_SIZE(intel_perfmon_event_map),
  815. .apic = 1,
  816. /*
  817. * Intel PMCs cannot be accessed sanely above 32 bit width,
  818. * so we install an artificial 1<<31 period regardless of
  819. * the generic event period:
  820. */
  821. .max_period = (1ULL << 31) - 1,
  822. .get_event_constraints = intel_get_event_constraints,
  823. .cpu_starting = intel_pmu_cpu_starting,
  824. .cpu_dying = intel_pmu_cpu_dying,
  825. };
  826. static void intel_clovertown_quirks(void)
  827. {
  828. /*
  829. * PEBS is unreliable due to:
  830. *
  831. * AJ67 - PEBS may experience CPL leaks
  832. * AJ68 - PEBS PMI may be delayed by one event
  833. * AJ69 - GLOBAL_STATUS[62] will only be set when DEBUGCTL[12]
  834. * AJ106 - FREEZE_LBRS_ON_PMI doesn't work in combination with PEBS
  835. *
  836. * AJ67 could be worked around by restricting the OS/USR flags.
  837. * AJ69 could be worked around by setting PMU_FREEZE_ON_PMI.
  838. *
  839. * AJ106 could possibly be worked around by not allowing LBR
  840. * usage from PEBS, including the fixup.
  841. * AJ68 could possibly be worked around by always programming
  842. * a pebs_event_reset[0] value and coping with the lost events.
  843. *
  844. * But taken together it might just make sense to not enable PEBS on
  845. * these chips.
  846. */
  847. printk(KERN_WARNING "PEBS disabled due to CPU errata.\n");
  848. x86_pmu.pebs = 0;
  849. x86_pmu.pebs_constraints = NULL;
  850. }
  851. static __init int intel_pmu_init(void)
  852. {
  853. union cpuid10_edx edx;
  854. union cpuid10_eax eax;
  855. unsigned int unused;
  856. unsigned int ebx;
  857. int version;
  858. if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
  859. switch (boot_cpu_data.x86) {
  860. case 0x6:
  861. return p6_pmu_init();
  862. case 0xf:
  863. return p4_pmu_init();
  864. }
  865. return -ENODEV;
  866. }
  867. /*
  868. * Check whether the Architectural PerfMon supports
  869. * Branch Misses Retired hw_event or not.
  870. */
  871. cpuid(10, &eax.full, &ebx, &unused, &edx.full);
  872. if (eax.split.mask_length <= ARCH_PERFMON_BRANCH_MISSES_RETIRED)
  873. return -ENODEV;
  874. version = eax.split.version_id;
  875. if (version < 2)
  876. x86_pmu = core_pmu;
  877. else
  878. x86_pmu = intel_pmu;
  879. x86_pmu.version = version;
  880. x86_pmu.num_counters = eax.split.num_counters;
  881. x86_pmu.cntval_bits = eax.split.bit_width;
  882. x86_pmu.cntval_mask = (1ULL << eax.split.bit_width) - 1;
  883. /*
  884. * Quirk: v2 perfmon does not report fixed-purpose events, so
  885. * assume at least 3 events:
  886. */
  887. if (version > 1)
  888. x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
  889. /*
  890. * v2 and above have a perf capabilities MSR
  891. */
  892. if (version > 1) {
  893. u64 capabilities;
  894. rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
  895. x86_pmu.intel_cap.capabilities = capabilities;
  896. }
  897. intel_ds_init();
  898. /*
  899. * Install the hw-cache-events table:
  900. */
  901. switch (boot_cpu_data.x86_model) {
  902. case 14: /* 65 nm core solo/duo, "Yonah" */
  903. pr_cont("Core events, ");
  904. break;
  905. case 15: /* original 65 nm celeron/pentium/core2/xeon, "Merom"/"Conroe" */
  906. x86_pmu.quirks = intel_clovertown_quirks;
  907. case 22: /* single-core 65 nm celeron/core2solo "Merom-L"/"Conroe-L" */
  908. case 23: /* current 45 nm celeron/core2/xeon "Penryn"/"Wolfdale" */
  909. case 29: /* six-core 45 nm xeon "Dunnington" */
  910. memcpy(hw_cache_event_ids, core2_hw_cache_event_ids,
  911. sizeof(hw_cache_event_ids));
  912. intel_pmu_lbr_init_core();
  913. x86_pmu.event_constraints = intel_core2_event_constraints;
  914. pr_cont("Core2 events, ");
  915. break;
  916. case 26: /* 45 nm nehalem, "Bloomfield" */
  917. case 30: /* 45 nm nehalem, "Lynnfield" */
  918. case 46: /* 45 nm nehalem-ex, "Beckton" */
  919. memcpy(hw_cache_event_ids, nehalem_hw_cache_event_ids,
  920. sizeof(hw_cache_event_ids));
  921. intel_pmu_lbr_init_nhm();
  922. x86_pmu.event_constraints = intel_nehalem_event_constraints;
  923. x86_pmu.enable_all = intel_pmu_nhm_enable_all;
  924. pr_cont("Nehalem events, ");
  925. break;
  926. case 28: /* Atom */
  927. memcpy(hw_cache_event_ids, atom_hw_cache_event_ids,
  928. sizeof(hw_cache_event_ids));
  929. intel_pmu_lbr_init_atom();
  930. x86_pmu.event_constraints = intel_gen_event_constraints;
  931. pr_cont("Atom events, ");
  932. break;
  933. case 37: /* 32 nm nehalem, "Clarkdale" */
  934. case 44: /* 32 nm nehalem, "Gulftown" */
  935. memcpy(hw_cache_event_ids, westmere_hw_cache_event_ids,
  936. sizeof(hw_cache_event_ids));
  937. intel_pmu_lbr_init_nhm();
  938. x86_pmu.event_constraints = intel_westmere_event_constraints;
  939. x86_pmu.enable_all = intel_pmu_nhm_enable_all;
  940. pr_cont("Westmere events, ");
  941. break;
  942. default:
  943. /*
  944. * default constraints for v2 and up
  945. */
  946. x86_pmu.event_constraints = intel_gen_event_constraints;
  947. pr_cont("generic architected perfmon, ");
  948. }
  949. return 0;
  950. }
  951. #else /* CONFIG_CPU_SUP_INTEL */
  952. static int intel_pmu_init(void)
  953. {
  954. return 0;
  955. }
  956. #endif /* CONFIG_CPU_SUP_INTEL */