From patchwork Fri May 10 06:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 13660905 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 82F74C25B10 for ; Fri, 10 May 2024 06:26:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78D576B008C; Fri, 10 May 2024 02:26:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 733E06B0092; Fri, 10 May 2024 02:26:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 585596B0093; Fri, 10 May 2024 02:26:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 386976B0092 for ; Fri, 10 May 2024 02:26:30 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DB22FA0532 for ; Fri, 10 May 2024 06:26:29 +0000 (UTC) X-FDA: 82101502098.23.FA1FDAD Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 1410E14000B for ; Fri, 10 May 2024 06:26:27 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="lRuQN/xM"; spf=pass (imf26.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=1715322388; a=rsa-sha256; cv=none; b=3v7VQ7GQQCFGJEf7BlGV2OalJ9pEj7XLtKUFgaUXUa8eH6hpBeaADiQKezusOc6PanpHZI zAoBWqzX4ydfTinaQ8Rjs8PZVYklDjc45g88xlZkCRldRXgaFf+/SJHW/pujj3Fp5/L6c8 6qES23M28nkYJp8NIMXcHwYMTR3KeyM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="lRuQN/xM"; spf=pass (imf26.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=1715322388; 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=qec/kt8yhdFKEAaIHR/lBrJDjyfV3DVrQvjyrnvIHpI=; b=X0kbn9S5HZciuFfBhUdOVziYFHOmj7XxyTxr8r6WX/skusoDrr7DevxkImPfnHPEBY58w3 12TVWhxssJPV7hWlycqe0ogoXzz3BTYUYR6Q4dxRB+7Wrcms08+yMmEOLvvfuGxseL2+wu WbNEqiIfDtoOj7y8jL6t7P3aTTv5VpM= 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 44A5Uk36011962; Fri, 10 May 2024 06:26:21 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=qec/kt8yhdFKEAaIHR/lBrJDjyfV3DVrQvjyrnvIHpI=; b=lRuQN/xMOVSxjVnhzDm+Pq4HIhcUC8yYEOf9Z2eUsA+MLCdtw0r5l4Pombb7wH6UCjOI DAYYVBc4bniRlWOm21BPU76OjthY5i0QfqOWVvzwathI0D/W6CQ7uuHBwMV2j0ymnBVI ThHaUIo3ooFviW92KbMemp3N1RH9kHybAN3w88XwqwFnJ86LuxAT3grjvFuDiqYUlpxM 4E3MGarfapaworMInHdK4rD/QALsuDuZONl/Vs8EvtzVfYnk/ELOp7bWs11EOlM63156 9Sq7AM5bSR1uXmHuJE6cagWmhGhhowmzdH7z2hzzmkJkhWEpKuNwR5yV2arNMnb2X0mT Qw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3y17x7recv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 May 2024 06:26:21 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 44A5vUjL020104; Fri, 10 May 2024 06:26:21 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3xysfpghcd-5; Fri, 10 May 2024 06:26:20 +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 v2 4/5] mm/memory-failure: move hwpoison_filter() higher up Date: Fri, 10 May 2024 00:26:01 -0600 Message-Id: <20240510062602.901510-5-jane.chu@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240510062602.901510-1-jane.chu@oracle.com> References: <20240510062602.901510-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.11.176.26 definitions=2024-05-10_04,2024-05-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405100044 X-Proofpoint-GUID: o2ec6oR7IMYucBVlxbovuoOEzvuShcLi X-Proofpoint-ORIG-GUID: o2ec6oR7IMYucBVlxbovuoOEzvuShcLi X-Stat-Signature: cp5ntdeejger7pmoao319kuzniwa8k8i X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1410E14000B X-HE-Tag: 1715322387-183930 X-HE-Meta: U2FsdGVkX1+z3DeGja9lp/AqJaz+2eMQ+2QJLvFgT/6nfVM7c81VY1zU/vgGEfaBwNcVzPRgpXC+33EunJf+Nmz2+dSxju1kaAC1bQfwPyD24MA564uWII43ZAws0xiFE4UcO2zMc/GTp7WkjO2GmhbEl7a8wa8trFN3s7Hq354nVnGRvKgPXmDG3pQzNxsTEy70s8x+VanR7TxhBHjOaFynYE5+CC7x1+mV6N2fTT32g7rX2j/1nb4+0PjjxU8UALGGfUjelRiSZxhZ9nFusrN43Y3b445vWLu5HIrLMC4C3eSBDvKxjVCgxNF1RUQ7cbpgW1j7lXWcbYEllVjUpyv3nnAbbmiSMoULu5hL4+E7YzeEdafq0cC97LK7eEpyhAMpZXvuhKMmISPqsKqmX9oTiXfVP0LelOIug6g0yabWVZxFsZ6pO9yySs4nzMVOcRNlAk8JYn8/JCWa7PpBO2N6IBqtjW1OUqzYyGGBCh6DkmYphJeS7yLYWM9AYx2ehsAjMl3X5fDSIWxHQKx8Ei9WS6/SCQ8Ap1jaUu21NKrfujKCgwMmLhG/T3zw0V2EfDUfTYx9iI+17b9ueEDdCFxZ9dK1vCslfZIjd7PdwzuhMSa/Locjse6Yz5XpBHzIi1gV4huG7K/J5n5vyKRFB8+v+m2kqEi7STYX9f31EA1ZDeJnK2r8fj5vMB/3PlBlfVWoaLMxzIxm+jK/IU3vhNxx1F4fbliTo6iR7Pqk6kul+WQYI+TljwCj7wzRyORCpegitanvZ1kJlpN4U5d5YmNGwChMIsx7EohfJYbqDDBQBslzfK1Ru56jxhhyW0Xg1D/7yfk5wb/v0TDR7V7nCu3qGX1AMYQNjo89JOu0kertmAjlskwTRvdZsUxl3OgR/ssi6SSP/7JTE6M6MIhsTFuNB5svETax2GwLJFrebcRacCaPBEXmZnW26nOgIlxeyJM+TEx+cxg/2ZSfBLe zXrTqNuU bgce+sol4c5fnU8FFH0kkO826SpXYUJXNgelgF1PUoHKq1MkKXveh1aE8ZQvB5zNGvqzZuUmo3U/RRf55fxp0iN9/UQbndJgnYlhk/DCbg51NeoqKM1jpO8scJRCWpLICkNg3F7dtVv599HW6qF1xWTbPEAtXchNmUZYMcvNcTtORyabhjNSsIi8EPU6odODGMbMFVgMOUQCvcGe3DTs+SsCOkUL6ceNMNNpVkMWncusRdyrO90JcIdfO+zi4nNhiMk2dHGoN/Zi1K7tXrC/havtdjfg7A/T5sXNhsczdiLCyTejNaNXwhFq9Cltf07cwkTnnSLglK6tgWWA= 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 for hwpoison handling. Signed-off-by: Jane Chu --- mm/memory-failure.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 62133c10fb51..2fa884d8b5a3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2236,6 +2236,13 @@ int memory_failure(unsigned long pfn, int flags) goto unlock_mutex; } + if (hwpoison_filter(p)) { + if (flags & MF_COUNT_INCREASED) + put_page(p); + res = -EOPNOTSUPP; + goto unlock_mutex; + } + try_again: res = try_memory_failure_hugetlb(pfn, flags, &hugetlb); if (hugetlb) @@ -2354,14 +2361,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