nmi_int.c 16 KB

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