nmi_int.c 15 KB

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