ras_event.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM ras
  3. #define TRACE_INCLUDE_FILE ras_event
  4. #if !defined(_TRACE_HW_EVENT_MC_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_HW_EVENT_MC_H
  6. #include <linux/tracepoint.h>
  7. #include <linux/edac.h>
  8. #include <linux/ktime.h>
  9. #include <linux/pci.h>
  10. #include <linux/aer.h>
  11. #include <linux/cper.h>
  12. #include <linux/mm.h>
  13. /*
  14. * MCE Extended Error Log trace event
  15. *
  16. * These events are generated when hardware detects a corrected or
  17. * uncorrected event.
  18. */
  19. /* memory trace event */
  20. #if defined(CONFIG_ACPI_EXTLOG) || defined(CONFIG_ACPI_EXTLOG_MODULE)
  21. TRACE_EVENT(extlog_mem_event,
  22. TP_PROTO(struct cper_sec_mem_err *mem,
  23. u32 err_seq,
  24. const uuid_le *fru_id,
  25. const char *fru_text,
  26. u8 sev),
  27. TP_ARGS(mem, err_seq, fru_id, fru_text, sev),
  28. TP_STRUCT__entry(
  29. __field(u32, err_seq)
  30. __field(u8, etype)
  31. __field(u8, sev)
  32. __field(u64, pa)
  33. __field(u8, pa_mask_lsb)
  34. __field_struct(uuid_le, fru_id)
  35. __string(fru_text, fru_text)
  36. __field_struct(struct cper_mem_err_compact, data)
  37. ),
  38. TP_fast_assign(
  39. __entry->err_seq = err_seq;
  40. if (mem->validation_bits & CPER_MEM_VALID_ERROR_TYPE)
  41. __entry->etype = mem->error_type;
  42. else
  43. __entry->etype = ~0;
  44. __entry->sev = sev;
  45. if (mem->validation_bits & CPER_MEM_VALID_PA)
  46. __entry->pa = mem->physical_addr;
  47. else
  48. __entry->pa = ~0ull;
  49. if (mem->validation_bits & CPER_MEM_VALID_PA_MASK)
  50. __entry->pa_mask_lsb = (u8)__ffs64(mem->physical_addr_mask);
  51. else
  52. __entry->pa_mask_lsb = ~0;
  53. __entry->fru_id = *fru_id;
  54. __assign_str(fru_text, fru_text);
  55. cper_mem_err_pack(mem, &__entry->data);
  56. ),
  57. TP_printk("{%d} %s error: %s physical addr: %016llx (mask lsb: %x) %sFRU: %pUl %.20s",
  58. __entry->err_seq,
  59. cper_severity_str(__entry->sev),
  60. cper_mem_err_type_str(__entry->etype),
  61. __entry->pa,
  62. __entry->pa_mask_lsb,
  63. cper_mem_err_unpack(p, &__entry->data),
  64. &__entry->fru_id,
  65. __get_str(fru_text))
  66. );
  67. #endif
  68. /*
  69. * Hardware Events Report
  70. *
  71. * Those events are generated when hardware detected a corrected or
  72. * uncorrected event, and are meant to replace the current API to report
  73. * errors defined on both EDAC and MCE subsystems.
  74. *
  75. * FIXME: Add events for handling memory errors originated from the
  76. * MCE subsystem.
  77. */
  78. /*
  79. * Hardware-independent Memory Controller specific events
  80. */
  81. /*
  82. * Default error mechanisms for Memory Controller errors (CE and UE)
  83. */
  84. TRACE_EVENT(mc_event,
  85. TP_PROTO(const unsigned int err_type,
  86. const char *error_msg,
  87. const char *label,
  88. const int error_count,
  89. const u8 mc_index,
  90. const s8 top_layer,
  91. const s8 mid_layer,
  92. const s8 low_layer,
  93. unsigned long address,
  94. const u8 grain_bits,
  95. unsigned long syndrome,
  96. const char *driver_detail),
  97. TP_ARGS(err_type, error_msg, label, error_count, mc_index,
  98. top_layer, mid_layer, low_layer, address, grain_bits,
  99. syndrome, driver_detail),
  100. TP_STRUCT__entry(
  101. __field( unsigned int, error_type )
  102. __string( msg, error_msg )
  103. __string( label, label )
  104. __field( u16, error_count )
  105. __field( u8, mc_index )
  106. __field( s8, top_layer )
  107. __field( s8, middle_layer )
  108. __field( s8, lower_layer )
  109. __field( long, address )
  110. __field( u8, grain_bits )
  111. __field( long, syndrome )
  112. __string( driver_detail, driver_detail )
  113. ),
  114. TP_fast_assign(
  115. __entry->error_type = err_type;
  116. __assign_str(msg, error_msg);
  117. __assign_str(label, label);
  118. __entry->error_count = error_count;
  119. __entry->mc_index = mc_index;
  120. __entry->top_layer = top_layer;
  121. __entry->middle_layer = mid_layer;
  122. __entry->lower_layer = low_layer;
  123. __entry->address = address;
  124. __entry->grain_bits = grain_bits;
  125. __entry->syndrome = syndrome;
  126. __assign_str(driver_detail, driver_detail);
  127. ),
  128. TP_printk("%d %s error%s:%s%s on %s (mc:%d location:%d:%d:%d address:0x%08lx grain:%d syndrome:0x%08lx%s%s)",
  129. __entry->error_count,
  130. mc_event_error_type(__entry->error_type),
  131. __entry->error_count > 1 ? "s" : "",
  132. __get_str(msg)[0] ? " " : "",
  133. __get_str(msg),
  134. __get_str(label),
  135. __entry->mc_index,
  136. __entry->top_layer,
  137. __entry->middle_layer,
  138. __entry->lower_layer,
  139. __entry->address,
  140. 1 << __entry->grain_bits,
  141. __entry->syndrome,
  142. __get_str(driver_detail)[0] ? " " : "",
  143. __get_str(driver_detail))
  144. );
  145. /*
  146. * PCIe AER Trace event
  147. *
  148. * These events are generated when hardware detects a corrected or
  149. * uncorrected event on a PCIe device. The event report has
  150. * the following structure:
  151. *
  152. * char * dev_name - The name of the slot where the device resides
  153. * ([domain:]bus:device.function).
  154. * u32 status - Either the correctable or uncorrectable register
  155. * indicating what error or errors have been seen
  156. * u8 severity - error severity 0:NONFATAL 1:FATAL 2:CORRECTED
  157. */
  158. #define aer_correctable_errors \
  159. {PCI_ERR_COR_RCVR, "Receiver Error"}, \
  160. {PCI_ERR_COR_BAD_TLP, "Bad TLP"}, \
  161. {PCI_ERR_COR_BAD_DLLP, "Bad DLLP"}, \
  162. {PCI_ERR_COR_REP_ROLL, "RELAY_NUM Rollover"}, \
  163. {PCI_ERR_COR_REP_TIMER, "Replay Timer Timeout"}, \
  164. {PCI_ERR_COR_ADV_NFAT, "Advisory Non-Fatal Error"}, \
  165. {PCI_ERR_COR_INTERNAL, "Corrected Internal Error"}, \
  166. {PCI_ERR_COR_LOG_OVER, "Header Log Overflow"}
  167. #define aer_uncorrectable_errors \
  168. {PCI_ERR_UNC_UND, "Undefined"}, \
  169. {PCI_ERR_UNC_DLP, "Data Link Protocol Error"}, \
  170. {PCI_ERR_UNC_SURPDN, "Surprise Down Error"}, \
  171. {PCI_ERR_UNC_POISON_TLP,"Poisoned TLP"}, \
  172. {PCI_ERR_UNC_FCP, "Flow Control Protocol Error"}, \
  173. {PCI_ERR_UNC_COMP_TIME, "Completion Timeout"}, \
  174. {PCI_ERR_UNC_COMP_ABORT,"Completer Abort"}, \
  175. {PCI_ERR_UNC_UNX_COMP, "Unexpected Completion"}, \
  176. {PCI_ERR_UNC_RX_OVER, "Receiver Overflow"}, \
  177. {PCI_ERR_UNC_MALF_TLP, "Malformed TLP"}, \
  178. {PCI_ERR_UNC_ECRC, "ECRC Error"}, \
  179. {PCI_ERR_UNC_UNSUP, "Unsupported Request Error"}, \
  180. {PCI_ERR_UNC_ACSV, "ACS Violation"}, \
  181. {PCI_ERR_UNC_INTN, "Uncorrectable Internal Error"},\
  182. {PCI_ERR_UNC_MCBTLP, "MC Blocked TLP"}, \
  183. {PCI_ERR_UNC_ATOMEG, "AtomicOp Egress Blocked"}, \
  184. {PCI_ERR_UNC_TLPPRE, "TLP Prefix Blocked Error"}
  185. TRACE_EVENT(aer_event,
  186. TP_PROTO(const char *dev_name,
  187. const u32 status,
  188. const u8 severity),
  189. TP_ARGS(dev_name, status, severity),
  190. TP_STRUCT__entry(
  191. __string( dev_name, dev_name )
  192. __field( u32, status )
  193. __field( u8, severity )
  194. ),
  195. TP_fast_assign(
  196. __assign_str(dev_name, dev_name);
  197. __entry->status = status;
  198. __entry->severity = severity;
  199. ),
  200. TP_printk("%s PCIe Bus Error: severity=%s, %s\n",
  201. __get_str(dev_name),
  202. __entry->severity == AER_CORRECTABLE ? "Corrected" :
  203. __entry->severity == AER_FATAL ?
  204. "Fatal" : "Uncorrected, non-fatal",
  205. __entry->severity == AER_CORRECTABLE ?
  206. __print_flags(__entry->status, "|", aer_correctable_errors) :
  207. __print_flags(__entry->status, "|", aer_uncorrectable_errors))
  208. );
  209. /*
  210. * memory-failure recovery action result event
  211. *
  212. * unsigned long pfn - Page Frame Number of the corrupted page
  213. * int type - Page types of the corrupted page
  214. * int result - Result of recovery action
  215. */
  216. #ifdef CONFIG_MEMORY_FAILURE
  217. #define MF_ACTION_RESULT \
  218. EM ( MF_IGNORED, "Ignored" ) \
  219. EM ( MF_FAILED, "Failed" ) \
  220. EM ( MF_DELAYED, "Delayed" ) \
  221. EMe ( MF_RECOVERED, "Recovered" )
  222. #define MF_PAGE_TYPE \
  223. EM ( MF_MSG_KERNEL, "reserved kernel page" ) \
  224. EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \
  225. EM ( MF_MSG_SLAB, "kernel slab page" ) \
  226. EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \
  227. EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \
  228. EM ( MF_MSG_HUGE, "huge page" ) \
  229. EM ( MF_MSG_FREE_HUGE, "free huge page" ) \
  230. EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \
  231. EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \
  232. EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \
  233. EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \
  234. EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \
  235. EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \
  236. EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \
  237. EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \
  238. EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \
  239. EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \
  240. EM ( MF_MSG_BUDDY, "free buddy page" ) \
  241. EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \
  242. EMe ( MF_MSG_UNKNOWN, "unknown page" )
  243. /*
  244. * First define the enums in MM_ACTION_RESULT to be exported to userspace
  245. * via TRACE_DEFINE_ENUM().
  246. */
  247. #undef EM
  248. #undef EMe
  249. #define EM(a, b) TRACE_DEFINE_ENUM(a);
  250. #define EMe(a, b) TRACE_DEFINE_ENUM(a);
  251. MF_ACTION_RESULT
  252. MF_PAGE_TYPE
  253. /*
  254. * Now redefine the EM() and EMe() macros to map the enums to the strings
  255. * that will be printed in the output.
  256. */
  257. #undef EM
  258. #undef EMe
  259. #define EM(a, b) { a, b },
  260. #define EMe(a, b) { a, b }
  261. TRACE_EVENT(memory_failure_event,
  262. TP_PROTO(unsigned long pfn,
  263. int type,
  264. int result),
  265. TP_ARGS(pfn, type, result),
  266. TP_STRUCT__entry(
  267. __field(unsigned long, pfn)
  268. __field(int, type)
  269. __field(int, result)
  270. ),
  271. TP_fast_assign(
  272. __entry->pfn = pfn;
  273. __entry->type = type;
  274. __entry->result = result;
  275. ),
  276. TP_printk("pfn %#lx: recovery action for %s: %s",
  277. __entry->pfn,
  278. __print_symbolic(__entry->type, MF_PAGE_TYPE),
  279. __print_symbolic(__entry->result, MF_ACTION_RESULT)
  280. )
  281. );
  282. #endif /* CONFIG_MEMORY_FAILURE */
  283. #endif /* _TRACE_HW_EVENT_MC_H */
  284. /* This part must be outside protection */
  285. #include <trace/define_trace.h>