Path: blob/master/arch/x86/oprofile/nmi_timer_int.c
10817 views
/**1* @file nmi_timer_int.c2*3* @remark Copyright 2003 OProfile authors4* @remark Read the file COPYING5*6* @author Zwane Mwaikambo <[email protected]>7*/89#include <linux/init.h>10#include <linux/smp.h>11#include <linux/errno.h>12#include <linux/oprofile.h>13#include <linux/rcupdate.h>14#include <linux/kdebug.h>1516#include <asm/nmi.h>17#include <asm/apic.h>18#include <asm/ptrace.h>1920static int profile_timer_exceptions_notify(struct notifier_block *self,21unsigned long val, void *data)22{23struct die_args *args = (struct die_args *)data;24int ret = NOTIFY_DONE;2526switch (val) {27case DIE_NMI:28oprofile_add_sample(args->regs, 0);29ret = NOTIFY_STOP;30break;31default:32break;33}34return ret;35}3637static struct notifier_block profile_timer_exceptions_nb = {38.notifier_call = profile_timer_exceptions_notify,39.next = NULL,40.priority = NMI_LOW_PRIOR,41};4243static int timer_start(void)44{45if (register_die_notifier(&profile_timer_exceptions_nb))46return 1;47return 0;48}495051static void timer_stop(void)52{53unregister_die_notifier(&profile_timer_exceptions_nb);54synchronize_sched(); /* Allow already-started NMIs to complete. */55}565758int __init op_nmi_timer_init(struct oprofile_operations *ops)59{60ops->start = timer_start;61ops->stop = timer_stop;62ops->cpu_type = "timer";63printk(KERN_INFO "oprofile: using NMI timer interrupt.\n");64return 0;65}666768