From patchwork Fri May 24 21:53: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: 13673756 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 F1611C25B74 for ; Fri, 24 May 2024 21:53:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 602C36B0083; Fri, 24 May 2024 17:53:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AF5C6B0085; Fri, 24 May 2024 17:53:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49DC56B0088; Fri, 24 May 2024 17:53:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2A38E6B0083 for ; Fri, 24 May 2024 17:53:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AFB0E1205D3 for ; Fri, 24 May 2024 21:53:23 +0000 (UTC) X-FDA: 82154641086.19.8358AD0 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf18.hostedemail.com (Postfix) with ESMTP id DD9F51C001D for ; Fri, 24 May 2024 21:53:20 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=TdcJBpGr; dmarc=pass (policy=quarantine) header.from=oracle.com; spf=pass (imf18.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=1716587601; 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=aVvMSdU9di+/pg8Z/YTSNT+1WpNBkHB9jxFSgsTIf2I=; b=HkYbQ6lkAeem/TNSF0KICsJMDBXZW382F+3Xt/eYfzFWYoTBbmLkZ8/vkChBz2qGuAQf9n jzB1hdN0JVOmjC5TqRxBsPYeTol4FR2xPu9d5i2fEBiwOn5yh+m2ndqMPU54j+WmkAqOP5 d1eEui/8VCY03yxL40FkzDN1/spPHCQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716587601; a=rsa-sha256; cv=none; b=AMrW6JSL+UEvt3OVJo9VhOo0mJCbnQhWUo7/2eRpUmNVT+LnxeoPrrghab+WTZf8nzsYHY bMn/pNOO9P8kqnhJHGNPSptrcHux4UWncSOQVhRbBNZNwvbjn3iS+Rinl0QoHPS3eE2tNL ln5PyRXAwcu1ouk83TQ5aGlswkXQnZs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=TdcJBpGr; dmarc=pass (policy=quarantine) header.from=oracle.com; spf=pass (imf18.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 (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44OFxjhF015807; Fri, 24 May 2024 21:53:14 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=aVvMSdU9di+/pg8Z/YTSNT+1WpNBkHB9jxFSgsTIf2I=; b=TdcJBpGrNn3qNkMVnilcUOPTUhxoR9n7n423lwhS5dNLcFnxh/pfSDcXomK4xUAAhiVX wP16N+QrVrskqaU3hspLv/12qFhlJuv6yPMsvpV+ttDjIBK9ICbqduZY7Gy5v2rvAIzq z/XnRrIIEl6fT588jno8RVTyxteuGWRg5RfLxAuRuluE9pf+8pFjHnkqNzNOEtwY9/T/ 8xKDCf0hmOW7HMqnejHg1y2haNxqOWSatRApVgawilJbqXdcH/x+Mscnb+u+A9qnEd78 YP+x++oJOdx5JMQ25xDlKuygN9UcKzsbGEOQHHvkBG+VyRvAhkZPvaxI0+z3pWo5nqjQ BA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y6k8ddd00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 May 2024 21:53:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44OLjG18035956; Fri, 24 May 2024 21:53:13 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3y6jscbsu0-2; Fri, 24 May 2024 21:53:13 +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 v4 1/5] mm/memory-failure: try to send SIGBUS even if unmap failed Date: Fri, 24 May 2024 15:53:02 -0600 Message-Id: <20240524215306.2705454-2-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240524215306.2705454-1-jane.chu@oracle.com> References: <20240524215306.2705454-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.12.28.16 definitions=2024-05-24_08,2024-05-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405240157 X-Proofpoint-GUID: FZtvSnJWRGZRRG_af1fn4jAKDaVUcprt X-Proofpoint-ORIG-GUID: FZtvSnJWRGZRRG_af1fn4jAKDaVUcprt X-Stat-Signature: 8ijioiep89k3rn143mn51d738tpgt6id X-Rspamd-Queue-Id: DD9F51C001D X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716587600-382202 X-HE-Meta: U2FsdGVkX19gyrnHmEOONBSeQTEwlludLmxPV3aixcB8VK+kOQaOzbFvz2O2gqmCHMnzUmOs8qR/GL2uV8yMyD/wx2E9yO52xno64Muo+n2hPFFYxe7rMPOU+l5dV2CSPAzD7rmcEX+7ZrMesrqZmmCoFEuX+f3qqjkkZSCn6Ukzk6UoPUBHVRJQcflxaa2zZD8SNNMOmadKuL2JTu2vr7I7C+qJtrQVblQIuVzPm9I38aNMIGsZUFNuaHFRSoiYvfqUzlSaGfcp+waMn8Zie2uS9IVoR3k6/4zNmUoquy9+fDLrBqt9nRwu0d8vgjeI6rB+aettXxv4p5ffjCXSj8XjnhLhPRYQT4YccrluCi5oeMEb878zkqUXa/A4QTDom6MzJm3B5BxKjiihmZcd0wvrdzZE3wXQAqc7cerfn4wyU3De5epLhpHSk/9Ex6zFuDA4LKVwmnSL1riyeHlX/WZfb2Yf6JtM8GI1HKu38Hf9e9poq0q8iolqCvYmRxnAySUop7SfRSG2ylnv2WobxzX3dau7HoYefd6fih6Iw/36c8V2VD5wRKo+nQiBTQvqJ54ezAPpCJesm2dZj2oPz/F8zAXp9G+AuRQkFw7ZRr+QaC9xLHkqkdYIl9+Ga/hVwJRqurTQL466Zrc4Rdx6dU36hcHpvn7LwvXiAjgmcRcqroOplcDA5gPGaSXSpcuvAO3ncRYKIa1qN1x4sLjIuZ8o2/mYgPvROhht47FcsIfWnXKR3idCSUMr7sRmk1RF2SwuqUOt35ZlAc7WcZFYHKG+oH+l4DdrVQ0u64jJv1PoC3f+vX1p2+4mjFTh5Df7r+xkeen2NVMNqlTJQG6kODOJd/vsMfSE/nSSVNSp6HK1DOAToFD+QDALrQeZry9jY2D83rSUNY05xBaestlZsE2YuWK0gDSp1ZgavCM0nSreqeNa9v1Ejeqlmfr6dvK42PQE15xxypk2OKl+9f3 Hu6q6tKD K0va3 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); } /*