Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial
[linux-2.6/kvm.git] / arch / i386 / oprofile / nmi_timer_int.c
blob930a1127bb309e0ff9030384f452e1641d59ea96
1 /**
2 * @file nmi_timer_int.c
4 * @remark Copyright 2003 OProfile authors
5 * @remark Read the file COPYING
7 * @author Zwane Mwaikambo <zwane@linuxpower.ca>
8 */
10 #include <linux/init.h>
11 #include <linux/smp.h>
12 #include <linux/errno.h>
13 #include <linux/oprofile.h>
14 #include <linux/rcupdate.h>
17 #include <asm/nmi.h>
18 #include <asm/apic.h>
19 #include <asm/ptrace.h>
21 static int nmi_timer_callback(struct pt_regs * regs, int cpu)
23 oprofile_add_sample(regs, 0);
24 return 1;
27 static int timer_start(void)
29 disable_timer_nmi_watchdog();
30 set_nmi_callback(nmi_timer_callback);
31 return 0;
35 static void timer_stop(void)
37 enable_timer_nmi_watchdog();
38 unset_nmi_callback();
39 synchronize_sched(); /* Allow already-started NMIs to complete. */
43 int __init op_nmi_timer_init(struct oprofile_operations * ops)
45 extern int nmi_active;
47 if (nmi_active <= 0)
48 return -ENODEV;
50 ops->start = timer_start;
51 ops->stop = timer_stop;
52 ops->cpu_type = "timer";
53 printk(KERN_INFO "oprofile: using NMI timer interrupt.\n");
54 return 0;