nmi_int.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  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. kmalloc(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].addr = 0;
  149. multiplex[i].saved = 0;
  150. }
  151. }
  152. per_cpu(switch_index, cpu) = 0;
  153. }
  154. static void nmi_cpu_save_mpx_registers(struct op_msrs *msrs)
  155. {
  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 (multiplex[virt].addr)
  161. rdmsrl(multiplex[virt].addr, multiplex[virt].saved);
  162. }
  163. }
  164. static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs)
  165. {
  166. struct op_msr *multiplex = msrs->multiplex;
  167. int i;
  168. for (i = 0; i < model->num_counters; ++i) {
  169. int virt = op_x86_phys_to_virt(i);
  170. if (multiplex[virt].addr)
  171. wrmsrl(multiplex[virt].addr, multiplex[virt].saved);
  172. }
  173. }
  174. static void nmi_cpu_switch(void *dummy)
  175. {
  176. int cpu = smp_processor_id();
  177. int si = per_cpu(switch_index, cpu);
  178. struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
  179. nmi_cpu_stop(NULL);
  180. nmi_cpu_save_mpx_registers(msrs);
  181. /* move to next set */
  182. si += model->num_counters;
  183. if ((si > model->num_virt_counters) || (counter_config[si].count == 0))
  184. per_cpu(switch_index, cpu) = 0;
  185. else
  186. per_cpu(switch_index, cpu) = si;
  187. model->switch_ctrl(model, msrs);
  188. nmi_cpu_restore_mpx_registers(msrs);
  189. nmi_cpu_start(NULL);
  190. }
  191. /*
  192. * Quick check to see if multiplexing is necessary.
  193. * The check should be sufficient since counters are used
  194. * in ordre.
  195. */
  196. static int nmi_multiplex_on(void)
  197. {
  198. return counter_config[model->num_counters].count ? 0 : -EINVAL;
  199. }
  200. static int nmi_switch_event(void)
  201. {
  202. if (!has_mux())
  203. return -ENOSYS; /* not implemented */
  204. if (nmi_multiplex_on() < 0)
  205. return -EINVAL; /* not necessary */
  206. on_each_cpu(nmi_cpu_switch, NULL, 1);
  207. return 0;
  208. }
  209. static inline void mux_init(struct oprofile_operations *ops)
  210. {
  211. if (has_mux())
  212. ops->switch_events = nmi_switch_event;
  213. }
  214. static void mux_clone(int cpu)
  215. {
  216. if (!has_mux())
  217. return;
  218. memcpy(per_cpu(cpu_msrs, cpu).multiplex,
  219. per_cpu(cpu_msrs, 0).multiplex,
  220. sizeof(struct op_msr) * model->num_virt_counters);
  221. }
  222. #else
  223. inline int op_x86_phys_to_virt(int phys) { return phys; }
  224. inline int op_x86_virt_to_phys(int virt) { return virt; }
  225. static inline void nmi_shutdown_mux(void) { }
  226. static inline int nmi_setup_mux(void) { return 1; }
  227. static inline void
  228. nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs) { }
  229. static inline void mux_init(struct oprofile_operations *ops) { }
  230. static void mux_clone(int cpu) { }
  231. #endif
  232. static void free_msrs(void)
  233. {
  234. int i;
  235. for_each_possible_cpu(i) {
  236. kfree(per_cpu(cpu_msrs, i).counters);
  237. per_cpu(cpu_msrs, i).counters = NULL;
  238. kfree(per_cpu(cpu_msrs, i).controls);
  239. per_cpu(cpu_msrs, i).controls = NULL;
  240. }
  241. }
  242. static int allocate_msrs(void)
  243. {
  244. size_t controls_size = sizeof(struct op_msr) * model->num_controls;
  245. size_t counters_size = sizeof(struct op_msr) * model->num_counters;
  246. int i;
  247. for_each_possible_cpu(i) {
  248. per_cpu(cpu_msrs, i).counters = kmalloc(counters_size,
  249. GFP_KERNEL);
  250. if (!per_cpu(cpu_msrs, i).counters)
  251. return 0;
  252. per_cpu(cpu_msrs, i).controls = kmalloc(controls_size,
  253. GFP_KERNEL);
  254. if (!per_cpu(cpu_msrs, i).controls)
  255. return 0;
  256. }
  257. return 1;
  258. }
  259. static void nmi_cpu_setup(void *dummy)
  260. {
  261. int cpu = smp_processor_id();
  262. struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
  263. nmi_cpu_save_registers(msrs);
  264. spin_lock(&oprofilefs_lock);
  265. model->setup_ctrs(model, msrs);
  266. nmi_cpu_setup_mux(cpu, msrs);
  267. spin_unlock(&oprofilefs_lock);
  268. per_cpu(saved_lvtpc, cpu) = apic_read(APIC_LVTPC);
  269. apic_write(APIC_LVTPC, APIC_DM_NMI);
  270. }
  271. static struct notifier_block profile_exceptions_nb = {
  272. .notifier_call = profile_exceptions_notify,
  273. .next = NULL,
  274. .priority = 2
  275. };
  276. static int nmi_setup(void)
  277. {
  278. int err = 0;
  279. int cpu;
  280. if (!allocate_msrs())
  281. err = -ENOMEM;
  282. else if (!nmi_setup_mux())
  283. err = -ENOMEM;
  284. else
  285. err = register_die_notifier(&profile_exceptions_nb);
  286. if (err) {
  287. free_msrs();
  288. nmi_shutdown_mux();
  289. return err;
  290. }
  291. /* We need to serialize save and setup for HT because the subset
  292. * of msrs are distinct for save and setup operations
  293. */
  294. /* Assume saved/restored counters are the same on all CPUs */
  295. model->fill_in_addresses(&per_cpu(cpu_msrs, 0));
  296. for_each_possible_cpu(cpu) {
  297. if (!cpu)
  298. continue;
  299. memcpy(per_cpu(cpu_msrs, cpu).counters,
  300. per_cpu(cpu_msrs, 0).counters,
  301. sizeof(struct op_msr) * model->num_counters);
  302. memcpy(per_cpu(cpu_msrs, cpu).controls,
  303. per_cpu(cpu_msrs, 0).controls,
  304. sizeof(struct op_msr) * model->num_controls);
  305. mux_clone(cpu);
  306. }
  307. on_each_cpu(nmi_cpu_setup, NULL, 1);
  308. nmi_enabled = 1;
  309. return 0;
  310. }
  311. static void nmi_cpu_restore_registers(struct op_msrs *msrs)
  312. {
  313. struct op_msr *counters = msrs->counters;
  314. struct op_msr *controls = msrs->controls;
  315. unsigned int i;
  316. for (i = 0; i < model->num_controls; ++i) {
  317. if (controls[i].addr)
  318. wrmsrl(controls[i].addr, controls[i].saved);
  319. }
  320. for (i = 0; i < model->num_counters; ++i) {
  321. if (counters[i].addr)
  322. wrmsrl(counters[i].addr, counters[i].saved);
  323. }
  324. }
  325. static void nmi_cpu_shutdown(void *dummy)
  326. {
  327. unsigned int v;
  328. int cpu = smp_processor_id();
  329. struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
  330. /* restoring APIC_LVTPC can trigger an apic error because the delivery
  331. * mode and vector nr combination can be illegal. That's by design: on
  332. * power on apic lvt contain a zero vector nr which are legal only for
  333. * NMI delivery mode. So inhibit apic err before restoring lvtpc
  334. */
  335. v = apic_read(APIC_LVTERR);
  336. apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
  337. apic_write(APIC_LVTPC, per_cpu(saved_lvtpc, cpu));
  338. apic_write(APIC_LVTERR, v);
  339. nmi_cpu_restore_registers(msrs);
  340. }
  341. static void nmi_shutdown(void)
  342. {
  343. struct op_msrs *msrs;
  344. nmi_enabled = 0;
  345. on_each_cpu(nmi_cpu_shutdown, NULL, 1);
  346. unregister_die_notifier(&profile_exceptions_nb);
  347. nmi_shutdown_mux();
  348. msrs = &get_cpu_var(cpu_msrs);
  349. model->shutdown(msrs);
  350. free_msrs();
  351. put_cpu_var(cpu_msrs);
  352. }
  353. static int nmi_create_files(struct super_block *sb, struct dentry *root)
  354. {
  355. unsigned int i;
  356. for (i = 0; i < model->num_virt_counters; ++i) {
  357. struct dentry *dir;
  358. char buf[4];
  359. /* quick little hack to _not_ expose a counter if it is not
  360. * available for use. This should protect userspace app.
  361. * NOTE: assumes 1:1 mapping here (that counters are organized
  362. * sequentially in their struct assignment).
  363. */
  364. if (!avail_to_resrv_perfctr_nmi_bit(op_x86_virt_to_phys(i)))
  365. continue;
  366. snprintf(buf, sizeof(buf), "%d", i);
  367. dir = oprofilefs_mkdir(sb, root, buf);
  368. oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled);
  369. oprofilefs_create_ulong(sb, dir, "event", &counter_config[i].event);
  370. oprofilefs_create_ulong(sb, dir, "count", &counter_config[i].count);
  371. oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask);
  372. oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel);
  373. oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user);
  374. }
  375. return 0;
  376. }
  377. #ifdef CONFIG_SMP
  378. static int oprofile_cpu_notifier(struct notifier_block *b, unsigned long action,
  379. void *data)
  380. {
  381. int cpu = (unsigned long)data;
  382. switch (action) {
  383. case CPU_DOWN_FAILED:
  384. case CPU_ONLINE:
  385. smp_call_function_single(cpu, nmi_cpu_start, NULL, 0);
  386. break;
  387. case CPU_DOWN_PREPARE:
  388. smp_call_function_single(cpu, nmi_cpu_stop, NULL, 1);
  389. break;
  390. }
  391. return NOTIFY_DONE;
  392. }
  393. static struct notifier_block oprofile_cpu_nb = {
  394. .notifier_call = oprofile_cpu_notifier
  395. };
  396. #endif
  397. #ifdef CONFIG_PM
  398. static int nmi_suspend(struct sys_device *dev, pm_message_t state)
  399. {
  400. /* Only one CPU left, just stop that one */
  401. if (nmi_enabled == 1)
  402. nmi_cpu_stop(NULL);
  403. return 0;
  404. }
  405. static int nmi_resume(struct sys_device *dev)
  406. {
  407. if (nmi_enabled == 1)
  408. nmi_cpu_start(NULL);
  409. return 0;
  410. }
  411. static struct sysdev_class oprofile_sysclass = {
  412. .name = "oprofile",
  413. .resume = nmi_resume,
  414. .suspend = nmi_suspend,
  415. };
  416. static struct sys_device device_oprofile = {
  417. .id = 0,
  418. .cls = &oprofile_sysclass,
  419. };
  420. static int __init init_sysfs(void)
  421. {
  422. int error;
  423. error = sysdev_class_register(&oprofile_sysclass);
  424. if (!error)
  425. error = sysdev_register(&device_oprofile);
  426. return error;
  427. }
  428. static void exit_sysfs(void)
  429. {
  430. sysdev_unregister(&device_oprofile);
  431. sysdev_class_unregister(&oprofile_sysclass);
  432. }
  433. #else
  434. #define init_sysfs() do { } while (0)
  435. #define exit_sysfs() do { } while (0)
  436. #endif /* CONFIG_PM */
  437. static int __init p4_init(char **cpu_type)
  438. {
  439. __u8 cpu_model = boot_cpu_data.x86_model;
  440. if (cpu_model > 6 || cpu_model == 5)
  441. return 0;
  442. #ifndef CONFIG_SMP
  443. *cpu_type = "i386/p4";
  444. model = &op_p4_spec;
  445. return 1;
  446. #else
  447. switch (smp_num_siblings) {
  448. case 1:
  449. *cpu_type = "i386/p4";
  450. model = &op_p4_spec;
  451. return 1;
  452. case 2:
  453. *cpu_type = "i386/p4-ht";
  454. model = &op_p4_ht2_spec;
  455. return 1;
  456. }
  457. #endif
  458. printk(KERN_INFO "oprofile: P4 HyperThreading detected with > 2 threads\n");
  459. printk(KERN_INFO "oprofile: Reverting to timer mode.\n");
  460. return 0;
  461. }
  462. static int force_arch_perfmon;
  463. static int force_cpu_type(const char *str, struct kernel_param *kp)
  464. {
  465. if (!strcmp(str, "arch_perfmon")) {
  466. force_arch_perfmon = 1;
  467. printk(KERN_INFO "oprofile: forcing architectural perfmon\n");
  468. }
  469. return 0;
  470. }
  471. module_param_call(cpu_type, force_cpu_type, NULL, NULL, 0);
  472. static int __init ppro_init(char **cpu_type)
  473. {
  474. __u8 cpu_model = boot_cpu_data.x86_model;
  475. struct op_x86_model_spec *spec = &op_ppro_spec; /* default */
  476. if (force_arch_perfmon && cpu_has_arch_perfmon)
  477. return 0;
  478. switch (cpu_model) {
  479. case 0 ... 2:
  480. *cpu_type = "i386/ppro";
  481. break;
  482. case 3 ... 5:
  483. *cpu_type = "i386/pii";
  484. break;
  485. case 6 ... 8:
  486. case 10 ... 11:
  487. *cpu_type = "i386/piii";
  488. break;
  489. case 9:
  490. case 13:
  491. *cpu_type = "i386/p6_mobile";
  492. break;
  493. case 14:
  494. *cpu_type = "i386/core";
  495. break;
  496. case 15: case 23:
  497. *cpu_type = "i386/core_2";
  498. break;
  499. case 26:
  500. spec = &op_arch_perfmon_spec;
  501. *cpu_type = "i386/core_i7";
  502. break;
  503. case 28:
  504. *cpu_type = "i386/atom";
  505. break;
  506. default:
  507. /* Unknown */
  508. return 0;
  509. }
  510. model = spec;
  511. return 1;
  512. }
  513. /* in order to get sysfs right */
  514. static int using_nmi;
  515. int __init op_nmi_init(struct oprofile_operations *ops)
  516. {
  517. __u8 vendor = boot_cpu_data.x86_vendor;
  518. __u8 family = boot_cpu_data.x86;
  519. char *cpu_type = NULL;
  520. int ret = 0;
  521. if (!cpu_has_apic)
  522. return -ENODEV;
  523. switch (vendor) {
  524. case X86_VENDOR_AMD:
  525. /* Needs to be at least an Athlon (or hammer in 32bit mode) */
  526. switch (family) {
  527. case 6:
  528. cpu_type = "i386/athlon";
  529. break;
  530. case 0xf:
  531. /*
  532. * Actually it could be i386/hammer too, but
  533. * give user space an consistent name.
  534. */
  535. cpu_type = "x86-64/hammer";
  536. break;
  537. case 0x10:
  538. cpu_type = "x86-64/family10";
  539. break;
  540. case 0x11:
  541. cpu_type = "x86-64/family11h";
  542. break;
  543. default:
  544. return -ENODEV;
  545. }
  546. model = &op_amd_spec;
  547. break;
  548. case X86_VENDOR_INTEL:
  549. switch (family) {
  550. /* Pentium IV */
  551. case 0xf:
  552. p4_init(&cpu_type);
  553. break;
  554. /* A P6-class processor */
  555. case 6:
  556. ppro_init(&cpu_type);
  557. break;
  558. default:
  559. break;
  560. }
  561. if (cpu_type)
  562. break;
  563. if (!cpu_has_arch_perfmon)
  564. return -ENODEV;
  565. /* use arch perfmon as fallback */
  566. cpu_type = "i386/arch_perfmon";
  567. model = &op_arch_perfmon_spec;
  568. break;
  569. default:
  570. return -ENODEV;
  571. }
  572. #ifdef CONFIG_SMP
  573. register_cpu_notifier(&oprofile_cpu_nb);
  574. #endif
  575. /* default values, can be overwritten by model */
  576. ops->create_files = nmi_create_files;
  577. ops->setup = nmi_setup;
  578. ops->shutdown = nmi_shutdown;
  579. ops->start = nmi_start;
  580. ops->stop = nmi_stop;
  581. ops->cpu_type = cpu_type;
  582. if (model->init)
  583. ret = model->init(ops);
  584. if (ret)
  585. return ret;
  586. if (!model->num_virt_counters)
  587. model->num_virt_counters = model->num_counters;
  588. mux_init(ops);
  589. init_sysfs();
  590. using_nmi = 1;
  591. printk(KERN_INFO "oprofile: using NMI interrupt.\n");
  592. return 0;
  593. }
  594. void op_nmi_exit(void)
  595. {
  596. if (using_nmi) {
  597. exit_sysfs();
  598. #ifdef CONFIG_SMP
  599. unregister_cpu_notifier(&oprofile_cpu_nb);
  600. #endif
  601. }
  602. if (model->exit)
  603. model->exit();
  604. }