2005-04-16 15:20:36 -07:00
|
|
|
/**
|
|
|
|
|
* @file nmi_timer_int.c
|
|
|
|
|
*
|
|
|
|
|
* @remark Copyright 2003 OProfile authors
|
|
|
|
|
* @remark Read the file COPYING
|
|
|
|
|
*
|
|
|
|
|
* @author Zwane Mwaikambo <zwane@linuxpower.ca>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
#include <linux/smp.h>
|
2005-09-26 05:49:44 +01:00
|
|
|
#include <linux/errno.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/oprofile.h>
|
|
|
|
|
#include <linux/rcupdate.h>
|
2007-05-08 00:27:03 -07:00
|
|
|
#include <linux/kdebug.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
#include <asm/nmi.h>
|
|
|
|
|
#include <asm/apic.h>
|
|
|
|
|
#include <asm/ptrace.h>
|
2008-02-22 23:11:34 +01:00
|
|
|
|
2011-09-30 15:06:21 -04:00
|
|
|
static int profile_timer_exceptions_notify(unsigned int val, struct pt_regs *regs)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2011-09-30 15:06:21 -04:00
|
|
|
oprofile_add_sample(regs, 0);
|
|
|
|
|
return NMI_HANDLED;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int timer_start(void)
|
|
|
|
|
{
|
2011-09-30 15:06:21 -04:00
|
|
|
if (register_nmi_handler(NMI_LOCAL, profile_timer_exceptions_notify,
|
|
|
|
|
0, "oprofile-timer"))
|
2006-09-26 10:52:27 +02:00
|
|
|
return 1;
|
2005-04-16 15:20:36 -07:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void timer_stop(void)
|
|
|
|
|
{
|
2011-09-30 15:06:21 -04:00
|
|
|
unregister_nmi_handler(NMI_LOCAL, "oprofile-timer");
|
2005-05-01 08:59:04 -07:00
|
|
|
synchronize_sched(); /* Allow already-started NMIs to complete. */
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-22 23:11:34 +01:00
|
|
|
int __init op_nmi_timer_init(struct oprofile_operations *ops)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
|
ops->start = timer_start;
|
|
|
|
|
ops->stop = timer_stop;
|
|
|
|
|
ops->cpu_type = "timer";
|
|
|
|
|
printk(KERN_INFO "oprofile: using NMI timer interrupt.\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|