blob: c58d0c14f2744a0ae524f07d3f73089d9486e049 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/**
2 * @file nmi_timer_int.c
3 *
4 * @remark Copyright 2003 OProfile authors
5 * @remark Read the file COPYING
6 *
7 * @author Zwane Mwaikambo <zwane@linuxpower.ca>
8 */
9
10#include <linux/init.h>
11#include <linux/smp.h>
12#include <linux/irq.h>
13#include <linux/oprofile.h>
14#include <linux/rcupdate.h>
15
16
17#include <asm/nmi.h>
18#include <asm/apic.h>
19#include <asm/ptrace.h>
20
21static int nmi_timer_callback(struct pt_regs * regs, int cpu)
22{
23 oprofile_add_sample(regs, 0);
24 return 1;
25}
26
27static int timer_start(void)
28{
29 disable_timer_nmi_watchdog();
30 set_nmi_callback(nmi_timer_callback);
31 return 0;
32}
33
34
35static void timer_stop(void)
36{
37 enable_timer_nmi_watchdog();
38 unset_nmi_callback();
Paul E. McKenneyfbd568a3e2005-05-01 08:59:04 -070039 synchronize_sched(); /* Allow already-started NMIs to complete. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040}
41
42
43int __init nmi_timer_init(struct oprofile_operations * ops)
44{
45 extern int nmi_active;
46
47 if (nmi_active <= 0)
48 return -ENODEV;
49
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;
55}