From nobody Sun Dec 14 12:01:13 2025 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 9AF0C15E81C for ; Fri, 10 May 2024 06:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322392; cv=none; b=hjudrtw6HA+UaPajfA4OHBwSUi4VZdvUDgHUOwLYvcrxtry1KQewlYZk5EcbyulruCnLLHhbNqzsY8Yi4J7lwRyDihnMqOFJHnPL1nJLXaibc2tA9C1yhT03JHLPITgifi3gwJ8tdZJADJZ8KhhBIE5TrDkivh1Z0qpPlJocXDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322392; c=relaxed/simple; bh=6F7CRpnGxqd3OYJM6ibrRjnqycdGgS1RVcWPgGIsFnE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=spidLgmhOlxMnwQ0zrJEGm+tgMTdCgPYZuf+5yNQUIJL/d+gqKvAr5GHZujQ8hq3f8GHxTZYd8meNFBrqp9PZ7lSQ+3rV+PZxm4AIdiLxgcddbUIXNrkU8einCOxVjPLSy5s/mJb7hp16R6X8+zVrEKt0Nm8YFHA1Y6zLq1gWTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=HDxOCPWi; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="HDxOCPWi" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44A60k6V028599; Fri, 10 May 2024 06:26:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=lidB/7GHuLOyvJaPSOUYyS3tm5icKkY717K7DeJTTTk=; b=HDxOCPWiFx5b+6+Aqn8kT94s6kd9HF/0Ec97tE1bjkoOyRt5Byl1pgUDij2aImMhHN+1 DYqIowMPMJnAGFbAZp6ZAL2yEf6uaTNDO961feviqzGH1J6IFoOrmCVN4lDsEunTQcV7 3/lfACmxlDsxsJzTJ8ARhK/5ujjEKMmgo35U0n2bv9LZtiM4PCyJKNwmnML9pruZUfQ/ 7DVEd4iR0ch5rJ1kV+c450Lab7aPIKoi+5KKUR3ecpHw+LRxxW1jp+thn5unqYbMY4+F I2iCZ0kR/rGHbPoagtEqJr8k/0yEVqYABR47/SdzhIv1kUEi9QNorEVhNZbkKblynn2U QQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y1dfsr44y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 May 2024 06:26:15 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5vUjH020104; Fri, 10 May 2024 06:26:14 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xysfpghcd-2; Fri, 10 May 2024 06:26:14 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, osalvador@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] mm/memory-failure: try to send SIGBUS even if unmap failed Date: Fri, 10 May 2024 00:25:58 -0600 Message-Id: <20240510062602.901510-2-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240510062602.901510-1-jane.chu@oracle.com> References: <20240510062602.901510-1-jane.chu@oracle.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-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-10_04,2024-05-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405100044 X-Proofpoint-GUID: KM_HUVbH9r9GCli7EIF_tqSVgZdQSVFi X-Proofpoint-ORIG-GUID: KM_HUVbH9r9GCli7EIF_tqSVgZdQSVFi Content-Type: text/plain; charset="utf-8" For years when it comes down to kill a process due to hwpoison, a SIGBUS is delivered only if unmap has been successful. Otherwise, a SIGKILL is delivered. And the reason for that is to prevent the involved process from accessing the hwpoisoned page again. Since then a lot has changed, a hwpoisoned page is marked and upon being re-accessed, the memory-failure handler invokes kill_accessing_process() to kill the process immediately. So let's take out the '!unmap_success' factor and try to deliver SIGBUS if possible. Signed-off-by: Jane Chu Reviewed-by: Oscar Salvador Acked-by: Miaohe Lin --- mm/memory-failure.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 16ada4fb02b7..739311e121af 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -514,22 +514,15 @@ void add_to_kill_ksm(struct task_struct *tsk, struct = page *p, * * Only do anything when FORCEKILL is set, otherwise just free the * list (this is used for clean pages which do not need killing) - * Also when FAIL is set do a force kill because something went - * wrong earlier. */ -static void kill_procs(struct list_head *to_kill, int forcekill, bool fail, +static void kill_procs(struct list_head *to_kill, int forcekill, unsigned long pfn, int flags) { struct to_kill *tk, *next; =20 list_for_each_entry_safe(tk, next, to_kill, nd) { if (forcekill) { - /* - * In case something went wrong with munmapping - * make sure the process doesn't catch the - * signal and then access the memory. Just kill it. - */ - if (fail || tk->addr =3D=3D -EFAULT) { + if (tk->addr =3D=3D -EFAULT) { pr_err("%#lx: forcibly killing %s:%d because of failure to unmap corru= pted page\n", pfn, tk->tsk->comm, tk->tsk->pid); do_send_sig_info(SIGKILL, SEND_SIG_PRIV, @@ -1660,7 +1653,7 @@ static bool hwpoison_user_mappings(struct folio *foli= o, struct page *p, */ forcekill =3D folio_test_dirty(folio) || (flags & MF_MUST_KILL) || !unmap_success; - kill_procs(&tokill, forcekill, !unmap_success, pfn, flags); + kill_procs(&tokill, forcekill, pfn, flags); =20 return unmap_success; } @@ -1724,7 +1717,7 @@ static void unmap_and_kill(struct list_head *to_kill,= unsigned long pfn, unmap_mapping_range(mapping, start, size, 0); } =20 - kill_procs(to_kill, flags & MF_MUST_KILL, false, pfn, flags); + kill_procs(to_kill, flags & MF_MUST_KILL, pfn, flags); } =20 /* --=20 2.39.3 From nobody Sun Dec 14 12:01:13 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 1FD5515E5D2 for ; Fri, 10 May 2024 06:26:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322391; cv=none; b=DapxgnvdD/MYEViOSP4RHLjQnr0G66E43duERTgs6ZzA6JwyLr1lNAUEBEfb6piN14HInDiI11QBVGUUnpejR6vIykW2Rpktxq01OOSMtEZDMWOXjOL9YddmYNB5HYKJ+g1qbZyJFoJMZSGZNS3cKzpm1/tNv1CFtKOdqgHx1a8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322391; c=relaxed/simple; bh=jqEa403Ip4Q6H3qKGudKAM9jGLLfwsy4VGx1KPzYp8o=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AlWO1awEn+UlBZCO9tuKFVmGaYgzmORzOSv+hvZ3wzL2RDO+YvyUF+cpaBNwfKcENlc9QR1Y4plVTQVNPIXJThT3tLBHfdI8yPNW/7wGvY1N1dmHhOYuuH5j/A3ps426dGitfE+7pMFbeZnElUfgS0Bd8abDnvtFoSPhB1q9azY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Ifn5HH/1; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Ifn5HH/1" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5t5Pv016630; Fri, 10 May 2024 06:26:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=uBRlM7MJKT+rrKvwlBySf0eucmcAfjmJ5dD+RRq8pvY=; b=Ifn5HH/16jXv/KuOyh0nU7ZLOCsuKELF+k0X9V9hWXtSrm2ohy/Omb5WgHC2u7/8UTkj /aNgAVKlFaQnD8OwSgRkHmdFUS4nJK80kxrKf6wCNUul/ixRVKtOLdrUe3/IJzZ3BtL0 5qzayJ0RJ5IqrjOofx2TK3QfCGSyDP7h02vAoHydjq+jQ7gx9trzJT8vylYQ5KXFZMqa HC/DFgxYodABvbZYlNn3KCgWZtaOCKWAtHFH6iBc1Mo5IOTFR5hr+WMEWpkdJa/Uubur wFy3XgAIUHOJC6HxTL2g8eZWqUdWZC6uwcMUtObkRcL9SWrZnqwBSFRVXusEUexd2Fi4 FA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y1a0j88g4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 May 2024 06:26:17 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5vUjI020104; Fri, 10 May 2024 06:26:16 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xysfpghcd-3; Fri, 10 May 2024 06:26:16 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, osalvador@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] mm/madvise: Add MF_ACTION_REQUIRED to madvise(MADV_HWPOISON) Date: Fri, 10 May 2024 00:25:59 -0600 Message-Id: <20240510062602.901510-3-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240510062602.901510-1-jane.chu@oracle.com> References: <20240510062602.901510-1-jane.chu@oracle.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-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-10_04,2024-05-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405100044 X-Proofpoint-ORIG-GUID: RkkUKBZtDn54AUwSlFAoI0xSgUT30iF6 X-Proofpoint-GUID: RkkUKBZtDn54AUwSlFAoI0xSgUT30iF6 Content-Type: text/plain; charset="utf-8" The soft hwpoison injector via madvise(MADV_HWPOISON) operates in a synchrous way in a sense, the injector is also a process under test, and should it have the poisoned page mapped in its address space, it should legitimately get killed as much as in a real UE situation. Signed-off-by: Jane Chu Reviewed-by: Oscar Salvador --- mm/madvise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/madvise.c b/mm/madvise.c index c8ba3f3eb54d..d8a01d7b2860 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1147,7 +1147,7 @@ static int madvise_inject_error(int behavior, } else { pr_info("Injecting memory failure for pfn %#lx at process virtual addre= ss %#lx\n", pfn, start); - ret =3D memory_failure(pfn, MF_COUNT_INCREASED | MF_SW_SIMULATED); + ret =3D memory_failure(pfn, MF_ACTION_REQUIRED | MF_COUNT_INCREASED | M= F_SW_SIMULATED); if (ret =3D=3D -EOPNOTSUPP) ret =3D 0; } --=20 2.39.3 From nobody Sun Dec 14 12:01:13 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 984C81607A0 for ; Fri, 10 May 2024 06:26:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322395; cv=none; b=VbGVizOIqH9/6eCHFde+uK74opLzZCTZvo+uzM36nIwHKSokfvPAoDNP2FzhJzDUMbfKoJWlHHpZnzxEB0+1/fTNagYv4kIIPek9IaErgbLuJ2Eli6V2qlo4GiU3+GwC9VyT78P82Itol9qc63/eeEiiiLnSoqfkvjWtu7pQLLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322395; c=relaxed/simple; bh=CAuOkel/LqRo1NMDUWv5wRqXBLBpH6DPowOjYYYlZHI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r0JUHYFZLhKe/NQtcIRLPckZXhuLiBN6dltpNQyAY9cutSdwpoabb0RurSlOirxIG76OTgiIgL8JuwTyGxXuBfOSPFrwhWCwAlJnXyz0T+5qNyWLboCO9MrkNp1bgAMKwCDb+1ZvP0EyfE1h796XuZMZfXsZDE/2SU1q5YXmSH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=H0PXqMVr; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="H0PXqMVr" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5t5Pw016630; Fri, 10 May 2024 06:26:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=viAyLHVrzHmyiEoKjeAdCo+t9ZTJA9p8OiNJ7HBHR+g=; b=H0PXqMVrGbNDFU8FnAuHXRnL6b4Ig4izVN/GdNGiOReqYUvngSa5ejZeqvvQ5K4u5Em4 Qh60056Xfp1+LV8p9JxcKYM0dUN1P09xHNDauOccr/WuDICMUgxLQ935GZt3rBGqjis+ hTeJe1dSch39ZV14iqOIRHGEpM6oPAZkluMStLyEp4PQ9V0BmrfHJb2J22dmWGBlGfgM Lf2n1YeUvUqv0eViouFw+l2pwhQLLJr1M/ss+RS5IH5a6OkyhbFFVEBL853d7LTFMwn5 vUWAYpcu91RtaFuToRxQtEQXMJYpHDHI3g8J3NQMvybc++cjOK8uV4Lozn1fsv2RZ6LQ Zg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y1a0j88g5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 May 2024 06:26:19 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5vUjK020104; Fri, 10 May 2024 06:26:18 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xysfpghcd-4; Fri, 10 May 2024 06:26:18 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, osalvador@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] mm/memory-failure: improve memory failure action_result messages Date: Fri, 10 May 2024 00:26:00 -0600 Message-Id: <20240510062602.901510-4-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240510062602.901510-1-jane.chu@oracle.com> References: <20240510062602.901510-1-jane.chu@oracle.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-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-10_04,2024-05-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=690 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405100044 X-Proofpoint-ORIG-GUID: 9Wi8zJK1XSS8g6hfb26O6JAQMP9nYrJq X-Proofpoint-GUID: 9Wi8zJK1XSS8g6hfb26O6JAQMP9nYrJq Content-Type: text/plain; charset="utf-8" Added two explicit MF_MSG messages describing failure in get_hwpoison_page. Attemped to document the definition of various action names, and made a few adjustment to the action_result() calls. Signed-off-by: Jane Chu --- include/linux/mm.h | 2 ++ include/ras/ras_event.h | 2 ++ mm/memory-failure.c | 28 +++++++++++++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9849dfda44d4..b4598c6a393a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4111,6 +4111,7 @@ enum mf_action_page_type { MF_MSG_DIFFERENT_COMPOUND, MF_MSG_HUGE, MF_MSG_FREE_HUGE, + MF_MSG_GET_HWPOISON, MF_MSG_UNMAP_FAILED, MF_MSG_DIRTY_SWAPCACHE, MF_MSG_CLEAN_SWAPCACHE, @@ -4124,6 +4125,7 @@ enum mf_action_page_type { MF_MSG_BUDDY, MF_MSG_DAX, MF_MSG_UNSPLIT_THP, + MF_MSG_ALREADY_POISONED, MF_MSG_UNKNOWN, }; =20 diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h index c011ea236e9b..b3f6832a94fe 100644 --- a/include/ras/ras_event.h +++ b/include/ras/ras_event.h @@ -360,6 +360,7 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" )= \ 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" ) \ @@ -373,6 +374,7 @@ TRACE_EVENT(aer_event, 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" ) =20 /* diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 739311e121af..62133c10fb51 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -879,6 +879,20 @@ static int kill_accessing_process(struct task_struct *= p, unsigned long pfn, return ret > 0 ? -EHWPOISON : -EFAULT; } =20 +/* + * MF_IGNORED - Either the m-f() handler did nothing to recover, or it did + * something, then caught in a race condition which renders the effort s= ort + * of moot. This is perhaps the most sever. + * MF_FAILED - The m-f() handler might have killed the process, but it can= 't + * do much to the poisoned page other than marking it poisoned, due to + * conditions such as extra pin, unmap failure, etc. + * MF_DELAYED - The poisoned page has been unmapped but not completely iso= lated, + * such as page might remain in LRU. But an attempt by userspace process + * to access the page again will hit page fault which will kill the proc= ess. + * MF_RECOVERED - The poisoned page has been completely isolated, via unma= p, + * taking the page out of the buddy system, or hole punching out of the + * mapping. + */ static const char *action_name[] =3D { [MF_IGNORED] =3D "Ignored", [MF_FAILED] =3D "Failed", @@ -893,6 +907,7 @@ static const char * const action_page_types[] =3D { [MF_MSG_DIFFERENT_COMPOUND] =3D "different compound page after locking", [MF_MSG_HUGE] =3D "huge page", [MF_MSG_FREE_HUGE] =3D "free huge page", + [MF_MSG_GET_HWPOISON] =3D "get hwpoison page", [MF_MSG_UNMAP_FAILED] =3D "unmapping failed page", [MF_MSG_DIRTY_SWAPCACHE] =3D "dirty swapcache page", [MF_MSG_CLEAN_SWAPCACHE] =3D "clean swapcache page", @@ -906,6 +921,7 @@ static const char * const action_page_types[] =3D { [MF_MSG_BUDDY] =3D "free buddy page", [MF_MSG_DAX] =3D "dax page", [MF_MSG_UNSPLIT_THP] =3D "unsplit thp", + [MF_MSG_ALREADY_POISONED] =3D "already poisoned", [MF_MSG_UNKNOWN] =3D "unknown page", }; =20 @@ -1018,7 +1034,7 @@ static int me_unknown(struct page_state *ps, struct p= age *p) { pr_err("%#lx: Unknown page state\n", page_to_pfn(p)); unlock_page(p); - return MF_FAILED; + return MF_IGNORED; } =20 /* @@ -2055,6 +2071,7 @@ static int try_memory_failure_hugetlb(unsigned long p= fn, int flags, int *hugetlb if (flags & MF_ACTION_REQUIRED) { folio =3D page_folio(p); res =3D kill_accessing_process(current, folio_pfn(folio), flags); + return action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED); } return res; } else if (res =3D=3D -EBUSY) { @@ -2062,7 +2079,7 @@ static int try_memory_failure_hugetlb(unsigned long p= fn, int flags, int *hugetlb flags |=3D MF_NO_RETRY; goto retry; } - return action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); + return action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED); } =20 folio =3D page_folio(p); @@ -2097,7 +2114,7 @@ static int try_memory_failure_hugetlb(unsigned long p= fn, int flags, int *hugetlb =20 if (!hwpoison_user_mappings(folio, p, pfn, flags)) { folio_unlock(folio); - return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); + return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_FAILED); } =20 return identify_page_state(pfn, p, page_flags); @@ -2231,6 +2248,7 @@ int memory_failure(unsigned long pfn, int flags) res =3D kill_accessing_process(current, pfn, flags); if (flags & MF_COUNT_INCREASED) put_page(p); + action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED); goto unlock_mutex; } =20 @@ -2267,7 +2285,7 @@ int memory_failure(unsigned long pfn, int flags) } goto unlock_mutex; } else if (res < 0) { - res =3D action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); + res =3D action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED); goto unlock_mutex; } } @@ -2363,7 +2381,7 @@ int memory_failure(unsigned long pfn, int flags) * Abort on fail: __filemap_remove_folio() assumes unmapped page. */ if (!hwpoison_user_mappings(folio, p, pfn, flags)) { - res =3D action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); + res =3D action_result(pfn, MF_MSG_UNMAP_FAILED, MF_FAILED); goto unlock_page; } =20 --=20 2.39.3 From nobody Sun Dec 14 12:01:13 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 AC6061607AC for ; Fri, 10 May 2024 06:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322394; cv=none; b=UYgsdo4nqSlm4ZsMZ4F9Hy+Q+SAcrmHqWryZf6aXkESGcHtT4U6ivy7tkCZO++VIw5QrsDOLDkkgz9eH3fkM8AE7rXz6Ktv56nafHJrFqp2h11rDlGITICqi+vi6u4d7S5cPv3Woly+ZMG08untbHgpi9imiPNQzoMgP/trzK4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322394; c=relaxed/simple; bh=y3xH+3hjLxbEC05EGc7rW1iUH9Sb7wWK1YJNYK9P/vk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rcJakhUtBB1I07lEngKNzpLHBaePHfMe3v9jLy6EnYPTEo+EwSTbAkWFpGTLHb/p4/3YsOGX8+QpdSNUDMQfGQp+Aole9jNZAB911LxVxu53avce4K4vcIUydxqqGatk1S0hb4y3BIHTGrm+EUGG4LVUnGLwX6FZVqzWXrlK4Ro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=lRuQN/xM; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lRuQN/xM" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5Uk36011962; Fri, 10 May 2024 06:26:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=qec/kt8yhdFKEAaIHR/lBrJDjyfV3DVrQvjyrnvIHpI=; b=lRuQN/xMOVSxjVnhzDm+Pq4HIhcUC8yYEOf9Z2eUsA+MLCdtw0r5l4Pombb7wH6UCjOI DAYYVBc4bniRlWOm21BPU76OjthY5i0QfqOWVvzwathI0D/W6CQ7uuHBwMV2j0ymnBVI ThHaUIo3ooFviW92KbMemp3N1RH9kHybAN3w88XwqwFnJ86LuxAT3grjvFuDiqYUlpxM 4E3MGarfapaworMInHdK4rD/QALsuDuZONl/Vs8EvtzVfYnk/ELOp7bWs11EOlM63156 9Sq7AM5bSR1uXmHuJE6cagWmhGhhowmzdH7z2hzzmkJkhWEpKuNwR5yV2arNMnb2X0mT Qw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y17x7recv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 May 2024 06:26:21 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5vUjL020104; Fri, 10 May 2024 06:26:21 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xysfpghcd-5; Fri, 10 May 2024 06:26:20 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, osalvador@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] mm/memory-failure: move hwpoison_filter() higher up Date: Fri, 10 May 2024 00:26:01 -0600 Message-Id: <20240510062602.901510-5-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240510062602.901510-1-jane.chu@oracle.com> References: <20240510062602.901510-1-jane.chu@oracle.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-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-10_04,2024-05-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405100044 X-Proofpoint-GUID: o2ec6oR7IMYucBVlxbovuoOEzvuShcLi X-Proofpoint-ORIG-GUID: o2ec6oR7IMYucBVlxbovuoOEzvuShcLi Content-Type: text/plain; charset="utf-8" Move hwpoison_filter() higher up as there is no need to spend a lot cycles only to find out later that the page is supposed to be skipped for hwpoison handling. Signed-off-by: Jane Chu --- mm/memory-failure.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 62133c10fb51..2fa884d8b5a3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2236,6 +2236,13 @@ int memory_failure(unsigned long pfn, int flags) goto unlock_mutex; } =20 + if (hwpoison_filter(p)) { + if (flags & MF_COUNT_INCREASED) + put_page(p); + res =3D -EOPNOTSUPP; + goto unlock_mutex; + } + try_again: res =3D try_memory_failure_hugetlb(pfn, flags, &hugetlb); if (hugetlb) @@ -2354,14 +2361,6 @@ int memory_failure(unsigned long pfn, int flags) */ page_flags =3D folio->flags; =20 - if (hwpoison_filter(p)) { - ClearPageHWPoison(p); - folio_unlock(folio); - folio_put(folio); - res =3D -EOPNOTSUPP; - goto unlock_mutex; - } - /* * __munlock_folio() may clear a writeback folio's LRU flag without * the folio lock. We need to wait for writeback completion for this --=20 2.39.3 From nobody Sun Dec 14 12:01:13 2025 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 1F23C1649DD for ; Fri, 10 May 2024 06:26:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322397; cv=none; b=L59aXli8X4BWAMa81722XuR6nlESUNkmKoLwFt2XDJj5LoKzGEMoHz6/Am0Gp6DTNRw0JrsJXLnhnUryUkyS6YGx7/UCw7Q5wJaqUfRC6XsdzFYA7nPhRUc+LIxtuvLbYgfjbLO1fCcDS/Y1zrnVVZM3F3UK2M7Z0GQo1dNfoo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715322397; c=relaxed/simple; bh=wCzAosb9yCwghwfxx/CGqsZgf9AZk6yq9vaFDYv2tRY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qDWn7sPFwpgBAt7YkrB7vYGrRXXwbSdi5fFki+HQjX6JtsN+E+IjoWrtbhVv9/2ZJ0VgWEqORfimdbpYBE0t+TjJ5WH4qhfrwrnIKmZ18ZsbSxVZ+9cFqmE7BSi33EB+apWqDmHz5aVSxtUGkK2ypJNutmOA02/r7w3G3zbUxpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=g+GG0Ikx; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="g+GG0Ikx" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44A6MlnA021258; Fri, 10 May 2024 06:26:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=tFRwwH8vMdoczPoQRYMz5N41Zt2owkILdQOhrik+iU8=; b=g+GG0IkxeBwWGSyuHfsSdSx+LFncqCu5jZOcbVaDHmkL9ozkB8xCjsgtm+GrDkXmTUj5 MXoy9msQbB+PCutyZxq+HAKT2pUU8SvxyEZ2h8S8G7Zgpmx8DuozzcRn3wU88odGNPMW 64+S4Ksxo0HtObmuilQyCk1Bd9sTw/qfkE5mtg1aJGpyp2oOSkUjnFa5aXIRYK5lfYTI vAky1uOu1pEQjAxLxo/Of1rF5SrdrkCi2qS+I3DhHhWoODouj/cHvEGyv5JIMn/0SxtB 9EzEdDUEkS747E2AHQEmFIXqS5giacQ4OQ2QB0t2qfddTjokh/pxF1dkkb3+namnHna6 sA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y1e8sr05v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 May 2024 06:26:26 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5vUjP020104; Fri, 10 May 2024 06:26:24 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xysfpghcd-6; Fri, 10 May 2024 06:26:24 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, osalvador@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] mm/memory-failure: send SIGBUS in the event of thp split fail Date: Fri, 10 May 2024 00:26:02 -0600 Message-Id: <20240510062602.901510-6-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240510062602.901510-1-jane.chu@oracle.com> References: <20240510062602.901510-1-jane.chu@oracle.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-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-10_04,2024-05-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405100044 X-Proofpoint-ORIG-GUID: Bbu3oqFBFYt86uLCdWySG1px70G6up9M X-Proofpoint-GUID: Bbu3oqFBFYt86uLCdWySG1px70G6up9M Content-Type: text/plain; charset="utf-8" When handle hwpoison in a RDMA longterm pinned thp page, try_to_split_thp_page() will fail. And at this point, there is little else the kernel could do except sending a SIGBUS to the user process, thus give it a chance to recover. Signed-off-by: Jane Chu --- mm/memory-failure.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 2fa884d8b5a3..15bb1c0c42e8 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1697,7 +1697,7 @@ static int identify_page_state(unsigned long pfn, str= uct page *p, return page_action(ps, p, pfn); } =20 -static int try_to_split_thp_page(struct page *page) +static int try_to_split_thp_page(struct page *page, bool release) { int ret; =20 @@ -1705,7 +1705,7 @@ static int try_to_split_thp_page(struct page *page) ret =3D split_huge_page(page); unlock_page(page); =20 - if (unlikely(ret)) + if (ret && release) put_page(page); =20 return ret; @@ -2177,6 +2177,24 @@ static int memory_failure_dev_pagemap(unsigned long = pfn, int flags, return rc; } =20 +/* + * The calling condition is as such: thp split failed, page might have + * been RDMA pinned, not much can be done for recovery. + * But a SIGBUS should be delivered with vaddr provided so that the user + * application has a chance to recover. Also, application processes' + * election for MCE early killed will be honored. + */ +static int kill_procs_now(struct page *p, unsigned long pfn, int flags, + struct folio *folio) +{ + LIST_HEAD(tokill); + + collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED); + kill_procs(&tokill, true, pfn, flags); + + return -EHWPOISON; +} + /** * memory_failure - Handle memory failure of a page. * @pfn: Page Number of the corrupted page @@ -2313,8 +2331,11 @@ int memory_failure(unsigned long pfn, int flags) * page is a valid handlable page. */ folio_set_has_hwpoisoned(folio); - if (try_to_split_thp_page(p) < 0) { - res =3D action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); + if (try_to_split_thp_page(p, false) < 0) { + pr_err("%#lx: thp split failed\n", pfn); + res =3D kill_procs_now(p, pfn, flags, folio); + put_page(p); + res =3D action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED); goto unlock_mutex; } VM_BUG_ON_PAGE(!page_count(p), p); @@ -2688,7 +2709,7 @@ static int soft_offline_in_use_page(struct page *page) }; =20 if (!huge && folio_test_large(folio)) { - if (try_to_split_thp_page(page)) { + if (try_to_split_thp_page(page, true)) { pr_info("soft offline: %#lx: thp split failed\n", pfn); return -EBUSY; } --=20 2.39.3