perf_event_intel_ds.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. #ifdef CONFIG_CPU_SUP_INTEL
  2. /* The maximal number of PEBS events: */
  3. #define MAX_PEBS_EVENTS 4
  4. /* The size of a BTS record in bytes: */
  5. #define BTS_RECORD_SIZE 24
  6. #define BTS_BUFFER_SIZE (PAGE_SIZE << 4)
  7. #define PEBS_BUFFER_SIZE PAGE_SIZE
  8. /*
  9. * pebs_record_32 for p4 and core not supported
  10. struct pebs_record_32 {
  11. u32 flags, ip;
  12. u32 ax, bc, cx, dx;
  13. u32 si, di, bp, sp;
  14. };
  15. */
  16. struct pebs_record_core {
  17. u64 flags, ip;
  18. u64 ax, bx, cx, dx;
  19. u64 si, di, bp, sp;
  20. u64 r8, r9, r10, r11;
  21. u64 r12, r13, r14, r15;
  22. };
  23. struct pebs_record_nhm {
  24. u64 flags, ip;
  25. u64 ax, bx, cx, dx;
  26. u64 si, di, bp, sp;
  27. u64 r8, r9, r10, r11;
  28. u64 r12, r13, r14, r15;
  29. u64 status, dla, dse, lat;
  30. };
  31. /*
  32. * A debug store configuration.
  33. *
  34. * We only support architectures that use 64bit fields.
  35. */
  36. struct debug_store {
  37. u64 bts_buffer_base;
  38. u64 bts_index;
  39. u64 bts_absolute_maximum;
  40. u64 bts_interrupt_threshold;
  41. u64 pebs_buffer_base;
  42. u64 pebs_index;
  43. u64 pebs_absolute_maximum;
  44. u64 pebs_interrupt_threshold;
  45. u64 pebs_event_reset[MAX_PEBS_EVENTS];
  46. };
  47. static void init_debug_store_on_cpu(int cpu)
  48. {
  49. struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
  50. if (!ds)
  51. return;
  52. wrmsr_on_cpu(cpu, MSR_IA32_DS_AREA,
  53. (u32)((u64)(unsigned long)ds),
  54. (u32)((u64)(unsigned long)ds >> 32));
  55. }
  56. static void fini_debug_store_on_cpu(int cpu)
  57. {
  58. if (!per_cpu(cpu_hw_events, cpu).ds)
  59. return;
  60. wrmsr_on_cpu(cpu, MSR_IA32_DS_AREA, 0, 0);
  61. }
  62. static int alloc_pebs_buffer(int cpu)
  63. {
  64. struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
  65. int max, thresh = 1; /* always use a single PEBS record */
  66. void *buffer;
  67. if (!x86_pmu.pebs)
  68. return 0;
  69. buffer = kzalloc(PEBS_BUFFER_SIZE, GFP_KERNEL);
  70. if (unlikely(!buffer))
  71. return -ENOMEM;
  72. max = PEBS_BUFFER_SIZE / x86_pmu.pebs_record_size;
  73. ds->pebs_buffer_base = (u64)(unsigned long)buffer;
  74. ds->pebs_index = ds->pebs_buffer_base;
  75. ds->pebs_absolute_maximum = ds->pebs_buffer_base +
  76. max * x86_pmu.pebs_record_size;
  77. ds->pebs_interrupt_threshold = ds->pebs_buffer_base +
  78. thresh * x86_pmu.pebs_record_size;
  79. return 0;
  80. }
  81. static void release_pebs_buffer(int cpu)
  82. {
  83. struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
  84. if (!ds || !x86_pmu.pebs)
  85. return;
  86. kfree((void *)(unsigned long)ds->pebs_buffer_base);
  87. ds->pebs_buffer_base = 0;
  88. }
  89. static int alloc_bts_buffer(int cpu)
  90. {
  91. struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
  92. int max, thresh;
  93. void *buffer;
  94. if (!x86_pmu.bts)
  95. return 0;
  96. buffer = kzalloc(BTS_BUFFER_SIZE, GFP_KERNEL);
  97. if (unlikely(!buffer))
  98. return -ENOMEM;
  99. max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE;
  100. thresh = max / 16;
  101. ds->bts_buffer_base = (u64)(unsigned long)buffer;
  102. ds->bts_index = ds->bts_buffer_base;
  103. ds->bts_absolute_maximum = ds->bts_buffer_base +
  104. max * BTS_RECORD_SIZE;
  105. ds->bts_interrupt_threshold = ds->bts_absolute_maximum -
  106. thresh * BTS_RECORD_SIZE;
  107. return 0;
  108. }
  109. static void release_bts_buffer(int cpu)
  110. {
  111. struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
  112. if (!ds || !x86_pmu.bts)
  113. return;
  114. kfree((void *)(unsigned long)ds->bts_buffer_base);
  115. ds->bts_buffer_base = 0;
  116. }
  117. static void release_ds_buffers(void)
  118. {
  119. int cpu;
  120. if (!x86_pmu.bts && !x86_pmu.pebs)
  121. return;
  122. get_online_cpus();
  123. for_each_online_cpu(cpu)
  124. fini_debug_store_on_cpu(cpu);
  125. for_each_possible_cpu(cpu) {
  126. struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
  127. if (!ds)
  128. continue;
  129. release_pebs_buffer(cpu);
  130. release_bts_buffer(cpu);
  131. per_cpu(cpu_hw_events, cpu).ds = NULL;
  132. kfree(ds);
  133. }
  134. put_online_cpus();
  135. }
  136. static int reserve_ds_buffers(void)
  137. {
  138. int cpu, err = 0;
  139. if (!x86_pmu.bts && !x86_pmu.pebs)
  140. return 0;
  141. get_online_cpus();
  142. for_each_possible_cpu(cpu) {
  143. struct debug_store *ds;
  144. err = -ENOMEM;
  145. ds = kzalloc(sizeof(*ds), GFP_KERNEL);
  146. if (unlikely(!ds))
  147. break;
  148. per_cpu(cpu_hw_events, cpu).ds = ds;
  149. if (alloc_bts_buffer(cpu))
  150. break;
  151. if (alloc_pebs_buffer(cpu))
  152. break;
  153. err = 0;
  154. }
  155. if (err)
  156. release_ds_buffers();
  157. else {
  158. for_each_online_cpu(cpu)
  159. init_debug_store_on_cpu(cpu);
  160. }
  161. put_online_cpus();
  162. return err;
  163. }
  164. /*
  165. * BTS
  166. */
  167. static struct event_constraint bts_constraint =
  168. EVENT_CONSTRAINT(0, 1ULL << X86_PMC_IDX_FIXED_BTS, 0);
  169. static void intel_pmu_enable_bts(u64 config)
  170. {
  171. unsigned long debugctlmsr;
  172. debugctlmsr = get_debugctlmsr();
  173. debugctlmsr |= DEBUGCTLMSR_TR;
  174. debugctlmsr |= DEBUGCTLMSR_BTS;
  175. debugctlmsr |= DEBUGCTLMSR_BTINT;
  176. if (!(config & ARCH_PERFMON_EVENTSEL_OS))
  177. debugctlmsr |= DEBUGCTLMSR_BTS_OFF_OS;
  178. if (!(config & ARCH_PERFMON_EVENTSEL_USR))
  179. debugctlmsr |= DEBUGCTLMSR_BTS_OFF_USR;
  180. update_debugctlmsr(debugctlmsr);
  181. }
  182. static void intel_pmu_disable_bts(void)
  183. {
  184. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  185. unsigned long debugctlmsr;
  186. if (!cpuc->ds)
  187. return;
  188. debugctlmsr = get_debugctlmsr();
  189. debugctlmsr &=
  190. ~(DEBUGCTLMSR_TR | DEBUGCTLMSR_BTS | DEBUGCTLMSR_BTINT |
  191. DEBUGCTLMSR_BTS_OFF_OS | DEBUGCTLMSR_BTS_OFF_USR);
  192. update_debugctlmsr(debugctlmsr);
  193. }
  194. static int intel_pmu_drain_bts_buffer(void)
  195. {
  196. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  197. struct debug_store *ds = cpuc->ds;
  198. struct bts_record {
  199. u64 from;
  200. u64 to;
  201. u64 flags;
  202. };
  203. struct perf_event *event = cpuc->events[X86_PMC_IDX_FIXED_BTS];
  204. struct bts_record *at, *top;
  205. struct perf_output_handle handle;
  206. struct perf_event_header header;
  207. struct perf_sample_data data;
  208. struct pt_regs regs;
  209. if (!event)
  210. return 0;
  211. if (!ds)
  212. return 0;
  213. at = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
  214. top = (struct bts_record *)(unsigned long)ds->bts_index;
  215. if (top <= at)
  216. return 0;
  217. ds->bts_index = ds->bts_buffer_base;
  218. perf_sample_data_init(&data, 0);
  219. data.period = event->hw.last_period;
  220. regs.ip = 0;
  221. /*
  222. * Prepare a generic sample, i.e. fill in the invariant fields.
  223. * We will overwrite the from and to address before we output
  224. * the sample.
  225. */
  226. perf_prepare_sample(&header, &data, event, &regs);
  227. if (perf_output_begin(&handle, event, header.size * (top - at), 1, 1))
  228. return 1;
  229. for (; at < top; at++) {
  230. data.ip = at->from;
  231. data.addr = at->to;
  232. perf_output_sample(&handle, &header, &data, event);
  233. }
  234. perf_output_end(&handle);
  235. /* There's new data available. */
  236. event->hw.interrupts++;
  237. event->pending_kill = POLL_IN;
  238. return 1;
  239. }
  240. /*
  241. * PEBS
  242. */
  243. static struct event_constraint intel_core_pebs_events[] = {
  244. PEBS_EVENT_CONSTRAINT(0x00c0, 0x1), /* INSTR_RETIRED.ANY */
  245. PEBS_EVENT_CONSTRAINT(0xfec1, 0x1), /* X87_OPS_RETIRED.ANY */
  246. PEBS_EVENT_CONSTRAINT(0x00c5, 0x1), /* BR_INST_RETIRED.MISPRED */
  247. PEBS_EVENT_CONSTRAINT(0x1fc7, 0x1), /* SIMD_INST_RETURED.ANY */
  248. PEBS_EVENT_CONSTRAINT(0x01cb, 0x1), /* MEM_LOAD_RETIRED.L1D_MISS */
  249. PEBS_EVENT_CONSTRAINT(0x02cb, 0x1), /* MEM_LOAD_RETIRED.L1D_LINE_MISS */
  250. PEBS_EVENT_CONSTRAINT(0x04cb, 0x1), /* MEM_LOAD_RETIRED.L2_MISS */
  251. PEBS_EVENT_CONSTRAINT(0x08cb, 0x1), /* MEM_LOAD_RETIRED.L2_LINE_MISS */
  252. PEBS_EVENT_CONSTRAINT(0x10cb, 0x1), /* MEM_LOAD_RETIRED.DTLB_MISS */
  253. EVENT_CONSTRAINT_END
  254. };
  255. static struct event_constraint intel_nehalem_pebs_events[] = {
  256. PEBS_EVENT_CONSTRAINT(0x00c0, 0xf), /* INSTR_RETIRED.ANY */
  257. PEBS_EVENT_CONSTRAINT(0xfec1, 0xf), /* X87_OPS_RETIRED.ANY */
  258. PEBS_EVENT_CONSTRAINT(0x00c5, 0xf), /* BR_INST_RETIRED.MISPRED */
  259. PEBS_EVENT_CONSTRAINT(0x1fc7, 0xf), /* SIMD_INST_RETURED.ANY */
  260. PEBS_EVENT_CONSTRAINT(0x01cb, 0xf), /* MEM_LOAD_RETIRED.L1D_MISS */
  261. PEBS_EVENT_CONSTRAINT(0x02cb, 0xf), /* MEM_LOAD_RETIRED.L1D_LINE_MISS */
  262. PEBS_EVENT_CONSTRAINT(0x04cb, 0xf), /* MEM_LOAD_RETIRED.L2_MISS */
  263. PEBS_EVENT_CONSTRAINT(0x08cb, 0xf), /* MEM_LOAD_RETIRED.L2_LINE_MISS */
  264. PEBS_EVENT_CONSTRAINT(0x10cb, 0xf), /* MEM_LOAD_RETIRED.DTLB_MISS */
  265. EVENT_CONSTRAINT_END
  266. };
  267. static struct event_constraint *
  268. intel_pebs_constraints(struct perf_event *event)
  269. {
  270. struct event_constraint *c;
  271. if (!event->attr.precise_ip)
  272. return NULL;
  273. if (x86_pmu.pebs_constraints) {
  274. for_each_event_constraint(c, x86_pmu.pebs_constraints) {
  275. if ((event->hw.config & c->cmask) == c->code)
  276. return c;
  277. }
  278. }
  279. return &emptyconstraint;
  280. }
  281. static void intel_pmu_pebs_enable(struct perf_event *event)
  282. {
  283. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  284. struct hw_perf_event *hwc = &event->hw;
  285. hwc->config &= ~ARCH_PERFMON_EVENTSEL_INT;
  286. cpuc->pebs_enabled |= 1ULL << hwc->idx;
  287. WARN_ON_ONCE(cpuc->enabled);
  288. if (x86_pmu.intel_cap.pebs_trap && event->attr.precise_ip > 1)
  289. intel_pmu_lbr_enable(event);
  290. }
  291. static void intel_pmu_pebs_disable(struct perf_event *event)
  292. {
  293. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  294. struct hw_perf_event *hwc = &event->hw;
  295. cpuc->pebs_enabled &= ~(1ULL << hwc->idx);
  296. if (cpuc->enabled)
  297. wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
  298. hwc->config |= ARCH_PERFMON_EVENTSEL_INT;
  299. if (x86_pmu.intel_cap.pebs_trap && event->attr.precise_ip > 1)
  300. intel_pmu_lbr_disable(event);
  301. }
  302. static void intel_pmu_pebs_enable_all(void)
  303. {
  304. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  305. if (cpuc->pebs_enabled)
  306. wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
  307. }
  308. static void intel_pmu_pebs_disable_all(void)
  309. {
  310. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  311. if (cpuc->pebs_enabled)
  312. wrmsrl(MSR_IA32_PEBS_ENABLE, 0);
  313. }
  314. #include <asm/insn.h>
  315. static inline bool kernel_ip(unsigned long ip)
  316. {
  317. #ifdef CONFIG_X86_32
  318. return ip > PAGE_OFFSET;
  319. #else
  320. return (long)ip < 0;
  321. #endif
  322. }
  323. static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs)
  324. {
  325. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  326. unsigned long from = cpuc->lbr_entries[0].from;
  327. unsigned long old_to, to = cpuc->lbr_entries[0].to;
  328. unsigned long ip = regs->ip;
  329. /*
  330. * We don't need to fixup if the PEBS assist is fault like
  331. */
  332. if (!x86_pmu.intel_cap.pebs_trap)
  333. return 1;
  334. /*
  335. * No LBR entry, no basic block, no rewinding
  336. */
  337. if (!cpuc->lbr_stack.nr || !from || !to)
  338. return 0;
  339. /*
  340. * Basic blocks should never cross user/kernel boundaries
  341. */
  342. if (kernel_ip(ip) != kernel_ip(to))
  343. return 0;
  344. /*
  345. * unsigned math, either ip is before the start (impossible) or
  346. * the basic block is larger than 1 page (sanity)
  347. */
  348. if ((ip - to) > PAGE_SIZE)
  349. return 0;
  350. /*
  351. * We sampled a branch insn, rewind using the LBR stack
  352. */
  353. if (ip == to) {
  354. regs->ip = from;
  355. return 1;
  356. }
  357. do {
  358. struct insn insn;
  359. u8 buf[MAX_INSN_SIZE];
  360. void *kaddr;
  361. old_to = to;
  362. if (!kernel_ip(ip)) {
  363. int bytes, size = MAX_INSN_SIZE;
  364. bytes = copy_from_user_nmi(buf, (void __user *)to, size);
  365. if (bytes != size)
  366. return 0;
  367. kaddr = buf;
  368. } else
  369. kaddr = (void *)to;
  370. kernel_insn_init(&insn, kaddr);
  371. insn_get_length(&insn);
  372. to += insn.length;
  373. } while (to < ip);
  374. if (to == ip) {
  375. regs->ip = old_to;
  376. return 1;
  377. }
  378. /*
  379. * Even though we decoded the basic block, the instruction stream
  380. * never matched the given IP, either the TO or the IP got corrupted.
  381. */
  382. return 0;
  383. }
  384. static int intel_pmu_save_and_restart(struct perf_event *event);
  385. static void __intel_pmu_pebs_event(struct perf_event *event,
  386. struct pt_regs *iregs, void *__pebs)
  387. {
  388. /*
  389. * We cast to pebs_record_core since that is a subset of
  390. * both formats and we don't use the other fields in this
  391. * routine.
  392. */
  393. struct pebs_record_core *pebs = __pebs;
  394. struct perf_sample_data data;
  395. struct pt_regs regs;
  396. if (!intel_pmu_save_and_restart(event))
  397. return;
  398. perf_sample_data_init(&data, 0);
  399. data.period = event->hw.last_period;
  400. /*
  401. * We use the interrupt regs as a base because the PEBS record
  402. * does not contain a full regs set, specifically it seems to
  403. * lack segment descriptors, which get used by things like
  404. * user_mode().
  405. *
  406. * In the simple case fix up only the IP and BP,SP regs, for
  407. * PERF_SAMPLE_IP and PERF_SAMPLE_CALLCHAIN to function properly.
  408. * A possible PERF_SAMPLE_REGS will have to transfer all regs.
  409. */
  410. regs = *iregs;
  411. regs.ip = pebs->ip;
  412. regs.bp = pebs->bp;
  413. regs.sp = pebs->sp;
  414. if (event->attr.precise_ip > 1 && intel_pmu_pebs_fixup_ip(&regs))
  415. regs.flags |= PERF_EFLAGS_EXACT;
  416. else
  417. regs.flags &= ~PERF_EFLAGS_EXACT;
  418. if (perf_event_overflow(event, 1, &data, &regs))
  419. x86_pmu_stop(event, 0);
  420. }
  421. static void intel_pmu_drain_pebs_core(struct pt_regs *iregs)
  422. {
  423. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  424. struct debug_store *ds = cpuc->ds;
  425. struct perf_event *event = cpuc->events[0]; /* PMC0 only */
  426. struct pebs_record_core *at, *top;
  427. int n;
  428. if (!ds || !x86_pmu.pebs)
  429. return;
  430. at = (struct pebs_record_core *)(unsigned long)ds->pebs_buffer_base;
  431. top = (struct pebs_record_core *)(unsigned long)ds->pebs_index;
  432. /*
  433. * Whatever else happens, drain the thing
  434. */
  435. ds->pebs_index = ds->pebs_buffer_base;
  436. if (!test_bit(0, cpuc->active_mask))
  437. return;
  438. WARN_ON_ONCE(!event);
  439. if (!event->attr.precise_ip)
  440. return;
  441. n = top - at;
  442. if (n <= 0)
  443. return;
  444. /*
  445. * Should not happen, we program the threshold at 1 and do not
  446. * set a reset value.
  447. */
  448. WARN_ON_ONCE(n > 1);
  449. at += n - 1;
  450. __intel_pmu_pebs_event(event, iregs, at);
  451. }
  452. static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
  453. {
  454. struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
  455. struct debug_store *ds = cpuc->ds;
  456. struct pebs_record_nhm *at, *top;
  457. struct perf_event *event = NULL;
  458. u64 status = 0;
  459. int bit, n;
  460. if (!ds || !x86_pmu.pebs)
  461. return;
  462. at = (struct pebs_record_nhm *)(unsigned long)ds->pebs_buffer_base;
  463. top = (struct pebs_record_nhm *)(unsigned long)ds->pebs_index;
  464. ds->pebs_index = ds->pebs_buffer_base;
  465. n = top - at;
  466. if (n <= 0)
  467. return;
  468. /*
  469. * Should not happen, we program the threshold at 1 and do not
  470. * set a reset value.
  471. */
  472. WARN_ON_ONCE(n > MAX_PEBS_EVENTS);
  473. for ( ; at < top; at++) {
  474. for_each_set_bit(bit, (unsigned long *)&at->status, MAX_PEBS_EVENTS) {
  475. event = cpuc->events[bit];
  476. if (!test_bit(bit, cpuc->active_mask))
  477. continue;
  478. WARN_ON_ONCE(!event);
  479. if (!event->attr.precise_ip)
  480. continue;
  481. if (__test_and_set_bit(bit, (unsigned long *)&status))
  482. continue;
  483. break;
  484. }
  485. if (!event || bit >= MAX_PEBS_EVENTS)
  486. continue;
  487. __intel_pmu_pebs_event(event, iregs, at);
  488. }
  489. }
  490. /*
  491. * BTS, PEBS probe and setup
  492. */
  493. static void intel_ds_init(void)
  494. {
  495. /*
  496. * No support for 32bit formats
  497. */
  498. if (!boot_cpu_has(X86_FEATURE_DTES64))
  499. return;
  500. x86_pmu.bts = boot_cpu_has(X86_FEATURE_BTS);
  501. x86_pmu.pebs = boot_cpu_has(X86_FEATURE_PEBS);
  502. if (x86_pmu.pebs) {
  503. char pebs_type = x86_pmu.intel_cap.pebs_trap ? '+' : '-';
  504. int format = x86_pmu.intel_cap.pebs_format;
  505. switch (format) {
  506. case 0:
  507. printk(KERN_CONT "PEBS fmt0%c, ", pebs_type);
  508. x86_pmu.pebs_record_size = sizeof(struct pebs_record_core);
  509. x86_pmu.drain_pebs = intel_pmu_drain_pebs_core;
  510. x86_pmu.pebs_constraints = intel_core_pebs_events;
  511. break;
  512. case 1:
  513. printk(KERN_CONT "PEBS fmt1%c, ", pebs_type);
  514. x86_pmu.pebs_record_size = sizeof(struct pebs_record_nhm);
  515. x86_pmu.drain_pebs = intel_pmu_drain_pebs_nhm;
  516. x86_pmu.pebs_constraints = intel_nehalem_pebs_events;
  517. break;
  518. default:
  519. printk(KERN_CONT "no PEBS fmt%d%c, ", format, pebs_type);
  520. x86_pmu.pebs = 0;
  521. break;
  522. }
  523. }
  524. }
  525. #else /* CONFIG_CPU_SUP_INTEL */
  526. static int reserve_ds_buffers(void)
  527. {
  528. return 0;
  529. }
  530. static void release_ds_buffers(void)
  531. {
  532. }
  533. #endif /* CONFIG_CPU_SUP_INTEL */