Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp791130lqm; Wed, 1 May 2024 16:27:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9hkJuanaxCGBgQqnxKcuqLD/TuK73hL/C4UrLm55LK4KMRzqAAgnyv14ZUipY0V50ml6OotJhMaHnNGrLbWuedCCDWUoK/gpGfDYkMA== X-Google-Smtp-Source: AGHT+IEkds+KFydeUNGQMQZ34NxDr8wajomxkUcZOtrdfntSsdqhdTWFcP+uVFUzrfabmYfS0kLb X-Received: by 2002:a50:8ad7:0:b0:572:8aab:4420 with SMTP id k23-20020a508ad7000000b005728aab4420mr2529981edk.39.1714606070574; Wed, 01 May 2024 16:27:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714606070; cv=pass; d=google.com; s=arc-20160816; b=PW9qoR6a/fhf76mx0SdMt/MlM+59WTGGGRwHxJEOpjeICvHk2sC3o7i+OmK7Qm2mCG E9Sw1580o7Tx8jD7lykNeWzTX15lXzBKSk2TFZK+qG4KpswQxD5Eogz+DzfgyKtd70lU vcP7v3sY0dxE4XNnafY0QJ9WZGdBADnJOmYMxfgYpzrE9cpp8Sw18V4BAqfXTq8NMoyk 5pyHkwpYp0pwqM5m+fQ41A2wSc5EhIQ4IgxQ/OSTRCx83aox3Ej80w0B0HuuHY5MWuOX fmEVuQoBwz1pZ7HbVmQfukmhcQnW1zPJz73XLCjFQ4RRgW8PlkPl83rOzwl4LtgNGHvN bt3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=wY3UVMyMfxgmoJifRLcjAmBE75B0nsP3Ptes0P01A1M=; fh=eLHx2/gUP3bPqAsE5tk9MDIjddpLnrR0F5b4B7LLJDg=; b=dDAcQndjOUvQ577Cs95VJxOKdx69YSn5KvTDcXpH5rcXKovzBKBCJO4xEE0ufrpFRk lduAzjXm7eMBxdMGboNMG/bCm2EZphLhxQFNy0l26pggtwbfTLNcpm+lwy9QWez1sKWN 0rCuHkYpw7Hs59iQSnIWegjpCl5tiAuQPMI6QZplQv1mWer4Qmj8oaoEQ31i3pDE6fn9 M0U3DXuFVuP/IGpw1xpGROquEq2Q0FHkw0oncHmuYWYHnytKhPXZnMc+64GoMGPO21L9 IIFFjU8fhWWbqhKvegpCWx36zUJxsscNoLg9zuRj/udsHW/XQuTbEGF8KII6JE1OYLfx InAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=O30NH25c; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-165850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oracle.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bm10-20020a0564020b0a00b005729d8ab32esi2092409edb.212.2024.05.01.16.27.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 16:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=O30NH25c; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-165850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 50B921F21473 for ; Wed, 1 May 2024 23:27:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFA9F168B1A; Wed, 1 May 2024 23:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="O30NH25c" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41BEA1581E3 for ; Wed, 1 May 2024 23:27:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714606063; cv=none; b=iaPXev608Sa+1uhX2e28NRZDbJJyHaqmoSa2RoZApPAWaZ8akKLSQS+Mw+PV98vz1uLyOQHq5AYcGtjG4cFLb8QM/9hBSZoeAnBrDw6GgLW2aUXAbkLlopR1ChbXhyc/bGiBLOptl7uGceiyYObm57ng42LZ6C4orh4SDSulhso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714606063; c=relaxed/simple; bh=Vejiy+vf8zrb4REZkuafU7dlCh5bhHcQ7BKMFAFU0Eo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dcdBWYPUTO/WToW+wksYh/j1fKDH4mmdgmws7QCZAULlmK8BrNxKMp0is8XtnfOJeq3tPK1pinwFIs+LHfQuwHtfANjHV4w7wmujwjaD942OSZIiEJWo9ua0to5uO99sHSiq1KGKh2xLBUJj2RUx5hjHaxCIpIjTzCbV9JEJZC0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=O30NH25c; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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); } /* -- 2.39.3