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); } /*