From patchwork Tue May 21 23:54:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13669817 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 75338C25B7C for ; Tue, 21 May 2024 23:55:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F30806B0098; Tue, 21 May 2024 19:55:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE3696B0099; Tue, 21 May 2024 19:55:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA8776B009A; Tue, 21 May 2024 19:55:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BE29B6B0098 for ; Tue, 21 May 2024 19:55:49 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7E2C7C102E for ; Tue, 21 May 2024 23:55:49 +0000 (UTC) X-FDA: 82144063218.20.7EA6A36 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf14.hostedemail.com (Postfix) with ESMTP id A4925100007 for ; Tue, 21 May 2024 23:55:47 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=h3CrhepT; spf=pass (imf14.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.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=1716335747; 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=frA7aS1vLKTncyYL7L1DmGtD13xbXGlpWxyw+e4B7WM=; b=yk/03eEitvfXfiWfWhGvGsgPTuvy8FF9RJu1f+4UKlHYwbQcc+b+/MS+9gzd1ZT0OycWOx Pwc4WtWjN1BN4se+89wEtuD3xwz1CLCAEkxjlq168ICf6xSaRatjAqlRxbbWktE6o8FT8A aqaRAs2epcM3Sbof3Ci/tnTjyHXprEk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=h3CrhepT; spf=pass (imf14.hostedemail.com: domain of jane.chu@oracle.com designates 205.220.177.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=1716335747; a=rsa-sha256; cv=none; b=eGSidFGINUKZrPH+OFDJzdnQ7lkGiyRV19NsO9Ts4we7gsbgJYBBrtNvqY+1W7f4q83x9Z v+5O6pSbrVJa0tTihVXolqgCGRIZRPIpCwcpEMoMYsIR07bljQB5+DbqRgOTV6F1/QESL6 Tv8DfCwcjlwtHVT759orSj11J6Sn5+o= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44LJi8dZ025724; Tue, 21 May 2024 23:55:40 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=frA7aS1vLKTncyYL7L1DmGtD13xbXGlpWxyw+e4B7WM=; b=h3CrhepTNn/GaGgIJzZhqtsA7faeT1QZf89SKUeSOVcUQEJKLeokWgdytocXbQ/tR6wd mvdIHTnqEutpHvRGnRnDRNy0BeIXtqXtEbZ19zn0/AMebwZaz97AqmHJl6VA8GQ9RSTX pkUkL+cbnjeDIQ9wc72PTtUQeyieP/pbryXb98HMIJAmqNl+yM1zEXbTU2pRXuNfmKWU FPTPhJh4CglqeOBXb7DRzY9IM3xTiV1SHJRB6BybSR0VEj91El9FE9C8CCVzQpW2w7w1 ORy8M037XhGzohEkU3LnrD3PKhweG9vEWPfIaeaIiUMP5WMgGC7tBF7q/V3BPMrYnm8H 2g== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y6k466m2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 May 2024 23:55:40 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44LMZkKi002667; Tue, 21 May 2024 23:55:39 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3y6js8erce-5; Tue, 21 May 2024 23:55:39 +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 v3 4/5] mm/memory-failure: move hwpoison_filter() higher up Date: Tue, 21 May 2024 17:54:28 -0600 Message-Id: <20240521235429.2368017-5-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240521235429.2368017-1-jane.chu@oracle.com> References: <20240521235429.2368017-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-21_14,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405210182 X-Proofpoint-ORIG-GUID: fN-L7z8FkqKuAIhlYwvx_1gv1456QLzQ X-Proofpoint-GUID: fN-L7z8FkqKuAIhlYwvx_1gv1456QLzQ X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A4925100007 X-Stat-Signature: fcuy1gxkw8cwfbq9smt1ugzsnowo4w8g X-HE-Tag: 1716335747-619197 X-HE-Meta: U2FsdGVkX19lVFSCsNHCDAk+WZpARzzdOCCz2vvnJM2uE8c0xkasPMQ8REozl9Rk8nHWeOwrbedXKv/Y9DukcMW6/KRF7n4cSGLfNkpvaFFOFpiDAjV0gZkWnxB3kvjf6HM6zqev/Ocz0A7MrStiZG/BnIBtY84f6VfNoJYFkt3gOzZ6OLDhAJa5QHzG5Z4YkuaF6ksus6xk2N01GuFpZtuvc2A3WT6Syaz+jveSPbFVUmRQDkQAUDbPdN18GSnybeQ/FzpRG0YB2BebLj9yiFoZCTakPLRrdFkiDzJ4XeS3PMMD+yv+WnWoEGMRbCai3o1/1sKczEMLUCyIkktzXzurKdrdhUgCjXzLH1sh6aCft9sAAbSiQNTcFEt5K1D+kS5lTVSb8+r0ycFlbrD5kyfOqPgEQSexfrG7heCG2HtfXamCKP7Y8blU5V9xSc0ii3RPYrdZ4NpXQuI3mYBZWgSLf+jAdw/U1es9x6H1DtX67JXJ/iKbFOj4BPBsYhia+zkIH+FJbC1qc3tIXhisCZjh2GgCu1hbjCN8lEmOYDyEOusy7Z0zNeLTyRE2yPPE0XpNZcGJ0E7oC5rRYm0D1pgM+55L27YwNQGO23xGdDwQetag434SF+sUPW11mLUFBgDuqvgpQBC8+mSPSCMZkDW8HLMbNrZihBJOqTJp7BpOYM9zcB5hjBN07OmoJ9YhKzjr1izEDCvprS1R5MXpnANO1MyOgQqiNyGJrt2Eln/tXmPhZO0MFJmTvFErUdspmFfe5CUNTOgOV9NqAnxTNiuSc6ST5tYnBW3B0iN/SrLGRFvX01Qck9Y+Kcvzaw2i9+K2DkvQGHtjltbTAJcZpgbJaX2oaQNAvaifAMqa4Gao6aZ8IrqXO0w2dqOteL5/79IRVu/7osYickPZyTQg5sHiT81Mz0MSUkLOqzcLelehewGSW1LVa9oyNEyAus3FlHEKdrYpL2eCc0xmRcn 9AGO5mgW KU0rFWwsmamcfmkb1asFLCV6vHg2izbFwYg/zXc7EisMTklViD9bzZXVsqY6YV6RBlj7Yokp7YS3A7PIcDmTxpRuA0tlWgs48JN15bPsRZDFRPs4DQ6ATS1/oNxvCFmHNBm6zXiymOKQJvRhfI1gzySe2gExlCBKdP5yIfmMZzkkG2i87OgYGeMrGqMvj/joN0lqtZAx6TsNyyXzrarCqPeDFCotjmLPG3CQ9JthdJgndiVIx8Bb/gNiEjmWx3KLr+Z7BKoGn0hvUmUg9dROc65XNjHc+aVy+zgUeyvLQ2whZbKc0Vi5kGdXOvRlqC3Lnvg4gVnGNzdA/IzU= 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 1e22d73c9329..794196951a04 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2301,6 +2301,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 @@ -2364,14 +2376,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