Skip to content

Commit 97f0b13

Browse files
Xie XiuQitorvalds
authored andcommitted
tracing: add trace event for memory-failure
RAS user space tools like rasdaemon which base on trace event, could receive mce error event, but no memory recovery result event. So, I want to add this event to make this scenario complete. This patch add a event at ras group for memory-failure. The output like below: # tracer: nop # # entries-in-buffer/entries-written: 2/2 #P:24 # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | mce-inject-13150 [001] .... 277.019359: memory_failure_event: pfn 0x19869: recovery action for free buddy page: Delayed [[email protected]: fix build error] Signed-off-by: Xie XiuQi <[email protected]> Reviewed-by: Naoya Horiguchi <[email protected]> Acked-by: Steven Rostedt <[email protected]> Cc: Tony Luck <[email protected]> Cc: Chen Gong <[email protected]> Cc: Jim Davis <[email protected]> Signed-off-by: Xie XiuQi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent cc3e2af commit 97f0b13

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

include/ras/ras_event.h

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/pci.h>
1212
#include <linux/aer.h>
1313
#include <linux/cper.h>
14+
#include <linux/mm.h>
1415

1516
/*
1617
* MCE Extended Error Log trace event
@@ -232,6 +233,90 @@ TRACE_EVENT(aer_event,
232233
__print_flags(__entry->status, "|", aer_uncorrectable_errors))
233234
);
234235

236+
/*
237+
* memory-failure recovery action result event
238+
*
239+
* unsigned long pfn - Page Frame Number of the corrupted page
240+
* int type - Page types of the corrupted page
241+
* int result - Result of recovery action
242+
*/
243+
244+
#ifdef CONFIG_MEMORY_FAILURE
245+
#define MF_ACTION_RESULT \
246+
EM ( MF_IGNORED, "Ignored" ) \
247+
EM ( MF_FAILED, "Failed" ) \
248+
EM ( MF_DELAYED, "Delayed" ) \
249+
EMe ( MF_RECOVERED, "Recovered" )
250+
251+
#define MF_PAGE_TYPE \
252+
EM ( MF_MSG_KERNEL, "reserved kernel page" ) \
253+
EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \
254+
EM ( MF_MSG_SLAB, "kernel slab page" ) \
255+
EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \
256+
EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \
257+
EM ( MF_MSG_HUGE, "huge page" ) \
258+
EM ( MF_MSG_FREE_HUGE, "free huge page" ) \
259+
EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \
260+
EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \
261+
EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \
262+
EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \
263+
EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \
264+
EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \
265+
EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \
266+
EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \
267+
EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \
268+
EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \
269+
EM ( MF_MSG_BUDDY, "free buddy page" ) \
270+
EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \
271+
EMe ( MF_MSG_UNKNOWN, "unknown page" )
272+
273+
/*
274+
* First define the enums in MM_ACTION_RESULT to be exported to userspace
275+
* via TRACE_DEFINE_ENUM().
276+
*/
277+
#undef EM
278+
#undef EMe
279+
#define EM(a, b) TRACE_DEFINE_ENUM(a);
280+
#define EMe(a, b) TRACE_DEFINE_ENUM(a);
281+
282+
MF_ACTION_RESULT
283+
MF_PAGE_TYPE
284+
285+
/*
286+
* Now redefine the EM() and EMe() macros to map the enums to the strings
287+
* that will be printed in the output.
288+
*/
289+
#undef EM
290+
#undef EMe
291+
#define EM(a, b) { a, b },
292+
#define EMe(a, b) { a, b }
293+
294+
TRACE_EVENT(memory_failure_event,
295+
TP_PROTO(unsigned long pfn,
296+
int type,
297+
int result),
298+
299+
TP_ARGS(pfn, type, result),
300+
301+
TP_STRUCT__entry(
302+
__field(unsigned long, pfn)
303+
__field(int, type)
304+
__field(int, result)
305+
),
306+
307+
TP_fast_assign(
308+
__entry->pfn = pfn;
309+
__entry->type = type;
310+
__entry->result = result;
311+
),
312+
313+
TP_printk("pfn %#lx: recovery action for %s: %s",
314+
__entry->pfn,
315+
__print_symbolic(__entry->type, MF_PAGE_TYPE),
316+
__print_symbolic(__entry->result, MF_ACTION_RESULT)
317+
)
318+
);
319+
#endif /* CONFIG_MEMORY_FAILURE */
235320
#endif /* _TRACE_HW_EVENT_MC_H */
236321

237322
/* This part must be outside protection */

mm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ config MEMORY_FAILURE
368368
depends on ARCH_SUPPORTS_MEMORY_FAILURE
369369
bool "Enable recovery from hardware memory errors"
370370
select MEMORY_ISOLATION
371+
select RAS
371372
help
372373
Enables code to recover from some memory failures on systems
373374
with MCA recovery. This allows a system to continue running

mm/memory-failure.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include <linux/mm_inline.h>
5858
#include <linux/kfifo.h>
5959
#include "internal.h"
60+
#include "ras/ras_event.h"
6061

6162
int sysctl_memory_failure_early_kill __read_mostly = 0;
6263

@@ -855,6 +856,8 @@ static struct page_state {
855856
static void action_result(unsigned long pfn, enum mf_action_page_type type,
856857
enum mf_result result)
857858
{
859+
trace_memory_failure_event(pfn, type, result);
860+
858861
pr_err("MCE %#lx: recovery action for %s: %s\n",
859862
pfn, action_page_types[type], action_name[result]);
860863
}

0 commit comments

Comments
 (0)