4 * @remark Copyright 2002 OProfile authors
5 * @remark Read the file COPYING
7 * @author John Levon <levon@movementarian.org>
10 #include <linux/kernel.h>
11 #include <linux/notifier.h>
12 #include <linux/smp.h>
13 #include <linux/oprofile.h>
14 #include <linux/profile.h>
15 #include <linux/init.h>
16 #include <asm/ptrace.h>
18 static int timer_notify(struct notifier_block * self, unsigned long val, void * data)
20 struct pt_regs * regs = (struct pt_regs *)data;
21 int cpu = smp_processor_id();
22 unsigned long eip = profile_pc(regs);
24 oprofile_add_sample(eip, !user_mode(regs), 0, cpu);
29 static struct notifier_block timer_notifier = {
30 .notifier_call = timer_notify,
34 static int timer_start(void)
36 return register_profile_notifier(&timer_notifier);
40 static void timer_stop(void)
42 unregister_profile_notifier(&timer_notifier);
46 static struct oprofile_operations timer_ops = {
53 void __init timer_init(struct oprofile_operations ** ops)
56 printk(KERN_INFO "oprofile: using timer interrupt.\n");