diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/x86/oprofile | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'arch/x86/oprofile')
| -rw-r--r-- | arch/x86/oprofile/nmi_timer_int.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/arch/x86/oprofile/nmi_timer_int.c b/arch/x86/oprofile/nmi_timer_int.c new file mode 100644 index 00000000000..720bf5a53c5 --- /dev/null +++ b/arch/x86/oprofile/nmi_timer_int.c | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /** | ||
| 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/errno.h> | ||
| 13 | #include <linux/oprofile.h> | ||
| 14 | #include <linux/rcupdate.h> | ||
| 15 | #include <linux/kdebug.h> | ||
| 16 | |||
| 17 | #include <asm/nmi.h> | ||
| 18 | #include <asm/apic.h> | ||
| 19 | #include <asm/ptrace.h> | ||
| 20 | |||
| 21 | static int profile_timer_exceptions_notify(struct notifier_block *self, | ||
| 22 | unsigned long val, void *data) | ||
| 23 | { | ||
| 24 | struct die_args *args = (struct die_args *)data; | ||
| 25 | int ret = NOTIFY_DONE; | ||
| 26 | |||
| 27 | switch (val) { | ||
| 28 | case DIE_NMI: | ||
| 29 | oprofile_add_sample(args->regs, 0); | ||
| 30 | ret = NOTIFY_STOP; | ||
| 31 | break; | ||
| 32 | default: | ||
| 33 | break; | ||
| 34 | } | ||
| 35 | return ret; | ||
| 36 | } | ||
| 37 | |||
| 38 | static struct notifier_block profile_timer_exceptions_nb = { | ||
| 39 | .notifier_call = profile_timer_exceptions_notify, | ||
| 40 | .next = NULL, | ||
| 41 | .priority = NMI_LOW_PRIOR, | ||
| 42 | }; | ||
| 43 | |||
| 44 | static int timer_start(void) | ||
| 45 | { | ||
| 46 | if (register_die_notifier(&profile_timer_exceptions_nb)) | ||
| 47 | return 1; | ||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | |||
| 51 | |||
| 52 | static void timer_stop(void) | ||
| 53 | { | ||
| 54 | unregister_die_notifier(&profile_timer_exceptions_nb); | ||
| 55 | synchronize_sched(); /* Allow already-started NMIs to complete. */ | ||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | int __init op_nmi_timer_init(struct oprofile_operations *ops) | ||
| 60 | { | ||
| 61 | ops->start = timer_start; | ||
| 62 | ops->stop = timer_stop; | ||
| 63 | ops->cpu_type = "timer"; | ||
| 64 | printk(KERN_INFO "oprofile: using NMI timer interrupt.\n"); | ||
| 65 | return 0; | ||
| 66 | } | ||
