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