nmi_timer_int.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/errno.h>
  12. #include <linux/oprofile.h>
  13. #include <linux/rcupdate.h>
  14. #include <linux/kdebug.h>
  15. #include <asm/nmi.h>
  16. #include <asm/apic.h>
  17. #include <asm/ptrace.h>
  18. static int profile_timer_exceptions_notify(unsigned int val, struct pt_regs *regs)
  19. {
  20. oprofile_add_sample(regs, 0);
  21. return NMI_HANDLED;
  22. }
  23. static int timer_start(void)
  24. {
  25. if (register_nmi_handler(NMI_LOCAL, profile_timer_exceptions_notify,
  26. 0, "oprofile-timer"))
  27. return 1;
  28. return 0;
  29. }
  30. static void timer_stop(void)
  31. {
  32. unregister_nmi_handler(NMI_LOCAL, "oprofile-timer");
  33. synchronize_sched(); /* Allow already-started NMIs to complete. */
  34. }
  35. int __init op_nmi_timer_init(struct oprofile_operations *ops)
  36. {
  37. ops->start = timer_start;
  38. ops->stop = timer_stop;
  39. ops->cpu_type = "timer";
  40. printk(KERN_INFO "oprofile: using NMI timer interrupt.\n");
  41. return 0;
  42. }