nmi.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * linux/include/linux/nmi.h
  3. */
  4. #ifndef LINUX_NMI_H
  5. #define LINUX_NMI_H
  6. #include <linux/sched.h>
  7. #include <asm/irq.h>
  8. /**
  9. * touch_nmi_watchdog - restart NMI watchdog timeout.
  10. *
  11. * If the architecture supports the NMI watchdog, touch_nmi_watchdog()
  12. * may be used to reset the timeout - for code which intentionally
  13. * disables interrupts for a long time. This call is stateless.
  14. */
  15. #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
  16. #include <asm/nmi.h>
  17. extern void touch_nmi_watchdog(void);
  18. #else
  19. static inline void touch_nmi_watchdog(void)
  20. {
  21. touch_softlockup_watchdog();
  22. }
  23. #endif
  24. #if defined(CONFIG_HARDLOCKUP_DETECTOR)
  25. extern void hardlockup_detector_disable(void);
  26. #else
  27. static inline void hardlockup_detector_disable(void) {}
  28. #endif
  29. /*
  30. * Create trigger_all_cpu_backtrace() out of the arch-provided
  31. * base function. Return whether such support was available,
  32. * to allow calling code to fall back to some other mechanism:
  33. */
  34. #ifdef arch_trigger_all_cpu_backtrace
  35. static inline bool trigger_all_cpu_backtrace(void)
  36. {
  37. arch_trigger_all_cpu_backtrace(true);
  38. return true;
  39. }
  40. static inline bool trigger_allbutself_cpu_backtrace(void)
  41. {
  42. arch_trigger_all_cpu_backtrace(false);
  43. return true;
  44. }
  45. /* generic implementation */
  46. void nmi_trigger_all_cpu_backtrace(bool include_self,
  47. void (*raise)(cpumask_t *mask));
  48. bool nmi_cpu_backtrace(struct pt_regs *regs);
  49. #else
  50. static inline bool trigger_all_cpu_backtrace(void)
  51. {
  52. return false;
  53. }
  54. static inline bool trigger_allbutself_cpu_backtrace(void)
  55. {
  56. return false;
  57. }
  58. #endif
  59. #ifdef CONFIG_LOCKUP_DETECTOR
  60. int hw_nmi_is_cpu_stuck(struct pt_regs *);
  61. u64 hw_nmi_get_sample_period(int watchdog_thresh);
  62. extern int nmi_watchdog_enabled;
  63. extern int soft_watchdog_enabled;
  64. extern int watchdog_user_enabled;
  65. extern int watchdog_thresh;
  66. extern unsigned long *watchdog_cpumask_bits;
  67. extern int sysctl_softlockup_all_cpu_backtrace;
  68. extern int sysctl_hardlockup_all_cpu_backtrace;
  69. struct ctl_table;
  70. extern int proc_watchdog(struct ctl_table *, int ,
  71. void __user *, size_t *, loff_t *);
  72. extern int proc_nmi_watchdog(struct ctl_table *, int ,
  73. void __user *, size_t *, loff_t *);
  74. extern int proc_soft_watchdog(struct ctl_table *, int ,
  75. void __user *, size_t *, loff_t *);
  76. extern int proc_watchdog_thresh(struct ctl_table *, int ,
  77. void __user *, size_t *, loff_t *);
  78. extern int proc_watchdog_cpumask(struct ctl_table *, int,
  79. void __user *, size_t *, loff_t *);
  80. extern int lockup_detector_suspend(void);
  81. extern void lockup_detector_resume(void);
  82. #else
  83. static inline int lockup_detector_suspend(void)
  84. {
  85. return 0;
  86. }
  87. static inline void lockup_detector_resume(void)
  88. {
  89. }
  90. #endif
  91. #ifdef CONFIG_HAVE_ACPI_APEI_NMI
  92. #include <asm/nmi.h>
  93. #endif
  94. #endif