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/module.h>
  19. #include <linux/delay.h>
  20. #include <linux/seq_buf.h>
  21. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  22. u64 hw_nmi_get_sample_period(int watchdog_thresh)
  23. {
  24. return (u64)(cpu_khz) * 1000 * watchdog_thresh;
  25. }
  26. #endif
  27. #ifdef arch_trigger_all_cpu_backtrace
  28. static void nmi_raise_cpu_backtrace(cpumask_t *mask)
  29. {
  30. apic->send_IPI_mask(mask, NMI_VECTOR);
  31. }
  32. void arch_trigger_all_cpu_backtrace(bool include_self)
  33. {
  34. nmi_trigger_all_cpu_backtrace(include_self, nmi_raise_cpu_backtrace);
  35. }
  36. static int
  37. arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs)
  38. {
  39. if (nmi_cpu_backtrace(regs))
  40. return NMI_HANDLED;
  41. return NMI_DONE;
  42. }
  43. NOKPROBE_SYMBOL(arch_trigger_all_cpu_backtrace_handler);
  44. static int __init register_trigger_all_cpu_backtrace(void)
  45. {
  46. register_nmi_handler(NMI_LOCAL, arch_trigger_all_cpu_backtrace_handler,
  47. 0, "arch_bt");
  48. return 0;
  49. }
  50. early_initcall(register_trigger_all_cpu_backtrace);
  51. #endif