From patchwork Wed May 1 23:24:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13651180 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 CAB64C4345F for ; Wed, 1 May 2024 23:27:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ABBA6B009C; Wed, 1 May 2024 19:27:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55BBE6B009D; Wed, 1 May 2024 19:27:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FC806B009E; Wed, 1 May 2024 19:27:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1DCAC6B009C for ; Wed, 1 May 2024 19:27:46 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D00B7160570 for ; Wed, 1 May 2024 23:27:40 +0000 (UTC) X-FDA: 82071416280.10.0AC60D9 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf26.hostedemail.com (Postfix) with ESMTP id CC792140006 for ; Wed, 1 May 2024 23:27:38 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=O30NH25c; dmarc=pass (policy=quarantine) header.from=oracle.com; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714606059; 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=wY3UVMyMfxgmoJifRLcjAmBE75B0nsP3Ptes0P01A1M=; b=uwKdKS9R18/ZG1Mcat/jHX2TXC9m18m1660BwfcnTiCC0oxPa199Zcb05mcGNoNWpAv+pv 2IdtW9Wk/bpp8LD5oscJkUc+XiILOPlAgNG9y3o6XMmeVAlNJPGrHfJdU+gcgit21wOsFH 1wYyAaRR89g7EOKFpnu8js8uTInHbMA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714606059; a=rsa-sha256; cv=none; b=TkR0ythPY3vwJwdUw4Oamecswpjk+Ov0s54LW7/xxmhR6o17y/i9UM4JwoY+T5lk9nZXjS bQgdHgyarmw0ZfeZioMkCtwebi5F/rhLs+ANKP6aN65tqOUzKLcRjp3OaTPtZ8jbswO8Ct 5p1C3u6M3oJEbxOTRzXUTqal2L5WFHU= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=O30NH25c; dmarc=pass (policy=quarantine) header.from=oracle.com; 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 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 441MJoFZ018832; Wed, 1 May 2024 23:27:34 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=wY3UVMyMfxgmoJifRLcjAmBE75B0nsP3Ptes0P01A1M=; b=O30NH25cEiHmaQi1UYG/GI/J9vkfjdSG/p9zThfthrKfqpArV/XvmpJlQSzOC6Zu+XBn xH1usMXR+tIYLDXSYDtvLXksqQFvQRzk+0jvH3c0QsoIubAVPBo8sBnJrbrL6dgrzuX/ H1d/VZImw3KYAraRssEdn515z8ouf6MLQ48AZtykRMb6S0WsUSvlklyQSlkq59del6QS CQxWa4qGwyY0v+m3KSb5qn8pQF8yq6eS21J1pb1m9qeP0VWax8QkxFn9ydAmNGX0QIzP d2gVRZWbmU+0R+uAQ1FNHT6uyCr15X5Nh7b6CaTF7AMUapMQGFeCROsBl3upOYn5/hKh 2Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrqy31xa6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 May 2024 23:27:32 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 441MBS4A033172; Wed, 1 May 2024 23:25:06 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xrqt9vbuq-2; Wed, 01 May 2024 23:25:06 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] mm/memory-failure: try to send SIGBUS even if unmap failed Date: Wed, 1 May 2024 17:24:56 -0600 Message-Id: <20240501232458.3919593-2-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240501232458.3919593-1-jane.chu@oracle.com> References: <20240501232458.3919593-1-jane.chu@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-01_16,2024-04-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405010165 X-Proofpoint-ORIG-GUID: SNkRBuHMGLGZMo7XtV4v_r1aq305_slf X-Proofpoint-GUID: SNkRBuHMGLGZMo7XtV4v_r1aq305_slf X-Rspamd-Queue-Id: CC792140006 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 5wuy5wtg3bohydu84fgz1kn3xx66nikd X-HE-Tag: 1714606058-332980 X-HE-Meta: U2FsdGVkX18RIfiUqm8da0Ouw0QP3GRrDUf0JFmrTyW+l8slueBWnh1l2GKo0ovq96HPVg81o1Oq8Bavm1wGVrYgOmxEewq6Fm6ODfoRzW3lq/LXoAQDpNRXQPOxR6lOO3mYyh1opGb9gpPU0tEWT1Vqh51PrY0gbHvXH0Xp9MkwPi1oiHRWNZPciO6mbf4lWGIlFttuNY79RQDxM+PzIzsIQMhv9aCC913PzLBYHSi/j5TEISEA15VoeJ0dCSzGUi97U/OaoMICggYo7n+CFj0RH9eErt0NJIfr6ZUS8rFnLJ/akbf2zRkQSI6rjOr+m0fHjZWmLbE3vGEM7QCMkWFd/RJ3z4jm/Dm8kbjCxZcg7nfA5aHlxt1JhXQvn1ofNVNrq33uRO7Cj0GFUAXNYz+gTRGs3UFsCB20e/ak6pEcHCagQUcaUSips8Xxyfks9kCA7RQH5ns8qCxkuaYahNFWAWEkQnJGNoAl+opxMmsv8XmRnmj9CdBUyFVpId0jvmok2y/jK+S473FbA2SI9vb3x6ygXCYzyNnmMvjgFgb9LcHLzJhRTw0siI1ULLRdWW7Q6yp8BFIw4+F46ZdmbvpCtaPErYONNv/G0LQXvNIBeAckgSAReY/azVnPxjedQhJdLZ/CrX18fnfjyXojXZPztEed2tyo+Nqjd3Jd+GtS6C3acs61zzcsMhY7Wq2q5eKyK7ofWDcR3p9cQnUJtfgh20qaL/i6ZZZV9E4zmYfeXDMiwX4dJ/xmlzNz7ifmf+YPVzufDeClE8gc8zaDJo0hP6XDQTQPVYtuvZt/6yKsFaMneDaybckuR6yhDzcLfB/ho5sCkKflF5JVEvW3VAdiulM+e2y5ofBqhwgDeXqZr+HLHxUold1rgb0RRDgN0drxAgk1rioh9BzH/pnPOj7pPVSHBWV2v5qzVUz31NWwlits2qoUZbkx0gfZ4ALwwdAMmJSuMoUs0Hv291z ZgzNgWgB g+iL6f5Vw/cB3Ka0i8Iqn3wxk5dAFsOnX17osKjcdDII/2TT0yYFiOZ9Ird0kyQh/Og14mR0eUEqOE63ehQSpWzEhdCs0yi3NHncUEll8iny1YcJU5neazWuahobiJKyk4MGG4VBPh2suyrQxqKaSsaaYfl7Q8KWbHxhrylVmxtM6KkieZIMK1zT59aXUci1gEBKCqlIN4q5CEaZjDsEcFEV4Ob5Ben6EFy2tptr7rjgIiSJkha1zLLH8pr0riSXuwVlfp8lnsTw56vvKuWDT7h+WZ1AQ5GMSdBR9 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 process will be killed immediately. So let's take out the '!unmap_success' factor and try to deliver SIGBUS if possible. Signed-off-by: Jane Chu --- mm/memory-failure.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9e62a00b46dd..7fcf182abb96 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -519,19 +519,14 @@ void add_to_kill_ksm(struct task_struct *tsk, struct page *p, * 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, @@ -1666,7 +1661,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, */ forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL) || !unmap_success; - kill_procs(&tokill, forcekill, !unmap_success, pfn, flags); + kill_procs(&tokill, forcekill, pfn, flags); return unmap_success; } @@ -1730,7 +1725,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 Wed May 1 23:24:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13651179 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 02E28C25B5C for ; Wed, 1 May 2024 23:27:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 892666B009A; Wed, 1 May 2024 19:27:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 841F26B009B; Wed, 1 May 2024 19:27:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BBCB6B009C; Wed, 1 May 2024 19:27:21 -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 4CFB26B009A for ; Wed, 1 May 2024 19:27:21 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F09F9A0C26 for ; Wed, 1 May 2024 23:27:20 +0000 (UTC) X-FDA: 82071415440.27.470F673 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf12.hostedemail.com (Postfix) with ESMTP id 0E07940004 for ; Wed, 1 May 2024 23:27:17 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YqTkUYed; spf=pass (imf12.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=1714606038; 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=5+PFPryu85fPUhHvvBmVJI7+H9PqDvUVFzqR0jjWF1Y=; b=rQw4SllQMjKaw0KRhO8DwKtPIp52tFkz3pU1fAFF2ZFZkWQ7z5q9ageq+O8R556NWLZtwo xZjBViAaDtY2pbrrR6fQNjaK6pjyjobpSsFcQiWk6tqNWsjlUAP3WBS/0Z1Q1kHrcCNxos +p4iVfiYEad9liewDneG9MkXRyMU4dU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YqTkUYed; spf=pass (imf12.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=1714606038; a=rsa-sha256; cv=none; b=U/1qCnKbl63O34ghEg1J3atCE/rNV8shp63R09jHZyWLPGUmUF4OoJIReYyN2D2UU939/Q oAyl5CWEg4PjI1bMNCIrLbdIEdQigAwACxrAY14DxFq61H5STJL6Cj8zA6d8/VJZIVFSGy qiVPT6nplhKeG8z94GoPCN9VUwxrvJw= 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 441MK3Z7031546; Wed, 1 May 2024 23:27:12 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=5+PFPryu85fPUhHvvBmVJI7+H9PqDvUVFzqR0jjWF1Y=; b=YqTkUYedogVvSCK4kM9rrwbF71TU1YEkkcaGMRNRVzcr5cYLUKudzAv2KpqTh1pqZf7o yf/vsAFC3dRx6rMA3QENwyJU9JR9PIcxGFE9OdEaKQoWvq952Oxl+wQHo4jRXbJBi23x GLVk6+R2bl8f8l0OAKpMxHgKrN3vzXIPTlWZSi21JstIa68JsvTqb7F7YIrSNjbfm6Yq zbzBGMzXFZyX9z6osQz+o3Aygge3m/lkbjjvRgn5YbFU2gNB8/dbfwj41VQ+ObswyI3f cE2r6bZ1SexRuIeYBzpfidVbO1O5kz9LGAZ+mc55QU8Wpw9tJpctx6flchfQQQNCf/5q Fg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrswvsyk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 May 2024 23:26:57 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 441MBS4B033172; Wed, 1 May 2024 23:25:08 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xrqt9vbuq-3; Wed, 01 May 2024 23:25:08 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mm/madvise: Add MF_ACTION_REQUIRED to madvise(MADV_HWPOISON) Date: Wed, 1 May 2024 17:24:57 -0600 Message-Id: <20240501232458.3919593-3-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240501232458.3919593-1-jane.chu@oracle.com> References: <20240501232458.3919593-1-jane.chu@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-01_16,2024-04-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405010165 X-Proofpoint-GUID: xYRc7ttZpJPOgWhFHPkn8aug1OV-_T7v X-Proofpoint-ORIG-GUID: xYRc7ttZpJPOgWhFHPkn8aug1OV-_T7v X-Rspamd-Queue-Id: 0E07940004 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: hokysruuragemsws5y4jjkncb7xshy5d X-HE-Tag: 1714606037-808134 X-HE-Meta: U2FsdGVkX1/sg0pZfbmoFeW1xk2VriNuB0RHywKzGDladRLaMnh2CXMPtwFSRYuXwn7EZjzVwy40jqS+KWCKDWnhsYVqC2KZitA8Xx8x/oL69TIA4UNClCBg+spO1jwetyOk7o9MOfdNEeWQx22yRnJJfVkm9hjjG6xpGgQHv/VFJkl+ebB7sRGllKyNq4v969beVdDJCMXhnh+ytJvWRlksNAT8jXSZN/OBZDtkpAdwDjFWkCST0v5gKeEBXsUYtYgBf6wOT3s8KE9aTmH5D4JjZsZrb0xp5vhv5g9UHab/VlPo4stt4DF8OYaNEKKNruaMr7AfH95GTkJC4u6+AivpdBstkjI0i84HqGteMMhQUOwlhukmIuNm6IMAS/9F4WAux89qQp7n/cH1Bq9k84tPxAGO77ZChxaNbii9Q54Q/TTQ2/F56YwMLKrTWLpFQjEuNSEcc1n91t0qnWVJ7OcVpvlM8p28CQB2/Hs80corBvYo4ecnkdzMNJbNKP6al8+IeHL9f1p5vu+tOfbkcYDOyoHz2f9wBroPP2Ca3U5lUD9b+IkNZL20aVF154dPahqaAdt5rQ/fc6jze8sMQTs6JljcJy5uPVonAQAw8Pmwl/P2cAV48g2MaShwDyZ/OfxSJDPJLmI5NkIoq092xUmiCrtD49F7WgtIOYPXEaaAmPU78ISmDuyS5SQfg6vODwokBFdyFnQtt4nweHC8/hmPmp+CO4SKN6MoLzoNtpq8ueLXluHVIEKhYoe08ppHpmPVXHA5nreWo6NGYVYDaZcuLqJHozaAr8uxstUsJxyMR/KuLi3hr58MqbYF6kpuk5O+WqzNa6WYro2aFJ2Idtw3YamKOpc6D3vOth72xiavTHoMnf37OIyARMYzOHufkMakxTiQfngFe1fqjSGbWNwuFybzCx8inM9iOTGNKHqYizw+/wCgTm3xZ4S/JJbYgIhD1BH2ID24z1oXhjx gaFJEeCe n6e4bobKz0R+JyPOaPzMsF0ff8xr7HsLSfizG2jwJMk4/CLorq8ixwQBDontbNWyXVmosm97CAwpskCCQCBzmkkSzXjcqy+BbtNfMBrGJobubOd5X7JS+J+8yDbaX9mN0yJLNcpCrKbYulmyceF7D31HA8BAhr7u8JfO6obrdpudCKOZJIzC++QotwyXr/hyzryfjFOOIeoHq0G+lQzd2mG1w1phE/vbfjlDmDKdZ0pRcVPYDupi3nJO5e0dmbt0NkPiG/6XVpHZ3khYIg1FsrERa0U4CWN5kfpxecaX35wJ/fQA8+d2u6msKxxmoeGL+nNN829AyfGTBlgs= 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 --- mm/madvise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/madvise.c b/mm/madvise.c index 1a073fcc4c0c..eaeae5252c02 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1127,7 +1127,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 Wed May 1 23:24: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: 13651224 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 592D4C4345F for ; Thu, 2 May 2024 00:02:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98BCA6B0085; Wed, 1 May 2024 20:02:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93BB16B0087; Wed, 1 May 2024 20:02:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82A566B0088; Wed, 1 May 2024 20:02:58 -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 66D4C6B0085 for ; Wed, 1 May 2024 20:02:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1034416060F for ; Thu, 2 May 2024 00:02:58 +0000 (UTC) X-FDA: 82071505236.19.3D71F43 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 2CECF18000D for ; Thu, 2 May 2024 00:02:55 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=cOAW+aeJ; dmarc=pass (policy=quarantine) header.from=oracle.com; spf=pass (imf24.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714608176; 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=iBNgjATm1g/dvs/mF70E3zaHDPEr1jQSRo6dBQGN4Yc=; b=hb2F/ljwn4gmSvUbaMPejKslEfjhP4NCB746SEH+sTKq7IyBv4eiTExMsqrJQoHdpILNHw 3o8Igc+mBouHdKUSfX3jGSjZZWGigPwAL4aRPtAN9OXHDKx/UROX8g+kiSblvHEsr1VdXz ETkqPv5hNy39nAV+Sr5uxCFFJ6/97ME= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=cOAW+aeJ; dmarc=pass (policy=quarantine) header.from=oracle.com; spf=pass (imf24.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jane.chu@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714608176; a=rsa-sha256; cv=none; b=uXlM5tbWF7sNXZHmMPN99Y1B5VIzrogjuDXpM6ZxRj86+z4NzeW/vmkjpsTc2ID847Lbbu 5b5cMcWutnC34M4Mim5QY8V48j40dMVVNzqtavkwxN04OmKP+r909ja9ZB5eqbWCSQ8koE Z8Vq1SaO6iAxksRm3tXq3GCiRepmjf4= 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 441NKAPw010464; Thu, 2 May 2024 00:02:50 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=iBNgjATm1g/dvs/mF70E3zaHDPEr1jQSRo6dBQGN4Yc=; b=cOAW+aeJW6MGxJkg049vVzz2Zzrb8XnTgk5GVZgHLiP74GRfVHXxw7mt9e2OxPnwPT8R t3+s32yTrY/ROVhL2IlZ1BJixpwJMqTOJhPM2JSztBbn2Sq16rfeuex6hKuxwpNHlsK8 1SC4qfcynTe3dxcCdxXZOmlwnvGwixyZdzlITCGCTuholKSh1CQP6x6cAUO6j8vYpNee P5BU2EzhcktlZAo6gYwGm9bGcwpcMl9JbDSh/kLwk1ePIgpiMWlXygpHMp/LcAjs8GL6 uq++DN7DScLxq5wM5tN4bqMK6X1YvKjOvm5L10vZbUZWZUPh8zN4QGvrk9zRU4+JcoWt dQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrsdetpj7-261 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 May 2024 00:02:47 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 441MBS4E033172; Wed, 1 May 2024 23:25:12 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xrqt9vbuq-4; Wed, 01 May 2024 23:25:12 +0000 From: Jane Chu To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] mm/memory-failure: send SIGBUS in the event of thp split fail Date: Wed, 1 May 2024 17:24:58 -0600 Message-Id: <20240501232458.3919593-4-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240501232458.3919593-1-jane.chu@oracle.com> References: <20240501232458.3919593-1-jane.chu@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-01_16,2024-04-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405010165 X-Proofpoint-GUID: ovlQb9iG_YSm1K2_mAapQrq0LojExnvH X-Proofpoint-ORIG-GUID: ovlQb9iG_YSm1K2_mAapQrq0LojExnvH X-Rspamd-Server: rspam01 X-Stat-Signature: 44rtwzj9uounof7ak3wztc8gwyfwws95 X-Rspam-User: X-Rspamd-Queue-Id: 2CECF18000D X-HE-Tag: 1714608175-53951 X-HE-Meta: U2FsdGVkX1+b20HCveFRWKiHrwVZzCODftaUP3L+tu83vnOu09gJlDypUT4wSiBGsBb2/7LmczMDA7IIkx6np66ZP+LtIxSgH6Xtwnoj4JEsn7YJ3JmANLOL3jGTcZCnJZDUDyoEA6fEj6M/Np66uUmYya7i9eUnYw0mezf1jIj7GNG2gTYfaNR3AIQxGooBDzJX5hGde+48DuIxWLT+XxsmhmkT04GJzxct5oNSO81D02wVv3mmnGlgwEe4OGOJYydkJtOd0oYVZ56Yx9Y0+2WCS+QDLWX1p8wMPmz1NrffHO535sukEWV6o/eBCQIEXGWk1gkh+tekRUlDYT1m8XpsuxcBEcEm2HLLkBBUSLH0KA04jBn4JoODnsujJcbuFCn/qQ2v7Pap5+tY10SqmXbaiFmqkGBUHEl0Qirw/uKdQhTm4qOaUlrVIkvdAd1a97ZSzNvJVOhuBKd71w6ZlSEFnpV2ADZe8xvnwYXcyA9GUo2aObMJbXNi+uP0JG09Y6chkAP6YLjg2y2jAINfUOYq2vcDPOCj2509zRzw2KfHXzBXAhE9VroDg2TOjf/q5jfQXwaTcxsRI6/QHySuQYqkQ0/f4c6ucj9sL9sYDv7nL4Dk/CkqI6dQNIrdiK+/vmxcI+Zvag/9Zg37HJVl3AG2YKATTARgJtpjIZMgfrbMvzsP7ZcTI7vbHJZtqV2j/UuYZkeSb4oP5kLpBuWVPO5EEEM9cDfcI43gCD+T4o+iiQs8MDyv42KDdyOWZvp4gvTnKVr6P+cPQxUjtOs0M7+fK2IVkUoov+lTNrGw+hXXDnRMNy1ByZSvD9WjOp8CMoNfWklISQLpyvA23FOFWzWO+tcsy71n51mBc+TPBNjNHFamq6u9coJ7YN4qVBSwXT6gRjxStndirtLUnNShPG9cfKxy9icBzaaPSIPFwnxWnWOON4xed67o2xf47mjje9fxNT81iEB721TvOv9 NCOatGXR nZI7tH3j+iqDi+M2BKeQSRNLzym6KP2wb4xiAlUo0hH34KLY9Br5pPGvHKKsHu/Ev/A9HuECUNZJiPIfiGwRhekDMUP/AC/EWrj5Uz76VZBubf7RgPLiYbsMeoNlltUolROV55bYZ/9DOBooitY3431XgvRLRg/ohMxOs+ikQP3QA3Qy4IbYs7lq0oegZlGDKlYfqiWIYQj+wjTShBXN11xtBlqE4+T3nnL7RFIzAUEhkYsCieERGfsXKGO7O8NG5GoQk6kM0b0mEt5I6/udFBUrzeQ== 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 GUP longterm pin'ed 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 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7fcf182abb96..67f4d24a98e7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2168,6 +2168,37 @@ 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 GUP longterm 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 page *hpage) +{ + struct folio *folio = page_folio(hpage); + LIST_HEAD(tokill); + int res = -EHWPOISON; + + /* deal with user pages only */ + if (PageReserved(p) || PageSlab(p) || PageTable(p) || PageOffline(p)) + res = -EBUSY; + if (!(PageLRU(hpage) || PageHuge(p))) + res = -EBUSY; + + if (res == -EHWPOISON) { + collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED); + kill_procs(&tokill, true, pfn, flags); + } + + if (flags & MF_COUNT_INCREASED) + put_page(p); + + return res; +} + /** * memory_failure - Handle memory failure of a page. * @pfn: Page Number of the corrupted page @@ -2297,6 +2328,11 @@ int memory_failure(unsigned long pfn, int flags) */ SetPageHasHWPoisoned(hpage); if (try_to_split_thp_page(p) < 0) { + if (flags & MF_ACTION_REQUIRED) { + pr_err("%#lx: thp split failed\n", pfn); + res = kill_procs_now(p, pfn, flags, hpage); + goto unlock_mutex; + } res = action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); goto unlock_mutex; }