]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/x86/oprofile/nmi_int.c
x86, nmi: Wire up NMI handlers to new routines
[karo-tx-linux.git] / arch / x86 / oprofile / nmi_int.c
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
14 #include <linux/init.h>
15 #include <linux/notifier.h>
16 #include <linux/smp.h>
17 #include <linux/oprofile.h>
18 #include <linux/syscore_ops.h>
19 #include <linux/slab.h>
20 #include <linux/moduleparam.h>
21 #include <linux/kdebug.h>
22 #include <linux/cpu.h>
23 #include <asm/nmi.h>
24 #include <asm/msr.h>
25 #include <asm/apic.h>
26
27 #include "op_counter.h"
28 #include "op_x86_model.h"
29
30 static struct op_x86_model_spec *model;
31 static DEFINE_PER_CPU(struct op_msrs, cpu_msrs);
32 static DEFINE_PER_CPU(unsigned long, saved_lvtpc);
33
34 /* must be protected with get_online_cpus()/put_online_cpus(): */
35 static int nmi_enabled;
36 static int ctr_running;
37
38 struct op_counter_config counter_config[OP_MAX_COUNTER];
39
40 /* common functions */
41
42 u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
43                     struct op_counter_config *counter_config)
44 {
45         u64 val = 0;
46         u16 event = (u16)counter_config->event;
47
48         val |= ARCH_PERFMON_EVENTSEL_INT;
49         val |= counter_config->user ? ARCH_PERFMON_EVENTSEL_USR : 0;
50         val |= counter_config->kernel ? ARCH_PERFMON_EVENTSEL_OS : 0;
51         val |= (counter_config->unit_mask & 0xFF) << 8;
52         counter_config->extra &= (ARCH_PERFMON_EVENTSEL_INV |
53                                   ARCH_PERFMON_EVENTSEL_EDGE |
54                                   ARCH_PERFMON_EVENTSEL_CMASK);
55         val |= counter_config->extra;
56         event &= model->event_mask ? model->event_mask : 0xFF;
57         val |= event & 0xFF;
58         val |= (event & 0x0F00) << 24;
59
60         return val;
61 }
62
63
64 static int profile_exceptions_notify(unsigned int val, struct pt_regs *regs)
65 {
66         if (ctr_running)
67                 model->check_ctrs(regs, &__get_cpu_var(cpu_msrs));
68         else if (!nmi_enabled)
69                 return NMI_DONE;
70         else
71                 model->stop(&__get_cpu_var(cpu_msrs));
72         return NMI_HANDLED;
73 }
74
75 static void nmi_cpu_save_registers(struct op_msrs *msrs)
76 {
77         struct op_msr *counters = msrs->counters;
78         struct op_msr *controls = msrs->controls;
79         unsigned int i;
80
81         for (i = 0; i < model->num_counters; ++i) {
82                 if (counters[i].addr)
83                         rdmsrl(counters[i].addr, counters[i].saved);
84         }
85
86         for (i = 0; i < model->num_controls; ++i) {
87                 if (controls[i].addr)
88                         rdmsrl(controls[i].addr, controls[i].saved);
89         }
90 }
91
92 static void nmi_cpu_start(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->start(msrs);
99 }
100
101 static int nmi_start(void)
102 {
103         get_online_cpus();
104         ctr_running = 1;
105         /* make ctr_running visible to the nmi handler: */
106         smp_mb();
107         on_each_cpu(nmi_cpu_start, NULL, 1);
108         put_online_cpus();
109         return 0;
110 }
111
112 static void nmi_cpu_stop(void *dummy)
113 {
114         struct op_msrs const *msrs = &__get_cpu_var(cpu_msrs);
115         if (!msrs->controls)
116                 WARN_ON_ONCE(1);
117         else
118                 model->stop(msrs);
119 }
120
121 static void nmi_stop(void)
122 {
123         get_online_cpus();
124         on_each_cpu(nmi_cpu_stop, NULL, 1);
125         ctr_running = 0;
126         put_online_cpus();
127 }
128
129 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
130
131 static DEFINE_PER_CPU(int, switch_index);
132
133 static inline int has_mux(void)
134 {
135         return !!model->switch_ctrl;
136 }
137
138 inline int op_x86_phys_to_virt(int phys)
139 {
140         return __this_cpu_read(switch_index) + phys;
141 }
142
143 inline int op_x86_virt_to_phys(int virt)
144 {
145         return virt % model->num_counters;
146 }
147
148 static void nmi_shutdown_mux(void)
149 {
150         int i;
151
152         if (!has_mux())
153                 return;
154
155         for_each_possible_cpu(i) {
156                 kfree(per_cpu(cpu_msrs, i).multiplex);
157                 per_cpu(cpu_msrs, i).multiplex = NULL;
158                 per_cpu(switch_index, i) = 0;
159         }
160 }
161
162 static int nmi_setup_mux(void)
163 {
164         size_t multiplex_size =
165                 sizeof(struct op_msr) * model->num_virt_counters;
166         int i;
167
168         if (!has_mux())
169                 return 1;
170
171         for_each_possible_cpu(i) {
172                 per_cpu(cpu_msrs, i).multiplex =
173                         kzalloc(multiplex_size, GFP_KERNEL);
174                 if (!per_cpu(cpu_msrs, i).multiplex)
175                         return 0;
176         }
177
178         return 1;
179 }
180
181 static void nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs)
182 {
183         int i;
184         struct op_msr *multiplex = msrs->multiplex;
185
186         if (!has_mux())
187                 return;
188
189         for (i = 0; i < model->num_virt_counters; ++i) {
190                 if (counter_config[i].enabled) {
191                         multiplex[i].saved = -(u64)counter_config[i].count;
192                 } else {
193                         multiplex[i].saved = 0;
194                 }
195         }
196
197         per_cpu(switch_index, cpu) = 0;
198 }
199
200 static void nmi_cpu_save_mpx_registers(struct op_msrs *msrs)
201 {
202         struct op_msr *counters = msrs->counters;
203         struct op_msr *multiplex = msrs->multiplex;
204         int i;
205
206         for (i = 0; i < model->num_counters; ++i) {
207                 int virt = op_x86_phys_to_virt(i);
208                 if (counters[i].addr)
209                         rdmsrl(counters[i].addr, multiplex[virt].saved);
210         }
211 }
212
213 static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs)
214 {
215         struct op_msr *counters = msrs->counters;
216         struct op_msr *multiplex = msrs->multiplex;
217         int i;
218
219         for (i = 0; i < model->num_counters; ++i) {
220                 int virt = op_x86_phys_to_virt(i);
221                 if (counters[i].addr)
222                         wrmsrl(counters[i].addr, multiplex[virt].saved);
223         }
224 }
225
226 static void nmi_cpu_switch(void *dummy)
227 {
228         int cpu = smp_processor_id();
229         int si = per_cpu(switch_index, cpu);
230         struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
231
232         nmi_cpu_stop(NULL);
233         nmi_cpu_save_mpx_registers(msrs);
234
235         /* move to next set */
236         si += model->num_counters;
237         if ((si >= model->num_virt_counters) || (counter_config[si].count == 0))
238                 per_cpu(switch_index, cpu) = 0;
239         else
240                 per_cpu(switch_index, cpu) = si;
241
242         model->switch_ctrl(model, msrs);
243         nmi_cpu_restore_mpx_registers(msrs);
244
245         nmi_cpu_start(NULL);
246 }
247
248
249 /*
250  * Quick check to see if multiplexing is necessary.
251  * The check should be sufficient since counters are used
252  * in ordre.
253  */
254 static int nmi_multiplex_on(void)
255 {
256         return counter_config[model->num_counters].count ? 0 : -EINVAL;
257 }
258
259 static int nmi_switch_event(void)
260 {
261         if (!has_mux())
262                 return -ENOSYS;         /* not implemented */
263         if (nmi_multiplex_on() < 0)
264                 return -EINVAL;         /* not necessary */
265
266         get_online_cpus();
267         if (ctr_running)
268                 on_each_cpu(nmi_cpu_switch, NULL, 1);
269         put_online_cpus();
270
271         return 0;
272 }
273
274 static inline void mux_init(struct oprofile_operations *ops)
275 {
276         if (has_mux())
277                 ops->switch_events = nmi_switch_event;
278 }
279
280 static void mux_clone(int cpu)
281 {
282         if (!has_mux())
283                 return;
284
285         memcpy(per_cpu(cpu_msrs, cpu).multiplex,
286                per_cpu(cpu_msrs, 0).multiplex,
287                sizeof(struct op_msr) * model->num_virt_counters);
288 }
289
290 #else
291
292 inline int op_x86_phys_to_virt(int phys) { return phys; }
293 inline int op_x86_virt_to_phys(int virt) { return virt; }
294 static inline void nmi_shutdown_mux(void) { }
295 static inline int nmi_setup_mux(void) { return 1; }
296 static inline void
297 nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs) { }
298 static inline void mux_init(struct oprofile_operations *ops) { }
299 static void mux_clone(int cpu) { }
300
301 #endif
302
303 static void free_msrs(void)
304 {
305         int i;
306         for_each_possible_cpu(i) {
307                 kfree(per_cpu(cpu_msrs, i).counters);
308                 per_cpu(cpu_msrs, i).counters = NULL;
309                 kfree(per_cpu(cpu_msrs, i).controls);
310                 per_cpu(cpu_msrs, i).controls = NULL;
311         }
312         nmi_shutdown_mux();
313 }
314
315 static int allocate_msrs(void)
316 {
317         size_t controls_size = sizeof(struct op_msr) * model->num_controls;
318         size_t counters_size = sizeof(struct op_msr) * model->num_counters;
319
320         int i;
321         for_each_possible_cpu(i) {
322                 per_cpu(cpu_msrs, i).counters = kzalloc(counters_size,
323                                                         GFP_KERNEL);
324                 if (!per_cpu(cpu_msrs, i).counters)
325                         goto fail;
326                 per_cpu(cpu_msrs, i).controls = kzalloc(controls_size,
327                                                         GFP_KERNEL);
328                 if (!per_cpu(cpu_msrs, i).controls)
329                         goto fail;
330         }
331
332         if (!nmi_setup_mux())
333                 goto fail;
334
335         return 1;
336
337 fail:
338         free_msrs();
339         return 0;
340 }
341
342 static void nmi_cpu_setup(void *dummy)
343 {
344         int cpu = smp_processor_id();
345         struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
346         nmi_cpu_save_registers(msrs);
347         spin_lock(&oprofilefs_lock);
348         model->setup_ctrs(model, msrs);
349         nmi_cpu_setup_mux(cpu, msrs);
350         spin_unlock(&oprofilefs_lock);
351         per_cpu(saved_lvtpc, cpu) = apic_read(APIC_LVTPC);
352         apic_write(APIC_LVTPC, APIC_DM_NMI);
353 }
354
355 static void nmi_cpu_restore_registers(struct op_msrs *msrs)
356 {
357         struct op_msr *counters = msrs->counters;
358         struct op_msr *controls = msrs->controls;
359         unsigned int i;
360
361         for (i = 0; i < model->num_controls; ++i) {
362                 if (controls[i].addr)
363                         wrmsrl(controls[i].addr, controls[i].saved);
364         }
365
366         for (i = 0; i < model->num_counters; ++i) {
367                 if (counters[i].addr)
368                         wrmsrl(counters[i].addr, counters[i].saved);
369         }
370 }
371
372 static void nmi_cpu_shutdown(void *dummy)
373 {
374         unsigned int v;
375         int cpu = smp_processor_id();
376         struct op_msrs *msrs = &per_cpu(cpu_msrs, cpu);
377
378         /* restoring APIC_LVTPC can trigger an apic error because the delivery
379          * mode and vector nr combination can be illegal. That's by design: on
380          * power on apic lvt contain a zero vector nr which are legal only for
381          * NMI delivery mode. So inhibit apic err before restoring lvtpc
382          */
383         v = apic_read(APIC_LVTERR);
384         apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
385         apic_write(APIC_LVTPC, per_cpu(saved_lvtpc, cpu));
386         apic_write(APIC_LVTERR, v);
387         nmi_cpu_restore_registers(msrs);
388         if (model->cpu_down)
389                 model->cpu_down();
390 }
391
392 static void nmi_cpu_up(void *dummy)
393 {
394         if (nmi_enabled)
395                 nmi_cpu_setup(dummy);
396         if (ctr_running)
397                 nmi_cpu_start(dummy);
398 }
399
400 static void nmi_cpu_down(void *dummy)
401 {
402         if (ctr_running)
403                 nmi_cpu_stop(dummy);
404         if (nmi_enabled)
405                 nmi_cpu_shutdown(dummy);
406 }
407
408 static int nmi_create_files(struct super_block *sb, struct dentry *root)
409 {
410         unsigned int i;
411
412         for (i = 0; i < model->num_virt_counters; ++i) {
413                 struct dentry *dir;
414                 char buf[4];
415
416                 /* quick little hack to _not_ expose a counter if it is not
417                  * available for use.  This should protect userspace app.
418                  * NOTE:  assumes 1:1 mapping here (that counters are organized
419                  *        sequentially in their struct assignment).
420                  */
421                 if (!avail_to_resrv_perfctr_nmi_bit(op_x86_virt_to_phys(i)))
422                         continue;
423
424                 snprintf(buf,  sizeof(buf), "%d", i);
425                 dir = oprofilefs_mkdir(sb, root, buf);
426                 oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled);
427                 oprofilefs_create_ulong(sb, dir, "event", &counter_config[i].event);
428                 oprofilefs_create_ulong(sb, dir, "count", &counter_config[i].count);
429                 oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask);
430                 oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel);
431                 oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user);
432                 oprofilefs_create_ulong(sb, dir, "extra", &counter_config[i].extra);
433         }
434
435         return 0;
436 }
437
438 static int oprofile_cpu_notifier(struct notifier_block *b, unsigned long action,
439                                  void *data)
440 {
441         int cpu = (unsigned long)data;
442         switch (action) {
443         case CPU_DOWN_FAILED:
444         case CPU_ONLINE:
445                 smp_call_function_single(cpu, nmi_cpu_up, NULL, 0);
446                 break;
447         case CPU_DOWN_PREPARE:
448                 smp_call_function_single(cpu, nmi_cpu_down, NULL, 1);
449                 break;
450         }
451         return NOTIFY_DONE;
452 }
453
454 static struct notifier_block oprofile_cpu_nb = {
455         .notifier_call = oprofile_cpu_notifier
456 };
457
458 static int nmi_setup(void)
459 {
460         int err = 0;
461         int cpu;
462
463         if (!allocate_msrs())
464                 return -ENOMEM;
465
466         /* We need to serialize save and setup for HT because the subset
467          * of msrs are distinct for save and setup operations
468          */
469
470         /* Assume saved/restored counters are the same on all CPUs */
471         err = model->fill_in_addresses(&per_cpu(cpu_msrs, 0));
472         if (err)
473                 goto fail;
474
475         for_each_possible_cpu(cpu) {
476                 if (!cpu)
477                         continue;
478
479                 memcpy(per_cpu(cpu_msrs, cpu).counters,
480                        per_cpu(cpu_msrs, 0).counters,
481                        sizeof(struct op_msr) * model->num_counters);
482
483                 memcpy(per_cpu(cpu_msrs, cpu).controls,
484                        per_cpu(cpu_msrs, 0).controls,
485                        sizeof(struct op_msr) * model->num_controls);
486
487                 mux_clone(cpu);
488         }
489
490         nmi_enabled = 0;
491         ctr_running = 0;
492         /* make variables visible to the nmi handler: */
493         smp_mb();
494         err = register_nmi_handler(NMI_LOCAL, profile_exceptions_notify,
495                                         0, "oprofile");
496         if (err)
497                 goto fail;
498
499         get_online_cpus();
500         register_cpu_notifier(&oprofile_cpu_nb);
501         nmi_enabled = 1;
502         /* make nmi_enabled visible to the nmi handler: */
503         smp_mb();
504         on_each_cpu(nmi_cpu_setup, NULL, 1);
505         put_online_cpus();
506
507         return 0;
508 fail:
509         free_msrs();
510         return err;
511 }
512
513 static void nmi_shutdown(void)
514 {
515         struct op_msrs *msrs;
516
517         get_online_cpus();
518         unregister_cpu_notifier(&oprofile_cpu_nb);
519         on_each_cpu(nmi_cpu_shutdown, NULL, 1);
520         nmi_enabled = 0;
521         ctr_running = 0;
522         put_online_cpus();
523         /* make variables visible to the nmi handler: */
524         smp_mb();
525         unregister_nmi_handler(NMI_LOCAL, "oprofile");
526         msrs = &get_cpu_var(cpu_msrs);
527         model->shutdown(msrs);
528         free_msrs();
529         put_cpu_var(cpu_msrs);
530 }
531
532 #ifdef CONFIG_PM
533
534 static int nmi_suspend(void)
535 {
536         /* Only one CPU left, just stop that one */
537         if (nmi_enabled == 1)
538                 nmi_cpu_stop(NULL);
539         return 0;
540 }
541
542 static void nmi_resume(void)
543 {
544         if (nmi_enabled == 1)
545                 nmi_cpu_start(NULL);
546 }
547
548 static struct syscore_ops oprofile_syscore_ops = {
549         .resume         = nmi_resume,
550         .suspend        = nmi_suspend,
551 };
552
553 static void __init init_suspend_resume(void)
554 {
555         register_syscore_ops(&oprofile_syscore_ops);
556 }
557
558 static void exit_suspend_resume(void)
559 {
560         unregister_syscore_ops(&oprofile_syscore_ops);
561 }
562
563 #else
564
565 static inline void init_suspend_resume(void) { }
566 static inline void exit_suspend_resume(void) { }
567
568 #endif /* CONFIG_PM */
569
570 static int __init p4_init(char **cpu_type)
571 {
572         __u8 cpu_model = boot_cpu_data.x86_model;
573
574         if (cpu_model > 6 || cpu_model == 5)
575                 return 0;
576
577 #ifndef CONFIG_SMP
578         *cpu_type = "i386/p4";
579         model = &op_p4_spec;
580         return 1;
581 #else
582         switch (smp_num_siblings) {
583         case 1:
584                 *cpu_type = "i386/p4";
585                 model = &op_p4_spec;
586                 return 1;
587
588         case 2:
589                 *cpu_type = "i386/p4-ht";
590                 model = &op_p4_ht2_spec;
591                 return 1;
592         }
593 #endif
594
595         printk(KERN_INFO "oprofile: P4 HyperThreading detected with > 2 threads\n");
596         printk(KERN_INFO "oprofile: Reverting to timer mode.\n");
597         return 0;
598 }
599
600 static int force_arch_perfmon;
601 static int force_cpu_type(const char *str, struct kernel_param *kp)
602 {
603         if (!strcmp(str, "arch_perfmon")) {
604                 force_arch_perfmon = 1;
605                 printk(KERN_INFO "oprofile: forcing architectural perfmon\n");
606         }
607
608         return 0;
609 }
610 module_param_call(cpu_type, force_cpu_type, NULL, NULL, 0);
611
612 static int __init ppro_init(char **cpu_type)
613 {
614         __u8 cpu_model = boot_cpu_data.x86_model;
615         struct op_x86_model_spec *spec = &op_ppro_spec; /* default */
616
617         if (force_arch_perfmon && cpu_has_arch_perfmon)
618                 return 0;
619
620         /*
621          * Documentation on identifying Intel processors by CPU family
622          * and model can be found in the Intel Software Developer's
623          * Manuals (SDM):
624          *
625          *  http://www.intel.com/products/processor/manuals/
626          *
627          * As of May 2010 the documentation for this was in the:
628          * "Intel 64 and IA-32 Architectures Software Developer's
629          * Manual Volume 3B: System Programming Guide", "Table B-1
630          * CPUID Signature Values of DisplayFamily_DisplayModel".
631          */
632         switch (cpu_model) {
633         case 0 ... 2:
634                 *cpu_type = "i386/ppro";
635                 break;
636         case 3 ... 5:
637                 *cpu_type = "i386/pii";
638                 break;
639         case 6 ... 8:
640         case 10 ... 11:
641                 *cpu_type = "i386/piii";
642                 break;
643         case 9:
644         case 13:
645                 *cpu_type = "i386/p6_mobile";
646                 break;
647         case 14:
648                 *cpu_type = "i386/core";
649                 break;
650         case 0x0f:
651         case 0x16:
652         case 0x17:
653         case 0x1d:
654                 *cpu_type = "i386/core_2";
655                 break;
656         case 0x1a:
657         case 0x1e:
658         case 0x2e:
659                 spec = &op_arch_perfmon_spec;
660                 *cpu_type = "i386/core_i7";
661                 break;
662         case 0x1c:
663                 *cpu_type = "i386/atom";
664                 break;
665         default:
666                 /* Unknown */
667                 return 0;
668         }
669
670         model = spec;
671         return 1;
672 }
673
674 int __init op_nmi_init(struct oprofile_operations *ops)
675 {
676         __u8 vendor = boot_cpu_data.x86_vendor;
677         __u8 family = boot_cpu_data.x86;
678         char *cpu_type = NULL;
679         int ret = 0;
680
681         if (!cpu_has_apic)
682                 return -ENODEV;
683
684         switch (vendor) {
685         case X86_VENDOR_AMD:
686                 /* Needs to be at least an Athlon (or hammer in 32bit mode) */
687
688                 switch (family) {
689                 case 6:
690                         cpu_type = "i386/athlon";
691                         break;
692                 case 0xf:
693                         /*
694                          * Actually it could be i386/hammer too, but
695                          * give user space an consistent name.
696                          */
697                         cpu_type = "x86-64/hammer";
698                         break;
699                 case 0x10:
700                         cpu_type = "x86-64/family10";
701                         break;
702                 case 0x11:
703                         cpu_type = "x86-64/family11h";
704                         break;
705                 case 0x12:
706                         cpu_type = "x86-64/family12h";
707                         break;
708                 case 0x14:
709                         cpu_type = "x86-64/family14h";
710                         break;
711                 case 0x15:
712                         cpu_type = "x86-64/family15h";
713                         break;
714                 default:
715                         return -ENODEV;
716                 }
717                 model = &op_amd_spec;
718                 break;
719
720         case X86_VENDOR_INTEL:
721                 switch (family) {
722                         /* Pentium IV */
723                 case 0xf:
724                         p4_init(&cpu_type);
725                         break;
726
727                         /* A P6-class processor */
728                 case 6:
729                         ppro_init(&cpu_type);
730                         break;
731
732                 default:
733                         break;
734                 }
735
736                 if (cpu_type)
737                         break;
738
739                 if (!cpu_has_arch_perfmon)
740                         return -ENODEV;
741
742                 /* use arch perfmon as fallback */
743                 cpu_type = "i386/arch_perfmon";
744                 model = &op_arch_perfmon_spec;
745                 break;
746
747         default:
748                 return -ENODEV;
749         }
750
751         /* default values, can be overwritten by model */
752         ops->create_files       = nmi_create_files;
753         ops->setup              = nmi_setup;
754         ops->shutdown           = nmi_shutdown;
755         ops->start              = nmi_start;
756         ops->stop               = nmi_stop;
757         ops->cpu_type           = cpu_type;
758
759         if (model->init)
760                 ret = model->init(ops);
761         if (ret)
762                 return ret;
763
764         if (!model->num_virt_counters)
765                 model->num_virt_counters = model->num_counters;
766
767         mux_init(ops);
768
769         init_suspend_resume();
770
771         printk(KERN_INFO "oprofile: using NMI interrupt.\n");
772         return 0;
773 }
774
775 void op_nmi_exit(void)
776 {
777         exit_suspend_resume();
778 }