Skip to content

Commit 3180748

Browse files
xieyuanbin1-huaweiakpm00
authored andcommitted
mm/memory-failure: remove the selection of RAS
commit 97f0b13 ("tracing: add trace event for memory-failure") introduces the selection of RAS in memory-failure. This commit is just a tracing feature; in reality, there is no dependency between memory-failure and RAS. RAS increases the size of the bzImage image by 8k, which is very valuable for embedded devices. Move the memory-failure traceing code from ras_event.h to memory-failure.h and remove the selection of RAS. Link: https://lkml.kernel.org/r/20251119095943.67125-1-xieyuanbin1@huawei.com Signed-off-by: Xie Yuanbin <xieyuanbin1@huawei.com> Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> Acked-by: Miaohe Lin <linmiaohe@huawei.com> Cc: Borislav Petkov <bp@alien8.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 519912b commit 3180748

5 files changed

Lines changed: 103 additions & 89 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11560,6 +11560,7 @@ R: Naoya Horiguchi <nao.horiguchi@gmail.com>
1156011560
L: linux-mm@kvack.org
1156111561
S: Maintained
1156211562
F: include/linux/memory-failure.h
11563+
F: include/trace/events/memory-failure.h
1156311564
F: mm/hwpoison-inject.c
1156411565
F: mm/memory-failure.c
1156511566

include/ras/ras_event.h

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/pci.h>
1313
#include <linux/aer.h>
1414
#include <linux/cper.h>
15-
#include <linux/mm.h>
1615

1716
/*
1817
* MCE Extended Error Log trace event
@@ -339,92 +338,6 @@ TRACE_EVENT(aer_event,
339338
"Not available")
340339
);
341340
#endif /* CONFIG_PCIEAER */
342-
343-
/*
344-
* memory-failure recovery action result event
345-
*
346-
* unsigned long pfn - Page Frame Number of the corrupted page
347-
* int type - Page types of the corrupted page
348-
* int result - Result of recovery action
349-
*/
350-
351-
#ifdef CONFIG_MEMORY_FAILURE
352-
#define MF_ACTION_RESULT \
353-
EM ( MF_IGNORED, "Ignored" ) \
354-
EM ( MF_FAILED, "Failed" ) \
355-
EM ( MF_DELAYED, "Delayed" ) \
356-
EMe ( MF_RECOVERED, "Recovered" )
357-
358-
#define MF_PAGE_TYPE \
359-
EM ( MF_MSG_KERNEL, "reserved kernel page" ) \
360-
EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \
361-
EM ( MF_MSG_HUGE, "huge page" ) \
362-
EM ( MF_MSG_FREE_HUGE, "free huge page" ) \
363-
EM ( MF_MSG_GET_HWPOISON, "get hwpoison page" ) \
364-
EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \
365-
EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \
366-
EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \
367-
EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \
368-
EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \
369-
EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \
370-
EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \
371-
EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \
372-
EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \
373-
EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \
374-
EM ( MF_MSG_BUDDY, "free buddy page" ) \
375-
EM ( MF_MSG_DAX, "dax page" ) \
376-
EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \
377-
EM ( MF_MSG_ALREADY_POISONED, "already poisoned" ) \
378-
EM ( MF_MSG_PFN_MAP, "non struct page pfn" ) \
379-
EMe ( MF_MSG_UNKNOWN, "unknown page" )
380-
381-
/*
382-
* First define the enums in MM_ACTION_RESULT to be exported to userspace
383-
* via TRACE_DEFINE_ENUM().
384-
*/
385-
#undef EM
386-
#undef EMe
387-
#define EM(a, b) TRACE_DEFINE_ENUM(a);
388-
#define EMe(a, b) TRACE_DEFINE_ENUM(a);
389-
390-
MF_ACTION_RESULT
391-
MF_PAGE_TYPE
392-
393-
/*
394-
* Now redefine the EM() and EMe() macros to map the enums to the strings
395-
* that will be printed in the output.
396-
*/
397-
#undef EM
398-
#undef EMe
399-
#define EM(a, b) { a, b },
400-
#define EMe(a, b) { a, b }
401-
402-
TRACE_EVENT(memory_failure_event,
403-
TP_PROTO(unsigned long pfn,
404-
int type,
405-
int result),
406-
407-
TP_ARGS(pfn, type, result),
408-
409-
TP_STRUCT__entry(
410-
__field(unsigned long, pfn)
411-
__field(int, type)
412-
__field(int, result)
413-
),
414-
415-
TP_fast_assign(
416-
__entry->pfn = pfn;
417-
__entry->type = type;
418-
__entry->result = result;
419-
),
420-
421-
TP_printk("pfn %#lx: recovery action for %s: %s",
422-
__entry->pfn,
423-
__print_symbolic(__entry->type, MF_PAGE_TYPE),
424-
__print_symbolic(__entry->result, MF_ACTION_RESULT)
425-
)
426-
);
427-
#endif /* CONFIG_MEMORY_FAILURE */
428341
#endif /* _TRACE_HW_EVENT_MC_H */
429342

