mm: make wait_on_page_writeback() wait for multiple pending writebacks
[linux/fpc-iii.git] / arch / sparc / oprofile / init.c
blob43730c9b1c8671ad5c6295c4caa05c6e193e0aa2
1 /**
2 * @file init.c
4 * @remark Copyright 2002 OProfile authors
5 * @remark Read the file COPYING
7 * @author John Levon <levon@movementarian.org>
8 */
10 #include <linux/kernel.h>
11 #include <linux/oprofile.h>
12 #include <linux/errno.h>
13 #include <linux/init.h>
14 #include <linux/param.h> /* for HZ */
16 #ifdef CONFIG_SPARC64
17 #include <linux/notifier.h>
18 #include <linux/rcupdate.h>
19 #include <linux/kdebug.h>
20 #include <asm/nmi.h>
22 static int profile_timer_exceptions_notify(struct notifier_block *self,
23 unsigned long val, void *data)
25 struct die_args *args = data;
26 int ret = NOTIFY_DONE;
28 switch (val) {
29 case DIE_NMI:
30 oprofile_add_sample(args->regs, 0);
31 ret = NOTIFY_STOP;
32 break;
33 default:
34 break;
36 return ret;
39 static struct notifier_block profile_timer_exceptions_nb = {
40 .notifier_call = profile_timer_exceptions_notify,
43 static int timer_start(void)
45 if (register_die_notifier(&profile_timer_exceptions_nb))
46 return 1;
47 nmi_adjust_hz(HZ);
48 return 0;
52 static void timer_stop(void)
54 nmi_adjust_hz(1);
55 unregister_die_notifier(&profile_timer_exceptions_nb);
56 synchronize_rcu(); /* Allow already-started NMIs to complete. */
59 static int op_nmi_timer_init(struct oprofile_operations *ops)
61 if (atomic_read(&nmi_active) <= 0)
62 return -ENODEV;
64 ops->start = timer_start;
65 ops->stop = timer_stop;
66 ops->cpu_type = "timer";
67 printk(KERN_INFO "oprofile: Using perfctr NMI timer interrupt.\n");
68 return 0;
70 #endif
72 int __init oprofile_arch_init(struct oprofile_operations *ops)
74 int ret = -ENODEV;
76 #ifdef CONFIG_SPARC64
77 ret = op_nmi_timer_init(ops);
78 if (!ret)
79 return ret;
80 #endif
82 return ret;
85 void oprofile_arch_exit(void)