From patchwork Fri May 10 06:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13660903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD747C25B4F for ; Fri, 10 May 2024 06:26:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97FF36B0088; Fri, 10 May 2024 02:26:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 956096B0089; Fri, 10 May 2024 02:26:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F49B6B008A; Fri, 10 May 2024 02:26:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 569DB6B0088 for ; Fri, 10 May 2024 02:26:26 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EA821C0486 for ; Fri, 10 May 2024 06:26:25 +0000 (UTC) X-FDA: 82101501930.16.0540BFA Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf07.hostedemail.com (Postfix) with ESMTP id 0B7C34000C for ; Fri, 10 May 2024 06:26:22 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=HDxOCPWi; spf=pass (imf07.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715322383; a=rsa-sha256; cv=none; b=4Q9L6Ymi7q+L8Wnf11xV85+Wyjs/mL1AKLUiokRvDk2mhmJuo2W1F47PZ9O2rdv0cKErpe Cb7ALzXUFSIaRqR/OS9ODdSg2GV/LOTmztLmlfuxHXif7sZ9IExsWojvkNf0yGKeIY/hMH hz9kPwxjoZP9fLyMR5iieWo6cfBiGaY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=HDxOCPWi; spf=pass (imf07.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715322383; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lidB/7GHuLOyvJaPSOUYyS3tm5icKkY717K7DeJTTTk=; b=M1YE7uFBFrVRNWwqkxzw2ftprWdCUdk0ZSGnZP/oCeG5rCOYA97sTxOfSsAKUtiUhuNVZL /0Q/uk4PX7FKm76gJ17KSdjzV/EJXtbQ0askh0LE0k1HOxZEI+SpMFiSwGXDxRjmArJBGc dcnbaQXvybumhk3AMmjbGsEjBcRQvfU= 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> MIME-Version: 1.0 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 X-Stat-Signature: qyatzrip44pqfzddapcsrrwoq8okppwz X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0B7C34000C X-HE-Tag: 1715322382-867937 X-HE-Meta: U2FsdGVkX1+z3SlDI4Pc/Upsed64XOaXma+Wf1MnJfDTXDuelvzvBHWBLKcD6qovl9soRycsbTNPCw04AD6BG65DFSMpCK2dj4+ZyNtp7V/luuAsFNHFzDXdsWSC2oFabQntv1PVSWtjlR68FoXI4pI1eIzfffJK2Dun4XnsTDtdCKAhPi9LldEeSKJuC//TIgZ/FxIzgWDlj+/q8NtXhkhr6juWG17YM+X5ozFkqnkVF1mEozpUiPR+Jzf/T+EU/BoXHqXKPNYk4Tn/QNNrB3ButDqC67u9K/JhAkON7uyi0Rt8mZusJN8A8J4K1w2JB8WTG/HEN2Fx8YzEzMgdQyVJwiuD0tqXhbZc+D7EsBLBrjzIZFo72qG7ilZqAcpsxxVFkNRuB78/ON/jUDiCsx5fGUkD1iX/oRr5ieHOsnW9fpO+Xs69fO08PNLrOeiNg2+qGUza0ar5OQnzi1YoIVOaEePbY/prgp/ueRSo+aqpEnXXFJ664xN2/mhTf3/B5N+r+jlYGVo4iXGbkGInE1W+YX+kE5USjA7XGAuHE50rKvciNvyG6H5dMt0aAVKZmId10JZrb/kuwW5kl/kvjIQJQYfy+7yz2NtV0UbQpcksGQ/bC1LhVZnvztCGZzjha2X4wO/OO0R8psWIYUi2iNP5v/85Ynf8QNd/cT+AiJ1XwUDTMjrDzpjwhURl/R2EwBtplo2CgvWy2fipJaa2v91I9Kpc3ES6x9aMbqBOv5FCJxOuIO3tYWVM18Sh1KOofrcvIIQPBBh4jSW9WCx1VfWGD556LQYGFliX0uzssUNS73v9oFu6jmVAOeubQHEOedEsu/xc7oq1pxkRuIo4WAYfActDhJrkEKXoSOaKlvx1xIkqJGfw63e7yetSwzgbOnNyZNPnKKZF3ldfs4HHgSOZ5YRSdVK2SsuQqOwWLBw1eeWBnStmT5FrImTd1as2huLirBc0EoffUMv0WH+ IgE5kfD2 oyi5MuFG3PrDzSW1Lwow/i90xw0utTYuGKK52cIfuLfzx8Ix6XAbzn0ixiLJ2bcIHthbdSN5G/ezu9xdOLQGEmhibq8Ul1dGH9G/T/SQu4O1S6CfRIAtrPfyxGxMBklzzi0wo93+kRqe3OkAFCBjiizK+6JhoRJMJMHxnElUgxb9cHAZXZ/Ra9tQqcyoh9pQPutn3aSLn4tBDVJftrrsfiLCif/W68uTuFcseYakSXoV1eR7Gt1vITbvcxn23zkbzVfSMKk8aq3qV+6aa/6UwRPZONC4rgV9tCvVH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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; 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 == -EFAULT) { + if (tk->addr == -EFAULT) { pr_err("%#lx: forcibly killing %s:%d because of failure to unmap corrupted 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 *folio, struct page *p, */ forcekill = folio_test_dirty(folio) || (flags & MF_MUST_KILL) || !unmap_success; - kill_procs(&tokill, forcekill, !unmap_success, pfn, flags); + kill_procs(&tokill, forcekill, pfn, flags); 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); } - kill_procs(to_kill, flags & MF_MUST_KILL, false, pfn, flags); + kill_procs(to_kill, flags & MF_MUST_KILL, pfn, flags); } /* From patchwork Fri May 10 06:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13660902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F00AC25B75 for ; Fri, 10 May 2024 06:26:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C64C6B0087; Fri, 10 May 2024 02:26:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 276AD6B0088; Fri, 10 May 2024 02:26:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13E2C6B0089; Fri, 10 May 2024 02:26:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id ECF816B0087 for ; Fri, 10 May 2024 02:26:25 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8F8B4121783 for ; Fri, 10 May 2024 06:26:25 +0000 (UTC) X-FDA: 82101501930.07.CF4A30E Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf12.hostedemail.com (Postfix) with ESMTP id B8E8240005 for ; Fri, 10 May 2024 06:26:23 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Ifn5HH/1"; spf=pass (imf12.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715322383; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uBRlM7MJKT+rrKvwlBySf0eucmcAfjmJ5dD+RRq8pvY=; b=tU6qwCrofbgozbDYldfrBUp8dOIzGvdp2FLzzKEsA4NSTlQ/rkJRxs55gi2SyE4l/426bi XPMQ9ejNqXxNlRIPzIdBxu69zTRgAoSsocUqVVwLmh2xMnz5/jV71/GramvMiGwSuWKG+f r24Q1eOw4UXKLkKhNheYcFGD+Yju/ko= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Ifn5HH/1"; spf=pass (imf12.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715322383; a=rsa-sha256; cv=none; b=2kn0VC//FdkG8SQHJO3vFFbBFZwnw5C7nH4pb9E5mk2hqFlmmFKBrBZpKDr28CdCTCW5RQ Gy8L1kZe+N7BoOIIRo8O6TCGlD2g5Xg4Tu8MZlt45RLPZKXN8UcmRdS/eI1U4uSHgbBQyT bzVvq8rVVl7hcAOPqnhBra79ivZlNfc= 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> MIME-Version: 1.0 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 X-Stat-Signature: s4fs4jterpsouur89z1trxekxsmhtant X-Rspam-User: X-Rspamd-Queue-Id: B8E8240005 X-Rspamd-Server: rspam05 X-HE-Tag: 1715322383-719127 X-HE-Meta: U2FsdGVkX1+96/WqfAb7OxhQRQRqeeDMWzEh76/nNxXiJmmwpKVoY8rfWioh432e+Dsh95U5P89zHXbaC5L612BqisGNsHeqxY0cQ+LUneIjOXMzcIdE4K0E2PiA9QHj1ixOKsP9FcztbapAisKmMu2y8gsqur5z2vWO8J6HC07BGwWCDf+hrWn9c+qrunhcyytFN6/CEaKYkm6D7vBaZyJtZO/jVKXhWhQ7OsyacwoCBpG4eAoe6x3UAnCSc6N8k+SgFrcmg4Bp/OK7+dmTVxa/5TbexEWmp4Ky/AmFCW4khhQZgpyNXXhlU6kw0W+cI0VsJydKkpCBZfBi4efMwWIn63NygAGYPwoYglH62eTwzv5fMaWMwd6V1MA8MN6KtnRZwVprDxQwe0/be0kdzyHTFd3kHSLpYAa15mCk47PmenYczFqSzchAgDgtpmUJfwnqW78LPl8hqJIsBpudwqlEtGH9p50v7ndaZSIfePPJ7TrsGTCa3gi9rPDDIHtBdZh4J9jRCeDFjO8abHIcuFfYXILX0ERl4w1a8FolDGZOBsgDw8tttJES9vZ3Up6MvDJ3wBgmOETzcZi2usBeX/NUFG6xky9wWxEtznRzM4PkQJR25+VnlT1KWnSvOsH/9I03hQ4NcT8e8IfDW1IKokeNq4HvoQMzu6w4YMmslV/WCaB1ag3OsUrCZl17CSxppKxA5juvUp1p9K3AikxDk0B1UUFxUWiDTwQ9eQKUN99C5CuXu6CJyENnLMhFdHTqjMdPdgiOqvwMJ7Q1itEaG1pGSDVSFWSX8bTgoxz9HF1PfnCf2a3ZbbqyMzYFTM8XcMX+YsNWAgoxB8mwInnLD4DLTeu7LScfyiC7HWwjyZI6gFItzWfr3CnZJ68ZMwlajaCQHvTCdqsOs6i0tw9hzkoLrJJYi4oTmool/NsPVg9X8dft5CGvklrUFy3GoWmS66a1QS30z1GQALl5L3Y eKjgaXRG 96So8ms2W74Ssipq4UEY4lCyS2PcjLbD6QaTTZRcql//QqJrh8HGGtlgqg4qbeyy7h951H5jBFeDGbY925yz1gIbRq/PqCUkoVVrjX65BMIZI33ZXxpDItQRf0Uai1lVkZlr3HHS3UYoH1/83aC9cT6QPuQ4zzqb0fcAyihhKzh7j4yOFX0LfAukKzqV5u1LW4ZcCjiqSlhkvPmwGYJIm5AzdAX3Hmda1yZXB4Bu3UfsZUYn5ytz5vvqGr4TmdzfdUAeT2Q6rTadpDEQqljW1vfTSxpYBtQqfS63wGYTUjb8j+9awUV8UF29p+a2rEk7/OFSYdTln8oH2yrY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 address %#lx\n", pfn, start); - ret = memory_failure(pfn, MF_COUNT_INCREASED | MF_SW_SIMULATED); + ret = memory_failure(pfn, MF_ACTION_REQUIRED | MF_COUNT_INCREASED | MF_SW_SIMULATED); if (ret == -EOPNOTSUPP) ret = 0; } From patchwork Fri May 10 06:26:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13660904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C48BC25B10 for ; Fri, 10 May 2024 06:26:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05AA76B008A; Fri, 10 May 2024 02:26:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EAC616B008C; Fri, 10 May 2024 02:26:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D25626B0092; Fri, 10 May 2024 02:26:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B2FA96B008A for ; Fri, 10 May 2024 02:26:29 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 65B7E1211D9 for ; Fri, 10 May 2024 06:26:29 +0000 (UTC) X-FDA: 82101502098.24.757DE59 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 908551C0013 for ; Fri, 10 May 2024 06:26:27 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=H0PXqMVr; spf=pass (imf20.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715322387; a=rsa-sha256; cv=none; b=OIN2Q0gNndWBQ0I15ZFp2njJQxaX061wVR+FeMXnemL7esghREO/N8BVXltYom6rF6gANl /gO7u9Q0RHzg5l9tW8+cBk3hM89C+AMxvNT86MIJsZpGkS7mtJtGtQ4GqLpZO/BY8LcXp1 D3w9bgKb32GxRyJBYNU/nHAqGaRa6hs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=H0PXqMVr; spf=pass (imf20.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715322387; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=viAyLHVrzHmyiEoKjeAdCo+t9ZTJA9p8OiNJ7HBHR+g=; b=O8zPG7PNGaSUVp8k2wDka8t85NgWMmUUqwvhM3AVVcKhO2QXpyYnWfpqcE3huIdmutdzgt c+U4SHzx2szD8+jMBRzba/zj7WP80ribJb9MefTmHMWQVdiSbUxYFmwgioJtS2fJUgqora YkXmQbsRH6sfC3AuaVZDR7v0PFqsFUc= 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> MIME-Version: 1.0 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 X-Stat-Signature: ruoto1b4prd9y7szuc1mnkwsqcnw6bs8 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 908551C0013 X-HE-Tag: 1715322387-187273 X-HE-Meta: U2FsdGVkX1/9v1fmpLOUgjY5KgHG4Ikm2+VVjWFiJu3CyIV847u0AHOKVkjh27Xrol2rRiQjPw7mcTI5J00a/Vz8OFzBN5uiK2ap8lSBGTs5IpDDbCzn4EYNnBKcKCSV5YCmmBW+FNPF/owgOaYbD2KkENIqcgQw0kwGn19rTUjfYNHfIdoXxe9wgiCtpCRKEF29haMPzIuZlEukRLbmPN4a7ld3bdNWPMMsy9wrQFaeu+v7izEJkSx3VGxJr9SHpgr3rVRnwZqxKAKjexT83z20NweXPJBEKj4cEXT9lk0wJyPuyReBCCtQK703QNfA5vzy/GkMjIr58mT52cYP9lbtTqEBFxqk2kcjEZiPzlRmZdlusrDqLBUBQhDZ8lvGSMwQko2sbQUGPIp1ONV0/arYq0AZODpMD7oBo5L5T1rs1TwxCKTVo7tSDxzQ1T8nCVPJsmj1JvTXkLjM+2mBTGFBZj4O8pJiAXsv1Ez5RoXLW4CAE8zI3TqDsz6svPrfyf5cbzfOOFvTg8Zs07GsNBlTUaEdTgxrG6cSorY7j2N68OHVW15x+WfzMo1F/F/Q+zE72Udrnbg4/1OXhxZh4SV8YV6QFL06GblI3GKa/DZl0DnKwCLfWVnmFjrlktDmggyZTNeVNAEkmaCT/atgcFEnlLVfLQF0KusozHNi10WhN5mOJhRyqT1WE6QmE3MrMfueMGnTXOM0Q5Bojh5Q4z3S9n81F4lDAmSx9a3+irdv6bMuTNC8ckQ1AhJDOct+BBZaqX5t7aPvdvGPV42Xx7Hu23U1lyG/Qn+8LSJx8rW3C5p5IGC1BlYNSUm8KMF8TvBoDqL+lSIOtJ1/QNGwsuq6KetmRfrIoaA2WBFcDm9WTpApim0GLLxr1MATjvNbcYNuaFPhVMKXm0CIa3yF5bcg8WhXFny8fsKqptARSEEy1Yl3b2eh4LwsgmJrIgsifkvgVHqjzdemSp2gt3L IcmuvCZN DdQC0f4hk39ZdrDt87zw1rokb+OYbsbecJbZlTxBDl60wqiAB5cxj05b5DGghY8GkV28NwlJg6QQgNpQKg/SAiZQTNSFhnauZO1714iJMxfpbmnp64J3wQR9mM7qk4Tnng+EHsHckv3atq1Z2a1DWniVkQlz/ypI4Mg6Igi6wek+CMYWar/Z8gBnylQZ9jh5tmkymxdfp1EFKR7hBgg4Qx+uUlrehyITVfobNI6MAsahCYRnBZL0m/LXMz5jUexJLChEQ/XpQaEjZ2nEcOePdthy45OVTKikQKUFglanxxZNgzIqacyjeDLggax+cj3ahWPo6n32mYG3RQRQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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, }; 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" ) /* 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; } +/* + * 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 sort + * 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 isolated, + * 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 process. + * MF_RECOVERED - The poisoned page has been completely isolated, via unmap, + * taking the page out of the buddy system, or hole punching out of the + * mapping. + */ static const char *action_name[] = { [MF_IGNORED] = "Ignored", [MF_FAILED] = "Failed", @@ -893,6 +907,7 @@ static const char * const action_page_types[] = { [MF_MSG_DIFFERENT_COMPOUND] = "different compound page after locking", [MF_MSG_HUGE] = "huge page", [MF_MSG_FREE_HUGE] = "free huge page", + [MF_MSG_GET_HWPOISON] = "get hwpoison page", [MF_MSG_UNMAP_FAILED] = "unmapping failed page", [MF_MSG_DIRTY_SWAPCACHE] = "dirty swapcache page", [MF_MSG_CLEAN_SWAPCACHE] = "clean swapcache page", @@ -906,6 +921,7 @@ static const char * const action_page_types[] = { [MF_MSG_BUDDY] = "free buddy page", [MF_MSG_DAX] = "dax page", [MF_MSG_UNSPLIT_THP] = "unsplit thp", + [MF_MSG_ALREADY_POISONED] = "already poisoned", [MF_MSG_UNKNOWN] = "unknown page", }; @@ -1018,7 +1034,7 @@ static int me_unknown(struct page_state *ps, struct page *p) { pr_err("%#lx: Unknown page state\n", page_to_pfn(p)); unlock_page(p); - return MF_FAILED; + return MF_IGNORED; } /* @@ -2055,6 +2071,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb if (flags & MF_ACTION_REQUIRED) { folio = page_folio(p); res = kill_accessing_process(current, folio_pfn(folio), flags); + return action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED); } return res; } else if (res == -EBUSY) { @@ -2062,7 +2079,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb flags |= MF_NO_RETRY; goto retry; } - return action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); + return action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED); } folio = page_folio(p); @@ -2097,7 +2114,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb 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); } return identify_page_state(pfn, p, page_flags); @@ -2231,6 +2248,7 @@ int memory_failure(unsigned long pfn, int flags) res = 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; } @@ -2267,7 +2285,7 @@ int memory_failure(unsigned long pfn, int flags) } goto unlock_mutex; } else if (res < 0) { - res = action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); + res = 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 = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); + res = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_FAILED); goto unlock_page; } From patchwork Fri May 10 06:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13660905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82F74C25B10 for ; Fri, 10 May 2024 06:26:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78D576B008C; Fri, 10 May 2024 02:26:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 733E06B0092; Fri, 10 May 2024 02:26:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 585596B0093; Fri, 10 May 2024 02:26:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 386976B0092 for ; Fri, 10 May 2024 02:26:30 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DB22FA0532 for ; Fri, 10 May 2024 06:26:29 +0000 (UTC) X-FDA: 82101502098.23.FA1FDAD Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 1410E14000B for ; Fri, 10 May 2024 06:26:27 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="lRuQN/xM"; spf=pass (imf26.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715322388; a=rsa-sha256; cv=none; b=3v7VQ7GQQCFGJEf7BlGV2OalJ9pEj7XLtKUFgaUXUa8eH6hpBeaADiQKezusOc6PanpHZI zAoBWqzX4ydfTinaQ8Rjs8PZVYklDjc45g88xlZkCRldRXgaFf+/SJHW/pujj3Fp5/L6c8 6qES23M28nkYJp8NIMXcHwYMTR3KeyM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="lRuQN/xM"; spf=pass (imf26.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715322388; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qec/kt8yhdFKEAaIHR/lBrJDjyfV3DVrQvjyrnvIHpI=; b=X0kbn9S5HZciuFfBhUdOVziYFHOmj7XxyTxr8r6WX/skusoDrr7DevxkImPfnHPEBY58w3 12TVWhxssJPV7hWlycqe0ogoXzz3BTYUYR6Q4dxRB+7Wrcms08+yMmEOLvvfuGxseL2+wu WbNEqiIfDtoOj7y8jL6t7P3aTTv5VpM= 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> MIME-Version: 1.0 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 X-Stat-Signature: cp5ntdeejger7pmoao319kuzniwa8k8i X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1410E14000B X-HE-Tag: 1715322387-183930 X-HE-Meta: U2FsdGVkX1+z3DeGja9lp/AqJaz+2eMQ+2QJLvFgT/6nfVM7c81VY1zU/vgGEfaBwNcVzPRgpXC+33EunJf+Nmz2+dSxju1kaAC1bQfwPyD24MA564uWII43ZAws0xiFE4UcO2zMc/GTp7WkjO2GmhbEl7a8wa8trFN3s7Hq354nVnGRvKgPXmDG3pQzNxsTEy70s8x+VanR7TxhBHjOaFynYE5+CC7x1+mV6N2fTT32g7rX2j/1nb4+0PjjxU8UALGGfUjelRiSZxhZ9nFusrN43Y3b445vWLu5HIrLMC4C3eSBDvKxjVCgxNF1RUQ7cbpgW1j7lXWcbYEllVjUpyv3nnAbbmiSMoULu5hL4+E7YzeEdafq0cC97LK7eEpyhAMpZXvuhKMmISPqsKqmX9oTiXfVP0LelOIug6g0yabWVZxFsZ6pO9yySs4nzMVOcRNlAk8JYn8/JCWa7PpBO2N6IBqtjW1OUqzYyGGBCh6DkmYphJeS7yLYWM9AYx2ehsAjMl3X5fDSIWxHQKx8Ei9WS6/SCQ8Ap1jaUu21NKrfujKCgwMmLhG/T3zw0V2EfDUfTYx9iI+17b9ueEDdCFxZ9dK1vCslfZIjd7PdwzuhMSa/Locjse6Yz5XpBHzIi1gV4huG7K/J5n5vyKRFB8+v+m2kqEi7STYX9f31EA1ZDeJnK2r8fj5vMB/3PlBlfVWoaLMxzIxm+jK/IU3vhNxx1F4fbliTo6iR7Pqk6kul+WQYI+TljwCj7wzRyORCpegitanvZ1kJlpN4U5d5YmNGwChMIsx7EohfJYbqDDBQBslzfK1Ru56jxhhyW0Xg1D/7yfk5wb/v0TDR7V7nCu3qGX1AMYQNjo89JOu0kertmAjlskwTRvdZsUxl3OgR/ssi6SSP/7JTE6M6MIhsTFuNB5svETax2GwLJFrebcRacCaPBEXmZnW26nOgIlxeyJM+TEx+cxg/2ZSfBLe zXrTqNuU bgce+sol4c5fnU8FFH0kkO826SpXYUJXNgelgF1PUoHKq1MkKXveh1aE8ZQvB5zNGvqzZuUmo3U/RRf55fxp0iN9/UQbndJgnYlhk/DCbg51NeoqKM1jpO8scJRCWpLICkNg3F7dtVv599HW6qF1xWTbPEAtXchNmUZYMcvNcTtORyabhjNSsIi8EPU6odODGMbMFVgMOUQCvcGe3DTs+SsCOkUL6ceNMNNpVkMWncusRdyrO90JcIdfO+zi4nNhiMk2dHGoN/Zi1K7tXrC/havtdjfg7A/T5sXNhsczdiLCyTejNaNXwhFq9Cltf07cwkTnnSLglK6tgWWA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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; } + if (hwpoison_filter(p)) { + if (flags & MF_COUNT_INCREASED) + put_page(p); + res = -EOPNOTSUPP; + goto unlock_mutex; + } + try_again: res = try_memory_failure_hugetlb(pfn, flags, &hugetlb); if (hugetlb) @@ -2354,14 +2361,6 @@ int memory_failure(unsigned long pfn, int flags) */ page_flags = folio->flags; - if (hwpoison_filter(p)) { - ClearPageHWPoison(p); - folio_unlock(folio); - folio_put(folio); - res = -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 From patchwork Fri May 10 06:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13660906 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AD93C25B10 for ; Fri, 10 May 2024 06:26:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44E466B0093; Fri, 10 May 2024 02:26:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FCAC6B0095; Fri, 10 May 2024 02:26:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22C506B0096; Fri, 10 May 2024 02:26:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EA83A6B0093 for ; Fri, 10 May 2024 02:26:32 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 731C812058E for ; Fri, 10 May 2024 06:26:32 +0000 (UTC) X-FDA: 82101502224.25.87DB990 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 8A948140007 for ; Fri, 10 May 2024 06:26:30 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=g+GG0Ikx; spf=pass (imf26.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715322390; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tFRwwH8vMdoczPoQRYMz5N41Zt2owkILdQOhrik+iU8=; b=NVwwxcBIo9PAIZM72HPELsy0lGHk9QEsUAff6gTzIYNR33hMdaRNG7oOl9HF00C7VeFGrT Nq2K5sLiyqeIVKucr+xMY4YzgpVrD9yjbYqWsZJ1rG9Ied65WkKJD8q0OiRj49UGPJvJ0K 3shXWNBKV/r3/jMq67bTIhaKQW7UzD8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715322390; a=rsa-sha256; cv=none; b=EtRw/MZwMqM9FmsyAJSp68iR1OctnPUP4lehPzTCCeIk3yU6cxz2uIFa02wLfb8uXPojTq zZe2bumYLNeWSW7U38tUwqrthYXvTvxpIZtg6YSM+hWejOCtEMymlGQNytyjTnVL69VriN V3+JWcr9E92Uui5Ynz0i/8taSHsZCNY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=g+GG0Ikx; spf=pass (imf26.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com 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> MIME-Version: 1.0 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 X-Rspam-User: X-Stat-Signature: jisgd6bfnxfx5qffjmm5zhjherksqnyf X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 8A948140007 X-HE-Tag: 1715322390-534075 X-HE-Meta: U2FsdGVkX1/1g8TfyUtm8OJ6KvB9X3cABSChPRzE9SSBfctaJYn6fo1r1MOEufGRimKv4Qwk7GWmeiWTrLs9OdQh7yWGWUMj0S51mHGHBOE5LBOc5nEW3vSc6UXPyBJIR7jQb/c5sxOjVQYuonyDpFsPzuIZJXuvgYooOxaCV5LB+oLl1cAzd/CoL949GziecnRVzNjzhrZPKGtnc2zzCJGXZE2Tpr4/H2wAKU7op8biQqMnQYvgH1/vZ6PviwUjn0ojXxvVWoATnXravRInr7Tl05RLmqZic3PcVnqoURJYyp4ugMTe2sA8Xxds611pLLNfPFyM51rvMZ/WQxB+mrM4Fk0IZhVFoDnSRalc8iqrG//1zy4DB4KugboS6e29hBnEu2q4jWVc/vlEJoBjPn1khboW1c0YGkMqyQ/0sCty5stUoU9P0X+0gdbzIcKr8LAzt5eYn+OQZOqNGqHpWR/5LuHFt73HnDMN1eyg3/pNu+7yy2fZyBO70ziokKsAI9QP5mpbWsOBTeWsGgVxco/e9tPpGcrYHsPFtDYxrMRvn1ubaO1P1A00JX7rKnbD7V6TmX70EqgelyN9gaB3ukbHXf/PQ6l+bquv49HFXOOpyoJCM4y68UoPbotyBlQYsF8W1YOON4FG2pzx67KPfjTXQXEChBEax+5VOjA8WBY1lSnDueOAN/OGpx3tt3drMct8IzUgQPtF94M91/wi3k2SvKGEHYgJiWCpajBB9V8EvVj1rxM/r/OT3axPboPP/ZIYFQJ2CC1ZPEeK8OXWAETcz2g4xUyUAGIx4lYG6dLzUaE3xuNlhYTJQYp5vEbh8eGfgmLvklj+qV5z1jzmRRTmfviWnx1KXHcT5zHLFI7t5YfUErExqk6EWm0YPG31nkrdMgsgP7Q2Wx8oom5oBECavSMoeLP/br02sbeLLcG5AkbPfwOOkfHIh8CwwHc2AqPk99ZkvYkt2ofHzNe KkJV8dAl G6Lj5TayZh1WnZtJ3Ht2//BOvIJ8lIdotN5jewFGgl1oTH+pyEqRzYWwwI5YYjQSD3xREjywfm2Cd2sVjEQUEnBKr4s8vbJ8cB/MVfcy+Ixg9u30ogn0/2aZFcbrYCBFtr84p2w77mr8uqOwgaRkuvvQmwWjeLjJFEmFMvNN01wzFOaxKoi2zj/xO8CwOix3YDHUgv/5RgO27/gvl04T6u2soPn0RYmSEKkOEwmlJ59CJdrknSgkUd4OSS4nGODTrC9k9MqpROuDxW+SIedahjvhtZQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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, struct page *p, return page_action(ps, p, pfn); } -static int try_to_split_thp_page(struct page *page) +static int try_to_split_thp_page(struct page *page, bool release) { int ret; @@ -1705,7 +1705,7 @@ static int try_to_split_thp_page(struct page *page) ret = split_huge_page(page); unlock_page(page); - if (unlikely(ret)) + if (ret && release) put_page(page); return ret; @@ -2177,6 +2177,24 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, return rc; } +/* + * 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 = 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 = kill_procs_now(p, pfn, flags, folio); + put_page(p); + res = 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) }; 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; }