430343
/* This part must be outside protection */
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#undef TRACE_SYSTEM
3+
#define TRACE_SYSTEM memory_failure
4+
#define TRACE_INCLUDE_FILE memory-failure
5+
6+
#if !defined(_TRACE_MEMORY_FAILURE_H) || defined(TRACE_HEADER_MULTI_READ)
7+
#define _TRACE_MEMORY_FAILURE_H
8+
9+
#include <linux/tracepoint.h>
10+
#include <linux/mm.h>
11+
12+
/*
13+
* memory-failure recovery action result event
14+
*
15+
* unsigned long pfn - Page Frame Number of the corrupted page
16+
* int type - Page types of the corrupted page
17+
* int result - Result of recovery action
18+
*/
19+
20+
#define MF_ACTION_RESULT \
21+
EM ( MF_IGNORED, "Ignored" ) \
22+
EM ( MF_FAILED, "Failed" ) \
23+
EM ( MF_DELAYED, "Delayed" ) \
24+
EMe ( MF_RECOVERED, "Recovered" )
25+
26+
#define MF_PAGE_TYPE \
27+
EM ( MF_MSG_KERNEL, "reserved kernel page" ) \
28+
EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \
29+
EM ( MF_MSG_HUGE, "huge page" ) \
30+
EM ( MF_MSG_FREE_HUGE, "free huge page" ) \
31+
EM ( MF_MSG_GET_HWPOISON, "get hwpoison page" ) \
32+
EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \
33+
EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \
34+
EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \
35+
EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \
36+
EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \
37+
EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \
38+
EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \
39+
EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \
40+
EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \
41+
EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \
42+
EM ( MF_MSG_BUDDY, "free buddy page" ) \
43+
EM ( MF_MSG_DAX, "dax page" ) \
44+
EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \
45+
EM ( MF_MSG_ALREADY_POISONED, "already poisoned" ) \
46+
EM ( MF_MSG_PFN_MAP, "non struct page pfn" ) \
47+
EMe ( MF_MSG_UNKNOWN, "unknown page" )
48+
49+
/*
50+
* First define the enums in MM_ACTION_RESULT to be exported to userspace
51+
* via TRACE_DEFINE_ENUM().
52+
*/
53+
#undef EM
54+
#undef EMe
55+
#define EM(a, b) TRACE_DEFINE_ENUM(a);
56+
#define EMe(a, b) TRACE_DEFINE_ENUM(a);
57+
58+
MF_ACTION_RESULT
59+
MF_PAGE_TYPE
60+
61+
/*
62+
* Now redefine the EM() and EMe() macros to map the enums to the strings
63+
* that will be printed in the output.
64+
*/
65+
#undef EM
66+
#undef EMe
67+
#define EM(a, b) { a, b },
68+
#define EMe(a, b) { a, b }
69+
70+
TRACE_EVENT(memory_failure_event,
71+
TP_PROTO(unsigned long pfn,
72+
int type,
73+
int result),
74+
75+
TP_ARGS(pfn, type, result),
76+
77+
TP_STRUCT__entry(
78+
__field(unsigned long, pfn)
79+
__field(int, type)
80+
__field(int, result)
81+
),
82+
83+
TP_fast_assign(
84+
__entry->pfn = pfn;
85+
__entry->type = type;
86+
__entry->result = result;
87+
),
88+
89+
TP_printk("pfn %#lx: recovery action for %s: %s",
90+
__entry->pfn,
91+
__print_symbolic(__entry->type, MF_PAGE_TYPE),
92+
__print_symbolic(__entry->result, MF_ACTION_RESULT)
93+
)
94+
);
95+
#endif /* _TRACE_MEMORY_FAILURE_H */
96+
97+
/* This part must be outside protection */
98+
#include <trace/define_trace.h>

mm/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,6 @@ config MEMORY_FAILURE
740740
depends on MMU
741741
depends on ARCH_SUPPORTS_MEMORY_FAILURE
742742
bool "Enable recovery from hardware memory errors"
743-
select RAS
744743
select INTERVAL_TREE
745744
help
746745
Enables code to recover from some memory failures on systems

mm/memory-failure.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@
6161
#include <linux/pagewalk.h>
6262
#include <linux/shmem_fs.h>
6363
#include <linux/sysctl.h>
64+
65+
#define CREATE_TRACE_POINTS
66+
#include <trace/events/memory-failure.h>
67+
6468
#include "swap.h"
6569
#include "internal.h"
66-
#include "ras/ras_event.h"
6770

6871
static int sysctl_memory_failure_early_kill __read_mostly;
6972

0 commit comments

Comments
 (0)