diff options
Diffstat (limited to 'arch/sparc/oprofile/init.c')
-rw-r--r-- | arch/sparc/oprofile/init.c | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/arch/sparc/oprofile/init.c b/arch/sparc/oprofile/init.c index 17bb6035069b..d172f86439b1 100644 --- a/arch/sparc/oprofile/init.c +++ b/arch/sparc/oprofile/init.c @@ -12,11 +12,74 @@ #include <linux/errno.h> #include <linux/init.h> -int __init oprofile_arch_init(struct oprofile_operations *ops) +#ifdef CONFIG_SPARC64 +#include <linux/notifier.h> +#include <linux/rcupdate.h> +#include <linux/kdebug.h> +#include <asm/nmi.h> + +static int profile_timer_exceptions_notify(struct notifier_block *self, + unsigned long val, void *data) +{ + struct die_args *args = (struct die_args *)data; + int ret = NOTIFY_DONE; + + switch (val) { + case DIE_NMI: + oprofile_add_sample(args->regs, 0); + ret = NOTIFY_STOP; + break; + default: + break; + } + return ret; +} + +static struct notifier_block profile_timer_exceptions_nb = { + .notifier_call = profile_timer_exceptions_notify, +}; + +static int timer_start(void) +{ + if (register_die_notifier(&profile_timer_exceptions_nb)) + return 1; + nmi_adjust_hz(HZ); + return 0; +} + + +static void timer_stop(void) { - return -ENODEV; + nmi_adjust_hz(1); + unregister_die_notifier(&profile_timer_exceptions_nb); + synchronize_sched(); /* Allow already-started NMIs to complete. */ +} + +static int op_nmi_timer_init(struct oprofile_operations *ops) +{ + if (!nmi_usable) + return -ENODEV; + + ops->start = timer_start; + ops->stop = timer_stop; + ops->cpu_type = "timer"; + printk(KERN_INFO "oprofile: Using perfctr NMI timer interrupt.\n"); + return 0; } +#endif +int __init oprofile_arch_init(struct oprofile_operations *ops) +{ + int ret = -ENODEV; + +#ifdef CONFIG_SPARC64 + ret = op_nmi_timer_init(ops); + if (!ret) + return ret; +#endif + + return ret; +} void oprofile_arch_exit(void) { |