nmi_int.c 15 KB

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