hw_nmi.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * HW NMI watchdog support
  3. *
  4. * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
  5. *
  6. * Arch specific calls to support NMI watchdog
  7. *
  8. * Bits copied from original nmi.c file
  9. *
  10. */
  11. #include <asm/apic.h>
  12. #include <asm/nmi.h>
  13. #include <linux/cpumask.h>
  14. #include <linux/kdebug.h>
  15. #include <linux/notifier.h>
  16. #include <linux/kprobes.h>
  17. #include <linux/nmi.h>
  18. #include <linux/init.h>
  19. #include <linux/delay.h>
  20. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  21. u64 hw_nmi_get_sample_period(int watchdog_thresh)
  22. {
  23. return (u64)(cpu_khz) * 1000 * watchdog_thresh;
  24. }
  25. #endif
  26. #ifdef arch_trigger_cpumask_backtrace
  27. static void nmi_raise_cpu_backtrace(cpumask_t *mask)
  28. {
  29. apic->send_IPI_mask(mask, NMI_VECTOR);
  30. }
  31. void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
  32. {
  33. nmi_trigger_cpumask_backtrace(mask, exclude_self,
  34. nmi_raise_cpu_backtrace);
  35. }
  36. static int nmi_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs)
  37. {
  38. if (nmi_cpu_backtrace(regs))
  39. return NMI_HANDLED;
  40. return NMI_DONE;
  41. }
  42. NOKPROBE_SYMBOL(nmi_cpu_backtrace_handler);
  43. static int __init register_nmi_cpu_backtrace_handler(void)
  44. {
  45. register_nmi_handler(NMI_LOCAL, nmi_cpu_backtrace_handler,
  46. 0, "arch_bt");
  47. return 0;
  48. }
  49. early_initcall(register_nmi_cpu_backtrace_handler);
  50. #endif