nmi_int.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /**
  2. * @file nmi_int.c
  3. *
  4. * @remark Copyright 2002-2009 OProfile authors
  5. * @remark Read the file COPYING
  6. *
  7. * @author John Levon <levon@movementarian.org>
  8. * @author Robert Richter <robert.richter@amd.com>
  9. * @author Barry Kasindorf <barry.kasindorf@amd.com>
  10. * @author Jason Yeh <jason.yeh@amd.com>
  11. * @author Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
  12. */
  13. #include <linux/init.h>
  14. #include <linux/notifier.h>
  15. #include <linux/smp.h>
  16. #include <linux/oprofile.h>
  17. #include <linux/sysdev.h>
  18. #include <linux/slab.h>
  19. #include <linux/moduleparam.h>
  20. #include <linux/kdebug.h>
  21. #include <linux/cpu.h>
  22. #include <asm/nmi.h>
  23. #include <asm/msr.h>
  24. #include <asm/apic.h>
  25. #include "op_counter.h"
  26. #include "op_x86_model.h"
  27. static struct op_x86_model_spec *model;
  28. static DEFINE_PER_CPU(struct op_msrs, cpu_msrs);
  29. static DEFINE_PER_CPU(unsigned long, saved_lvtpc);
  30. /* 0 == registered but off, 1 == registered and on */
  31. static int nmi_enabled = 0;
  32. struct op_counter_config counter_config[OP_MAX_COUNTER];
  33. /* common functions */
  34. u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
  35. struct op_counter_config *counter_config)
  36. {
  37. u64 val = 0;
  38. u16 event = (u16)counter_config->event;
  39. val |= ARCH_PERFMON_EVENTSEL_INT;
  40. val |= counter_config->user ? ARCH_PERFMON_EVENTSEL_USR : 0;
  41. val |= counter_config->kernel ? ARCH_PERFMON_EVENTSEL_OS : 0;
  42. val |= (counter_config->unit_mask & 0xFF) << 8;
  43. event &= model->event_mask ? model->event_mask : 0xFF;
  44. val |= event & 0xFF;
  45. val |= (event & 0x0F00) << 24;
  46. return val;
  47. }
  48. static int profile_exceptions_notify(struct notifier_block *self,
  49. unsigned long val, void *data)
  50. {
  51. struct die_args *args = (struct die_args *)data;
  52. int ret = NOTIFY_DONE;
  53. int cpu = smp_processor_id();
  54. switch (val) {
  55. case DIE_NMI:
  56. case DIE_NMI_IPI:
  57. model->check_ctrs(args->regs, &per_cpu(cpu_msrs, cpu));
  58. ret = NOTIFY_STOP;
  59. break;
  60. default:
  61. break;
  62. }
  63. return ret;
  64. }
  65. static void nmi_cpu_save_registers(struct op_msrs *msrs)
  66. {
  67. struct op_msr *counters = msrs->counters;
  68. struct op_msr *controls = msrs->controls;
  69. unsigned int i;
  70. for (i = 0; i < model->num_counters; ++i) {
  71. if (counters[i].addr)
  72. rdmsrl(counters[i].addr, counters[i].saved);
  73. }
  74. for (i = 0; i < model->num_controls; ++i) {
  75. if (controls[i].addr)
  76. rdmsrl(controls[i].addr, controls[i].saved);
  77. }
  78. }
  79. static void nmi_cpu_start(void *dummy)
  80. {
  81. struct op_msrs const *msrs = &__get_cpu_var(cpu_msrs);
  82. model->start(msrs);
  83. }
  84. static int nmi_start(void)
  85. {
  86. on_each_cpu(nmi_cpu_start, NULL, 1);
  87. return 0;
  88. }
  89. static void nmi_cpu_stop(void *dummy)
  90. {
  91. struct op_msrs const *msrs = &__get_cpu_var(cpu_msrs);
  92. model->stop(msrs);
  93. }
  94. static void nmi_stop(void)
  95. {
  96. on_each_cpu(nmi_cpu_stop, NULL, 1);
  97. }
  98. #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
  99. static DEFINE_PER_CPU(int, switch_index);
  100. static inline int has_mux(void)
  101. {
  102. return !!model->switch_ctrl;
  103. }
  104. inline int op_x86_phys_to_virt(int phys)
  105. {
  106. return __get_cpu_var(switch_index) + phys;
  107. }
  108. inline int op_x86_virt_to_phys(int virt)
  109. {
  110. return virt % model->num_counters;
  111. }
  112. static void nmi_shutdown_mux(void)
  113. {
  114. int i;
  115. if (!has_mux())
  116. return;
  117. for_each_possible_cpu(i) {
  118. kfree(per_cpu(cpu_msrs, i).multiplex);
  119. per_cpu(cpu_msrs, i).multiplex = NULL;
  120. per_cpu(switch_index, i) = 0;
  121. }
  122. }
  123. static int nmi_setup_mux(void)
  124. {
  125. size_t multiplex_size =
  126. sizeof(struct op_msr) * model->num_virt_counters;
  127. int i;
  128. if (!has_mux())
  129. return 1;
  130. for_each_possible_cpu(i) {
  131. per_cpu(cpu_msrs, i).multiplex =
  132. kzalloc(multiplex_size, GFP_KERNEL);
  133. if (!per_cpu(cpu_msrs, i).multiplex)
  134. return 0;
  135. }
  136. return 1;
  137. }
  138. static void nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs)
  139. {
  140. int i;
  141. struct op_msr *multiplex = msrs->multiplex;
  142. if (!has_mux())
  143. return;
  144. for (i = 0; i < model->num_virt_counters; ++i) {
  145. if (counter_config[i].enabled) {
  146. multiplex[i].saved = -(u64)counter_config[i].count;
  147. } else {
  148. multiplex[i].saved = 0;
  149. }
  150. }
  151. per_cpu(switch_index, cpu) = 0;
  152. }
  153. static void nmi_cpu_save_mpx_registers(struct op_msrs *msrs)
  154. {
  155. struct op_msr *counters = msrs->counters;
  156. struct op_msr *multiplex = msrs->multiplex;
  157. int i;
  158. for (i = 0; i < model->num_counters; ++i) {
  159. int virt = op_x86_phys_to_virt(i);
  160. if (counters[i].addr)
  161. rdmsrl(counters[i].addr, multiplex[virt].saved);
  162. }
  163. }
  164. static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs)
  165. {
  166. struct op_msr *counters = msrs->counters;
  167. struct op_msr *multiplex = msrs->multiplex;
  168. int i;
  169. for (i = 0; i < model->num_counters; ++i) {
  170. int virt = op_x86_phys_to_virt(i);
  171. if (counters[i].addr)
  172. wrmsrl(counters[i].addr, multiplex[virt].saved);
  173. }
  174. }
  175. static void nmi_cpu_switch(void *dummy)
  176. {
  177. int cpu = smp_processor_id();
  178. int si = per_cpu(switch_index, cpu);
  179. struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
  180. nmi_cpu_stop(NULL);
  181. nmi_cpu_save_mpx_registers(msrs);
  182. /* move to next set */
  183. si += model->num_counters;
  184. if ((si >= model->num_virt_counters) || (counter_config[si].count == 0))
  185. per_cpu(switch_index, cpu) = 0;
  186. else
  187. per_cpu(switch_index, cpu) = si;
  188. model->switch_ctrl(model, msrs);
  189. nmi_cpu_restore_mpx_registers(msrs);
  190. nmi_cpu_start(NULL);
  191. }
  192. /*
  193. * Quick check to see if multiplexing is necessary.
  194. * The check should be sufficient since counters are used
  195. * in ordre.
  196. */
  197. static int nmi_multiplex_on(void)
  198. {
  199. return counter_config[model->num_counters].count ? 0 : -EINVAL;
  200. }
  201. static int nmi_switch_event(void)
  202. {
  203. if (!has_mux())
  204. return -ENOSYS; /* not implemented */
  205. if (nmi_multiplex_on() < 0)
  206. return -EINVAL; /* not necessary */
  207. on_each_cpu(nmi_cpu_switch, NULL, 1);
  208. return 0;
  209. }
  210. static inline void mux_init(struct oprofile_operations *ops)
  211. {
  212. if (has_mux())
  213. ops->switch_events = nmi_switch_event;
  214. }
  215. static void mux_clone(int cpu)
  216. {
  217. if (!has_mux())
  218. return;
  219. memcpy(per_cpu(cpu_msrs, cpu).multiplex,
  220. per_cpu(cpu_msrs, 0).multiplex,
  221. sizeof(struct op_msr) * model->num_virt_counters);
  222. }
  223. #else
  224. inline int op_x86_phys_to_virt(int phys) { return phys; }
  225. inline int op_x86_virt_to_phys(int virt) { return virt; }
  226. static inline void nmi_shutdown_mux(void) { }
  227. static inline int nmi_setup_mux(void) { return 1; }
  228. static inline void
  229. nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs) { }
  230. static inline void mux_init(struct oprofile_operations *ops) { }
  231. static void mux_clone(int cpu) { }
  232. #endif
  233. static void free_msrs(void)
  234. {
  235. int i;
  236. for_each_possible_cpu(i) {
  237. kfree(per_cpu(cpu_msrs, i).counters);
  238. per_cpu(cpu_msrs, i).counters = NULL;
  239. kfree(per_cpu(cpu_msrs, i).controls);
  240. per_cpu(cpu_msrs, i).controls = NULL;
  241. }
  242. }
  243. static int allocate_msrs(void)
  244. {
  245. size_t controls_size = sizeof(struct op_msr) * model->num_controls;
  246. size_t counters_size = sizeof(struct op_msr) * model->num_counters;
  247. int i;
  248. for_each_possible_cpu(i) {
  249. per_cpu(cpu_msrs, i).counters = kzalloc(counters_size,
  250. GFP_KERNEL);
  251. if (!per_cpu(cpu_msrs, i).counters)
  252. return 0;
  253. per_cpu(cpu_msrs, i).controls = kzalloc(controls_size,
  254. GFP_KERNEL);
  255. if (!per_cpu(cpu_msrs, i).controls)
  256. return 0;
  257. }
  258. return 1;
  259. }
  260. static void nmi_cpu_setup(void *dummy)
  261. {
  262. int cpu = smp_processor_id();
  263. struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
  264. nmi_cpu_save_registers(msrs);
  265. spin_lock(&oprofilefs_lock);
  266. model->setup_ctrs(model, msrs);
  267. nmi_cpu_setup_mux(cpu, msrs);
  268. spin_unlock(&oprofilefs_lock);
  269. per_cpu(saved_lvtpc, cpu) = apic_read(APIC_LVTPC);
  270. apic_write(APIC_LVTPC, APIC_DM_NMI);
  271. }
  272. static struct notifier_block profile_exceptions_nb = {
  273. .notifier_call = profile_exceptions_notify,
  274. .next = NULL,
  275. .priority = 2
  276. };
  277. static int nmi_setup(void)
  278. {
  279. int err = 0;
  280. int cpu;
  281. if (!allocate_msrs())
  282. err = -ENOMEM;
  283. else if (!nmi_setup_mux())
  284. err = -ENOMEM;
  285. else
  286. err = register_die_notifier(&profile_exceptions_nb);
  287. if (err) {
  288. free_msrs();
  289. nmi_shutdown_mux();
  290. return err;
  291. }
  292. /* We need to serialize save and setup for HT because the subset
  293. * of msrs are distinct for save and setup operations
  294. */
  295. /* Assume saved/restored counters are the same on all CPUs */
  296. model->fill_in_addresses(&per_cpu(cpu_msrs, 0));
  297. for_each_possible_cpu(cpu) {
  298. if (!cpu)
  299. continue;
  300. memcpy(per_cpu(cpu_msrs, cpu).counters,
  301. per_cpu(cpu_msrs, 0).counters,
  302. sizeof(struct op_msr) * model->num_counters);
  303. memcpy(per_cpu(cpu_msrs, cpu).controls,
  304. per_cpu(cpu_msrs, 0).controls,
  305. sizeof(struct op_msr) * model->num_controls);
  306. mux_clone(cpu);
  307. }
  308. on_each_cpu(nmi_cpu_setup, NULL, 1);
  309. nmi_enabled = 1;
  310. return 0;
  311. }
  312. static void nmi_cpu_restore_registers(struct op_msrs *msrs)
  313. {
  314. struct op_msr *counters = msrs->counters;
  315. struct op_msr *controls = msrs->controls;
  316. unsigned int i;
  317. for (i = 0; i < model->num_controls; ++i) {
  318. if (controls[i].addr)
  319. wrmsrl(controls[i].addr, controls[i].saved);
  320. }
  321. for (i = 0; i < model->num_counters; ++i) {
  322. if (counters[i].addr)
  323. wrmsrl(counters[i].addr, counters[i].saved);
  324. }
  325. }
  326. static void nmi_cpu_shutdown(void *dummy)
  327. {
  328. unsigned int v;
  329. int cpu = smp_processor_id();
  330. struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
  331. /* restoring APIC_LVTPC can trigger an apic error because the delivery
  332. * mode and vector nr combination can be illegal. That's by design: on
  333. * power on apic lvt contain a zero vector nr which are legal only for
  334. * NMI delivery mode. So inhibit apic err before restoring lvtpc
  335. */
  336. v = apic_read(APIC_LVTERR);
  337. apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
  338. apic_write(APIC_LVTPC, per_cpu(saved_lvtpc, cpu));
  339. apic_write(APIC_LVTERR, v);
  340. nmi_cpu_restore_registers(msrs);
  341. }
  342. static void nmi_shutdown(void)
  343. {
  344. struct op_msrs *msrs;
  345. nmi_enabled = 0;
  346. on_each_cpu(nmi_cpu_shutdown, NULL, 1);
  347. unregister_die_notifier(&profile_exceptions_nb);
  348. nmi_shutdown_mux();
  349. msrs = &get_cpu_var(cpu_msrs);
  350. model->shutdown(msrs);
  351. free_msrs();
  352. put_cpu_var(cpu_msrs);
  353. }
  354. static int nmi_create_files(struct super_block *sb, struct dentry *root)
  355. {
  356. unsigned int i;
  357. for (i = 0; i < model->num_virt_counters; ++i) {
  358. struct dentry *dir;
  359. char buf[4];
  360. /* quick little hack to _not_ expose a counter if it is not
  361. * available for use. This should protect userspace app.
  362. * NOTE: assumes 1:1 mapping here (that counters are organized
  363. * sequentially in their struct assignment).
  364. */
  365. if (!avail_to_resrv_perfctr_nmi_bit(op_x86_virt_to_phys(i)))
  366. continue;
  367. snprintf(buf, sizeof(buf), "%d", i);
  368. dir = oprofilefs_mkdir(sb, root, buf);
  369. oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled);
  370. oprofilefs_create_ulong(sb, dir, "event", &counter_config[i].event);
  371. oprofilefs_create_ulong(sb, dir, "count", &counter_config[i].count);
  372. oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask);
  373. oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel);
  374. oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user);
  375. }
  376. return 0;
  377. }
  378. #ifdef CONFIG_SMP
  379. static int oprofile_cpu_notifier(struct notifier_block *b, unsigned long action,
  380. void *data)
  381. {
  382. int cpu = (unsigned long)data;
  383. switch (action) {
  384. case CPU_DOWN_FAILED:
  385. case CPU_ONLINE:
  386. smp_call_function_single(cpu, nmi_cpu_start, NULL, 0);
  387. break;
  388. case CPU_DOWN_PREPARE:
  389. smp_call_function_single(cpu, nmi_cpu_stop, NULL, 1);
  390. break;
  391. }
  392. return NOTIFY_DONE;
  393. }
  394. static struct notifier_block oprofile_cpu_nb = {
  395. .notifier_call = oprofile_cpu_notifier
  396. };
  397. #endif
  398. #ifdef CONFIG_PM
  399. static int nmi_suspend(struct sys_device *dev, pm_message_t state)
  400. {
  401. /* Only one CPU left, just stop that one */
  402. if (nmi_enabled == 1)
  403. nmi_cpu_stop(NULL);
  404. return 0;
  405. }
  406. static int nmi_resume(struct sys_device *dev)
  407. {
  408. if (nmi_enabled == 1)
  409. nmi_cpu_start(NULL);
  410. return 0;
  411. }
  412. static struct sysdev_class oprofile_sysclass = {
  413. .name = "oprofile",
  414. .resume = nmi_resume,
  415. .suspend = nmi_suspend,
  416. };
  417. static struct sys_device device_oprofile = {
  418. .id = 0,
  419. .cls = &oprofile_sysclass,
  420. };
  421. static int __init init_sysfs(void)
  422. {
  423. int error;
  424. error = sysdev_class_register(&oprofile_sysclass);
  425. if (!error)
  426. error = sysdev_register(&device_oprofile);
  427. return error;
  428. }
  429. static void exit_sysfs(void)
  430. {
  431. sysdev_unregister(&device_oprofile);
  432. sysdev_class_unregister(&oprofile_sysclass);
  433. }
  434. #else
  435. #define init_sysfs() do { } while (0)
  436. #define exit_sysfs() do { } while (0)
  437. #endif /* CONFIG_PM */
  438. static int __init p4_init(char **cpu_type)
  439. {
  440. __u8 cpu_model = boot_cpu_data.x86_model;
  441. if (cpu_model > 6 || cpu_model == 5)
  442. return 0;
  443. #ifndef CONFIG_SMP
  444. *cpu_type = "i386/p4";
  445. model = &op_p4_spec;
  446. return 1;
  447. #else
  448. switch (smp_num_siblings) {
  449. case 1:
  450. *cpu_type = "i386/p4";
  451. model = &op_p4_spec;
  452. return 1;
  453. case 2:
  454. *cpu_type = "i386/p4-ht";
  455. model = &op_p4_ht2_spec;
  456. return 1;
  457. }
  458. #endif
  459. printk(KERN_INFO "oprofile: P4 HyperThreading detected with > 2 threads\n");
  460. printk(KERN_INFO "oprofile: Reverting to timer mode.\n");
  461. return 0;
  462. }
  463. static int force_arch_perfmon;
  464. static int force_cpu_type(const char *str, struct kernel_param *kp)
  465. {
  466. if (!strcmp(str, "arch_perfmon")) {
  467. force_arch_perfmon = 1;
  468. printk(KERN_INFO "oprofile: forcing architectural perfmon\n");
  469. }
  470. return 0;
  471. }
  472. module_param_call(cpu_type, force_cpu_type, NULL, NULL, 0);
  473. static int __init ppro_init(char **cpu_type)
  474. {
  475. __u8 cpu_model = boot_cpu_data.x86_model;
  476. struct op_x86_model_spec *spec = &op_ppro_spec; /* default */
  477. if (force_arch_perfmon && cpu_has_arch_perfmon)
  478. return 0;
  479. switch (cpu_model) {
  480. case 0 ... 2:
  481. *cpu_type = "i386/ppro";
  482. break;
  483. case 3 ... 5:
  484. *cpu_type = "i386/pii";
  485. break;
  486. case 6 ... 8:
  487. case 10 ... 11:
  488. *cpu_type = "i386/piii";
  489. break;
  490. case 9:
  491. case 13:
  492. *cpu_type = "i386/p6_mobile";
  493. break;
  494. case 14:
  495. *cpu_type = "i386/core";
  496. break;
  497. case 15: case 23:
  498. *cpu_type = "i386/core_2";
  499. break;
  500. case 0x2e:
  501. case 26:
  502. spec = &op_arch_perfmon_spec;
  503. *cpu_type = "i386/core_i7";
  504. break;
  505. case 28:
  506. *cpu_type = "i386/atom";
  507. break;
  508. default:
  509. /* Unknown */
  510. return 0;
  511. }
  512. model = spec;
  513. return 1;
  514. }
  515. /* in order to get sysfs right */
  516. static int using_nmi;
  517. int __init op_nmi_init(struct oprofile_operations *ops)
  518. {
  519. __u8 vendor = boot_cpu_data.x86_vendor;
  520. __u8 family = boot_cpu_data.x86;
  521. char *cpu_type = NULL;
  522. int ret = 0;
  523. if (!cpu_has_apic)
  524. return -ENODEV;
  525. switch (vendor) {
  526. case X86_VENDOR_AMD:
  527. /* Needs to be at least an Athlon (or hammer in 32bit mode) */
  528. switch (family) {
  529. case 6:
  530. cpu_type = "i386/athlon";
  531. break;
  532. case 0xf:
  533. /*
  534. * Actually it could be i386/hammer too, but
  535. * give user space an consistent name.
  536. */
  537. cpu_type = "x86-64/hammer";
  538. break;
  539. case 0x10:
  540. cpu_type = "x86-64/family10";
  541. break;
  542. case 0x11:
  543. cpu_type = "x86-64/family11h";
  544. break;
  545. default:
  546. return -ENODEV;
  547. }
  548. model = &op_amd_spec;
  549. break;
  550. case X86_VENDOR_INTEL:
  551. switch (family) {
  552. /* Pentium IV */
  553. case 0xf:
  554. p4_init(&cpu_type);
  555. break;
  556. /* A P6-class processor */
  557. case 6:
  558. ppro_init(&cpu_type);
  559. break;
  560. default:
  561. break;
  562. }
  563. if (cpu_type)
  564. break;
  565. if (!cpu_has_arch_perfmon)
  566. return -ENODEV;
  567. /* use arch perfmon as fallback */
  568. cpu_type = "i386/arch_perfmon";
  569. model = &op_arch_perfmon_spec;
  570. break;
  571. default:
  572. return -ENODEV;
  573. }
  574. #ifdef CONFIG_SMP
  575. register_cpu_notifier(&oprofile_cpu_nb);
  576. #endif
  577. /* default values, can be overwritten by model */
  578. ops->create_files = nmi_create_files;
  579. ops->setup = nmi_setup;
  580. ops->shutdown = nmi_shutdown;
  581. ops->start = nmi_start;
  582. ops->stop = nmi_stop;
  583. ops->cpu_type = cpu_type;
  584. if (model->init)
  585. ret = model->init(ops);
  586. if (ret)
  587. return ret;
  588. if (!model->num_virt_counters)
  589. model->num_virt_counters = model->num_counters;
  590. mux_init(ops);
  591. init_sysfs();
  592. using_nmi = 1;
  593. printk(KERN_INFO "oprofile: using NMI interrupt.\n");
  594. return 0;
  595. }
  596. void op_nmi_exit(void)
  597. {
  598. if (using_nmi) {
  599. exit_sysfs();
  600. #ifdef CONFIG_SMP
  601. unregister_cpu_notifier(&oprofile_cpu_nb);
  602. #endif
  603. }
  604. if (model->exit)
  605. model->exit();
  606. }