From nobody Sun Feb 8 12:36:24 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F175328FFFB; Tue, 4 Nov 2025 07:23:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762240998; cv=none; b=Y9qNVQYOh/+elelLLw0ZntDTiCyqWtW777V/BCIMbLrpDGM9wauq+ZPx3f7tVpM1PLpcu2x8qR51oC8gj1xXqSvdoNqCcDd+TRvQoGr7vd8KxK0/Ur4BNQ9JzD9OqkGWcOCR/arVwngegbsdYzJBF1XPd8DtcHtr5AEaq0f82Uc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762240998; c=relaxed/simple; bh=3vVe7TDYnR9ehJ7D6C2tMAepXRSFgcke+mQsyT7GWCQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sGNI9E1LfGJvzuG2lrmyVurRpdxPwAh//34A0Q8skK/wWI+m8xRjxpD3+QUiIUQ/ovChPatQ43tzJYfR3f7qizLspTFOx5kZ0HRZcBy4t2mfyKD1fMBVM29kDbhIfD3pjH/CZJPkVjAgRQ2yJn+RYdfio7aERz4F13mtfZY9WNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=rRFvaS8d; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="rRFvaS8d" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=NghPoVpU9F9TPfTZpSz+vCAG1iGPiKItcdvquhOQIn4=; b=rRFvaS8dJ0mRc4JzcbwoZpDYcsM59LP6EXUUKmiKOrxgiB0iiudwogcBujZwcoQpbPe7pATMf 0l75qpkTRD2jQoXbGvabjU417w2lVBfvW0swG76sU3jj0Lv3+6XUo8y+QX31/VO4WfDJoNHjzAd 6yMq/k3X8v/JfJWUEr1U41o= Received: from mail.maildlp.com (unknown [172.19.88.105]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4d10J254Ktzcb3X; Tue, 4 Nov 2025 15:21:38 +0800 (CST) Received: from kwepemj100009.china.huawei.com (unknown [7.202.194.3]) by mail.maildlp.com (Postfix) with ESMTPS id 5D9BA1402E9; Tue, 4 Nov 2025 15:23:13 +0800 (CST) Received: from DESKTOP-A37P9LK.huawei.com (10.67.109.17) by kwepemj100009.china.huawei.com (7.202.194.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 4 Nov 2025 15:23:12 +0800 From: Xie Yuanbin To: , , , , , , , , , , , , , , , , , , CC: , , , , , , , Xie Yuanbin Subject: [PATCH v2 1/2] x86/mm: support memory-failure on 32-bits with SPARSEMEM Date: Tue, 4 Nov 2025 15:23:05 +0800 Message-ID: <20251104072306.100738-2-xieyuanbin1@huawei.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104072306.100738-1-xieyuanbin1@huawei.com> References: <20251104072306.100738-1-xieyuanbin1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemj100009.china.huawei.com (7.202.194.3) Content-Type: text/plain; charset="utf-8" The historical commit d949f36f1865c60239d4 ("x86: Fix hwpoison code related build failure on 32-bit NUMAQ"), disabled x86_32's memory-failure when SPARSEMEM is enabled, because the number of page-flags are insufficient. The commit 46df8e73a4a3f1445f2a ("mm: free up PG_slab") removes PG_slab flag that allows MEMORY_FAILURE to be enabled from here on. The commit 09022bc196d23484a7a5 ("mm: remove PG_error") removes PG_error flag. The commit cceba6f7e46c48deca43 ("mm: add PG_dropbehind folio flag") add PG_dropbehind flag, but MEMORY_FAILURE can still be enabled. For the current version, for x86_32, when SPARSEMEM && HIGHMEM && X86_PAE && X86_PAT, the number of pageflags reaches its maximum value, which is 31. Therefore, MEMORY_FAILURE can be safely enabled. Signed-off-by: Xie Yuanbin Cc: David Hildenbrand Cc: Dave Hansen Acked-by: David Hildenbrand (Red Hat) --- arch/x86/Kconfig | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d55c01efd7c2..f9ee57a55500 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -750,13 +750,10 @@ config IOSF_MBI_DEBUG =20 config X86_SUPPORTS_MEMORY_FAILURE def_bool y # MCE code calls memory_failure(): depends on X86_MCE - # On 32-bit this adds too big of NODES_SHIFT and we run out of page flags: - # On 32-bit SPARSEMEM adds too big of SECTIONS_WIDTH: - depends on X86_64 || !SPARSEMEM select ARCH_SUPPORTS_MEMORY_FAILURE =20 config X86_32_IRIS tristate "Eurobraille/Iris poweroff module" depends on X86_32 --=20 2.51.0 From nobody Sun Feb 8 12:36:24 2026 Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FB112BCF4A; Tue, 4 Nov 2025 07:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.224 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762241004; cv=none; b=XLUc6Cka/OphGP02ElBnhOXx8G/CYwvZV8ClZ3IjbIZjvEXeF13SU1T6iALpZUjuDgwvrGfUPAX/DPtT3lNJyLFAWsJm4kSy+Kcup3FYvq3AKaLJijX+mqogzKLSaKYr/zLVxQaxIlhiwIK6QH/Nw8tkNPjMVSoTft7bty4603M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762241004; c=relaxed/simple; bh=wxCxhzy09vQ2GkMKL/aARYJb2KCwOoUmwyawAYhA6NM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kbAGN++nGJhFYJ2Es1SI9rWVwNAiiuh1g8iRs5XZfDsoU+fmh6flVA26FEaOi+t4IG8z6UeW0ZK73l6Ck1xxiKNNkb1y3YYMlR9B5oNNJxjaRryp/I6VXQL1IotRoj9bKv6ssxjRIsNQry749nmpvQ8+WKOgk0vdYkyBj4nINzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=xroOrPlT; arc=none smtp.client-ip=113.46.200.224 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="xroOrPlT" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=5ACxLG6dzzDo30S/CHlMc09wITqLQddejtCKmmhm0BQ=; b=xroOrPlTR0uZ9+iLfrqbfubRjRexnA3TBZ399y4grTlz9Flnce/wf9rEsSbMR5Z3Ps0RA0NTS EVcGDFAtakWZH2kG6c/Hpf+G9xVkXG8fcV8L6avJItBdLACHEcjs5TY4z8H79s6B2e12l6/l3Wh s7IaF6vGqb2v2F8wLNkFxkI= Received: from mail.maildlp.com (unknown [172.19.163.44]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4d10J319T3z1cyPR; Tue, 4 Nov 2025 15:21:39 +0800 (CST) Received: from kwepemj100009.china.huawei.com (unknown [7.202.194.3]) by mail.maildlp.com (Postfix) with ESMTPS id 1009E140158; Tue, 4 Nov 2025 15:23:14 +0800 (CST) Received: from DESKTOP-A37P9LK.huawei.com (10.67.109.17) by kwepemj100009.china.huawei.com (7.202.194.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 4 Nov 2025 15:23:13 +0800 From: Xie Yuanbin To: , , , , , , , , , , , , , , , , , , CC: , , , , , , , Xie Yuanbin Subject: [PATCH v2 2/2] mm/memory-failure: remove the selection of RAS Date: Tue, 4 Nov 2025 15:23:06 +0800 Message-ID: <20251104072306.100738-3-xieyuanbin1@huawei.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251104072306.100738-1-xieyuanbin1@huawei.com> References: <20251104072306.100738-1-xieyuanbin1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemj100009.china.huawei.com (7.202.194.3) Content-Type: text/plain; charset="utf-8" The commit 97f0b13452198290799f ("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. Signed-off-by: Xie Yuanbin Cc: David Hildenbrand Cc: Borislav Petkov Acked-by: David Hildenbrand (Red Hat) --- include/ras/ras_event.h | 86 ------------------------ include/trace/events/memory-failure.h | 97 +++++++++++++++++++++++++++ mm/Kconfig | 1 - mm/memory-failure.c | 5 +- 4 files changed, 101 insertions(+), 88 deletions(-) create mode 100644 include/trace/events/memory-failure.h diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h index c8cd0f00c845..1e5e87020eef 100644 --- a/include/ras/ras_event.h +++ b/include/ras/ras_event.h @@ -10,11 +10,10 @@ #include #include #include #include #include -#include =20 /* * MCE Extended Error Log trace event * * These events are generated when hardware detects a corrected or @@ -337,94 +336,9 @@ TRACE_EVENT(aer_event, __entry->tlp_header_valid ? __print_array(__entry->tlp_header, PCIE_STD_MAX_TLP_HEADERLOG, 4) : "Not available") ); #endif /* CONFIG_PCIEAER */ - -/* - * memory-failure recovery action result event - * - * unsigned long pfn - Page Frame Number of the corrupted page - * int type - Page types of the corrupted page - * int result - Result of recovery action - */ - -#ifdef CONFIG_MEMORY_FAILURE -#define MF_ACTION_RESULT \ - EM ( MF_IGNORED, "Ignored" ) \ - EM ( MF_FAILED, "Failed" ) \ - EM ( MF_DELAYED, "Delayed" ) \ - EMe ( MF_RECOVERED, "Recovered" ) - -#define MF_PAGE_TYPE \ - EM ( MF_MSG_KERNEL, "reserved kernel page" ) \ - EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \ - EM ( MF_MSG_HUGE, "huge page" ) \ - EM ( MF_MSG_FREE_HUGE, "free huge page" ) \ - EM ( MF_MSG_GET_HWPOISON, "get hwpoison page" ) \ - EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \ - EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \ - EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \ - EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \ - EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \ - EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \ - EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \ - EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \ - EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \ - EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \ - EM ( MF_MSG_BUDDY, "free buddy page" ) \ - EM ( MF_MSG_DAX, "dax page" ) \ - EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ - EM ( MF_MSG_ALREADY_POISONED, "already poisoned" ) \ - EMe ( MF_MSG_UNKNOWN, "unknown page" ) - -/* - * First define the enums in MM_ACTION_RESULT to be exported to userspace - * via TRACE_DEFINE_ENUM(). - */ -#undef EM -#undef EMe -#define EM(a, b) TRACE_DEFINE_ENUM(a); -#define EMe(a, b) TRACE_DEFINE_ENUM(a); - -MF_ACTION_RESULT -MF_PAGE_TYPE - -/* - * Now redefine the EM() and EMe() macros to map the enums to the strings - * that will be printed in the output. - */ -#undef EM -#undef EMe -#define EM(a, b) { a, b }, -#define EMe(a, b) { a, b } - -TRACE_EVENT(memory_failure_event, - TP_PROTO(unsigned long pfn, - int type, - int result), - - TP_ARGS(pfn, type, result), - - TP_STRUCT__entry( - __field(unsigned long, pfn) - __field(int, type) - __field(int, result) - ), - - TP_fast_assign( - __entry->pfn =3D pfn; - __entry->type =3D type; - __entry->result =3D result; - ), - - TP_printk("pfn %#lx: recovery action for %s: %s", - __entry->pfn, - __print_symbolic(__entry->type, MF_PAGE_TYPE), - __print_symbolic(__entry->result, MF_ACTION_RESULT) - ) -); -#endif /* CONFIG_MEMORY_FAILURE */ #endif /* _TRACE_HW_EVENT_MC_H */ =20 /* This part must be outside protection */ #include diff --git a/include/trace/events/memory-failure.h b/include/trace/events/m= emory-failure.h new file mode 100644 index 000000000000..6c88fb624bd7 --- /dev/null +++ b/include/trace/events/memory-failure.h @@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM ras +#define TRACE_INCLUDE_FILE memory-failure + +#if !defined(_TRACE_MEMORY_FAILURE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_MEMORY_FAILURE_H + +#include +#include + +/* + * memory-failure recovery action result event + * + * unsigned long pfn - Page Frame Number of the corrupted page + * int type - Page types of the corrupted page + * int result - Result of recovery action + */ + +#define MF_ACTION_RESULT \ + EM ( MF_IGNORED, "Ignored" ) \ + EM ( MF_FAILED, "Failed" ) \ + EM ( MF_DELAYED, "Delayed" ) \ + EMe ( MF_RECOVERED, "Recovered" ) + +#define MF_PAGE_TYPE \ + EM ( MF_MSG_KERNEL, "reserved kernel page" ) \ + EM ( MF_MSG_KERNEL_HIGH_ORDER, "high-order kernel page" ) \ + EM ( MF_MSG_HUGE, "huge page" ) \ + EM ( MF_MSG_FREE_HUGE, "free huge page" ) \ + EM ( MF_MSG_GET_HWPOISON, "get hwpoison page" ) \ + EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \ + EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \ + EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \ + EM ( MF_MSG_DIRTY_MLOCKED_LRU, "dirty mlocked LRU page" ) \ + EM ( MF_MSG_CLEAN_MLOCKED_LRU, "clean mlocked LRU page" ) \ + EM ( MF_MSG_DIRTY_UNEVICTABLE_LRU, "dirty unevictable LRU page" ) \ + EM ( MF_MSG_CLEAN_UNEVICTABLE_LRU, "clean unevictable LRU page" ) \ + EM ( MF_MSG_DIRTY_LRU, "dirty LRU page" ) \ + EM ( MF_MSG_CLEAN_LRU, "clean LRU page" ) \ + EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \ + EM ( MF_MSG_BUDDY, "free buddy page" ) \ + EM ( MF_MSG_DAX, "dax page" ) \ + EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ + EM ( MF_MSG_ALREADY_POISONED, "already poisoned" ) \ + EMe ( MF_MSG_UNKNOWN, "unknown page" ) + +/* + * First define the enums in MM_ACTION_RESULT to be exported to userspace + * via TRACE_DEFINE_ENUM(). + */ +#undef EM +#undef EMe +#define EM(a, b) TRACE_DEFINE_ENUM(a); +#define EMe(a, b) TRACE_DEFINE_ENUM(a); + +MF_ACTION_RESULT +MF_PAGE_TYPE + +/* + * Now redefine the EM() and EMe() macros to map the enums to the strings + * that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM(a, b) { a, b }, +#define EMe(a, b) { a, b } + +TRACE_EVENT(memory_failure_event, + TP_PROTO(unsigned long pfn, + int type, + int result), + + TP_ARGS(pfn, type, result), + + TP_STRUCT__entry( + __field(unsigned long, pfn) + __field(int, type) + __field(int, result) + ), + + TP_fast_assign( + __entry->pfn =3D pfn; + __entry->type =3D type; + __entry->result =3D result; + ), + + TP_printk("pfn %#lx: recovery action for %s: %s", + __entry->pfn, + __print_symbolic(__entry->type, MF_PAGE_TYPE), + __print_symbolic(__entry->result, MF_ACTION_RESULT) + ) +); +#endif /* _TRACE_MEMORY_FAILURE_H */ + +/* This part must be outside protection */ +#include diff --git a/mm/Kconfig b/mm/Kconfig index a5a90b169435..c3a8e0ba1ac1 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -738,11 +738,10 @@ config ARCH_SUPPORTS_MEMORY_FAILURE =20 config MEMORY_FAILURE depends on MMU depends on ARCH_SUPPORTS_MEMORY_FAILURE bool "Enable recovery from hardware memory errors" - select RAS help Enables code to recover from some memory failures on systems with MCA recovery. This allows a system to continue running even when some of its memory has uncorrected errors. This requires special hardware support and typically ECC memory. diff --git a/mm/memory-failure.c b/mm/memory-failure.c index f698df156bf8..a1fe6d760983 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -58,13 +58,16 @@ #include #include #include #include #include + +#define CREATE_TRACE_POINTS +#include + #include "swap.h" #include "internal.h" -#include "ras/ras_event.h" =20 #define SOFT_OFFLINE_ENABLED BIT(0) #define SOFT_OFFLINE_SKIP_HUGETLB BIT(1) =20 static int sysctl_memory_failure_early_kill __read_mostly; --=20 2.51.0