From patchwork Fri May 24 21:53:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13673759 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 C40F8C25B74 for ; Fri, 24 May 2024 21:53:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 455AA6B0093; Fri, 24 May 2024 17:53:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 403366B0095; Fri, 24 May 2024 17:53:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27CA66B0096; Fri, 24 May 2024 17:53:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 087456B0093 for ; Fri, 24 May 2024 17:53:55 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C4BFB1C109C for ; Fri, 24 May 2024 21:53:54 +0000 (UTC) X-FDA: 82154642388.01.4A4A396 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf28.hostedemail.com (Postfix) with ESMTP id CC012C000E for ; Fri, 24 May 2024 21:53:52 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KW8Qwaw9; spf=pass (imf28.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=1716587633; 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=SihancN5k8LC/Hgj/5KOjJmpYjhXQMOG14zedpZ75B8=; b=SOQe54ZyUpyBbj69rytLZTFVWu2l//JrZTqh9/0kLP0RXjDIqmuSLB9htRJ6sIoxw6EuV9 TEb8zMFHfzlceb/UImgUQPvyhpdHMnt/PvW07LZy2Z0Vsdop86TwyWBkrnfHlFlbl+WwxG bOXW2zAoH/548Nx3G7bTnkxkXzh+rbs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KW8Qwaw9; spf=pass (imf28.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=1716587633; a=rsa-sha256; cv=none; b=CnlNKP2EqJd8DRFubRJhw4g4Ee4QEGmmP4xMwtItShJ3dZT58UZOkhc12p2p76DIa+TeG0 Au6W1roMB0Tt4KUudevUEI7TftAK+oKV0aezCoszf6xFVhn17XfmbkSgyfwI++WYZAZapg mmE8p3eQhbQiNv3MYzQ5hwjGR9KJWNY= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44OKTbZh023819; Fri, 24 May 2024 21:53:48 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=SihancN5k8LC/Hgj/5KOjJmpYjhXQMOG14zedpZ75B8=; b=KW8Qwaw9MgRTg2x6HgWx4L/6ultVBxcZu1IHaepybohYvCDch5isMwzqEapu2CteSb41 KWsxMyoAa4IVCIzA3xHEdbiU/p+B0JNiK28ssP9KL1at9eBlEDlu9VQvIIPEV71Fe9tl paGzZjvKEZdH3GGMsFwvJI92QFHNMWlBqWjF+krfNuSlKwU/K20kV/2/DaWde3jORtEO tgndbaquKNWUHvyVk4U0GJOw9aDiQFSK6IoxCMC10njzgNpoESMeyt7brQPHCjwIorpk ndpalrOF/jweatfkpifBeTuvSXR0REwwlGLeLTp2455ym1GMtO9lc9Rf0X8ORikqiLFO Bw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y6m7bcxts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 May 2024 21:53:48 +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 44OLjG1O035956; Fri, 24 May 2024 21:53:47 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-5; Fri, 24 May 2024 21:53:47 +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 4/5] mm/memory-failure: move hwpoison_filter() higher up Date: Fri, 24 May 2024 15:53:05 -0600 Message-Id: <20240524215306.2705454-5-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-2405240158 X-Proofpoint-ORIG-GUID: OTsiOAKLEUfSAJALl24pXDTKjX6cQFx5 X-Proofpoint-GUID: OTsiOAKLEUfSAJALl24pXDTKjX6cQFx5 X-Stat-Signature: 7e5uat7yk9a7etodrezqd7sy5cdhgzxy X-Rspamd-Queue-Id: CC012C000E X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716587632-32541 X-HE-Meta: U2FsdGVkX187GE8DYrTDqKU7A8vLZooosTaG1pEMmE8qLK5IrdGmvSXLPP3VoiFCs75auumbTxlDkxAhmaL2pEZGxDFMaZ2yhjg34Hg4zb6nyrYvsoJzuP+AplnFeDY8Ft5EvZ++ZSI7k8y+00Wsfw19jZL3wDVmqZ1xsToD02vI3IF44pEwKu8GikrunmX3xqTN1zgq4A5RmtpPptXSStkHzDeqffXZSQRN4FPWxfpiUzXOWwQEV1FQGkiNlN55j44d4N+ZOKujDYch4IRXYFRtz7TXMKHGZEEdSsrsxdQpQBt1qaItMZDJz0X/UFrjCt96SHjsfAqelcfwPdG5toy48Z8Ea6GvtUQTSEKgUzcOREZwwMsFfxgOrhnLuolApIM0o0A7bjInIuE1+AxDZBka/IgQ4+NZo1ObUwhnF5wT/5386HdfuUU+g03vLCVh8CMIkan4mWZrutS8SrZqpdkJUsEpTlQyD4tMZOpPHRrKbBqsxgCuaxJahUzhMzkqo2gjhepb4kh+WdOxMRmxaY6n5R8P9BAcxNy6DBC4pG6s8paLWE1sAgQOlrTf662SgEmMK60UyZm9ONqNL3C4o+/FpoAGL6bBZHx1pn9g0WTJU8xx/VzO5+762FEtxTR578DpUvPs+97KsrSwlFL2hrinOuJt8dhwkmjTQQ4656DWqYjTxOVClor4b28ReQ/TW6naFtcM+Yrdv4qw+OD0xE2bRhJ1yPNxySAUa7+Y/BbK0CZtm659cIzQ4xwcpFNdRbqZ6yYVRhgTCdw/omFFU9VZQjG3PO7uJtONSBWVIReWorGXpkfPaxVA/YGp+Xi1anOTZs9Hpj8WeolLdLAL/7kbrrS+2hkN20dIw2lSnRqFEPOS0BgTCs0u4AU5+lRnDMP738ikeffm4AbevA5UY5COgOSfvUWmA/fO0jYWIKMzVN00P2h60EQkVLKLvHvhWY3MRojo3WP7TgngJbT DQXfponH raQmJ6AsUXW7+b8Uh95KfA2Trfcrf7XSSSJ+uvLLGeLZW8v6AkKXiaPeKXD1DxkmxbmszoJz8HyS4x5AhGY9U5hODUv3n3kcWeceYvffaUAYqb6NprGKFoHJIYv0Wgl4ylCyWMnPmEkDyCmAju58Wl9K/bHHhaITaUIOpQqWY8SODPb5AphxHIZJWMA+nlfZDjiohLyybFI2f5eqtRBBfYjssoPMJDkd+2hYVCcFNhx7757q0a/f+iE1GCZvUbwn0w+sWTcAPvtLxxbeWK4yPhekzHO4sSMXVEdcuXdwEIU2Hzs25c53D7YeQzC1lJs29KJ8ya8EWgK82MilTVxiLMMzwbYWaPEQ/Lw9/ 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: Move hwpoison_filter() higher up as there is no need to spend a lot cycles only to find out later that the page is supposed to be skipped from hwpoison handling. Signed-off-by: Jane Chu Reviewed-by: Oscar Salvador Acked-by: Miaohe Lin --- mm/memory-failure.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d1fb1d6f6b11..85659dd0ea32 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2300,6 +2300,18 @@ int memory_failure(unsigned long pfn, int flags) } folio = page_folio(p); + + /* filter pages that are protected from hwpoison test by users */ + folio_lock(folio); + if (hwpoison_filter(p)) { + ClearPageHWPoison(p); + folio_unlock(folio); + folio_put(folio); + res = -EOPNOTSUPP; + goto unlock_mutex; + } + folio_unlock(folio); + if (folio_test_large(folio)) { /* * The flag must be set after the refcount is bumped @@ -2363,14 +2375,6 @@ int memory_failure(unsigned long pfn, int flags) */ page_flags = folio->flags; - if (hwpoison_filter(p)) { - ClearPageHWPoison(p); - folio_unlock(folio); - folio_put(folio); - res = -EOPNOTSUPP; - goto unlock_mutex; - } - /* * __munlock_folio() may clear a writeback folio's LRU flag without * the folio lock. We need to wait for writeback completion for this