nmi_timer_int.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <linux/init.h>
  10. #include <linux/smp.h>
  11. #include <linux/irq.h>
  12. #include <linux/oprofile.h>
  13. #include <linux/rcupdate.h>
  14. #include <asm/nmi.h>
  15. #include <asm/apic.h>
  16. #include <asm/ptrace.h>
  17. static int nmi_timer_callback(struct pt_regs * regs, int cpu)
  18. {
  19. oprofile_add_sample(regs, 0);
  20. return 1;
  21. }
  22. static int timer_start(void)
  23. {
  24. disable_timer_nmi_watchdog();
  25. set_nmi_callback(nmi_timer_callback);
  26. return 0;
  27. }
  28. static void timer_stop(void)
  29. {
  30. enable_timer_nmi_watchdog();
  31. unset_nmi_callback();
  32. synchronize_sched(); /* Allow already-started NMIs to complete. */
  33. }
  34. int __init op_nmi_timer_init(struct oprofile_operations * ops)
  35. {
  36. extern int nmi_active;
  37. if (nmi_active <= 0)
  38. return -ENODEV;
  39. ops->start = timer_start;
  40. ops->stop = timer_stop;
  41. ops->cpu_type = "timer";
  42. printk(KERN_INFO "oprofile: using NMI timer interrupt.\n");
  43. return 0;
  44. }