From patchwork Thu Jan 12 12:40:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13097896 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 B0305C54EBC for ; Thu, 12 Jan 2023 12:25:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 304088E0002; Thu, 12 Jan 2023 07:25:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B39F8E0001; Thu, 12 Jan 2023 07:25:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17C0D8E0002; Thu, 12 Jan 2023 07:25:35 -0500 (EST) 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 045EE8E0001 for ; Thu, 12 Jan 2023 07:25:35 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D628AA018C for ; Thu, 12 Jan 2023 12:25:34 +0000 (UTC) X-FDA: 80346067788.30.C655E12 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 272F240015 for ; Thu, 12 Jan 2023 12:25:31 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673526333; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=Be4E+mWRG6ZymTCSSnoESKadyO8NUW6VKbJq/iMDUxk=; b=fBwWP7jbxrCr4j3MBCs4qKBS+D9kYOnFcxnoi3NmH+VNw+s7dWxeMHZJsS2XGAwdm1CJfA NC2IHQRROK7pTHYKBVuYtfXPrBWu7XZoCrtQKoa6MjaJGMiCnAXmmUbLhbLhpnJ1E4NRrh oVbp8vMTgckMvUZNotEs4BAy3sr7me8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673526333; a=rsa-sha256; cv=none; b=0OHUmmUM1cpdaejn6cxAYJEfe0IoAW+HdwCCavU/cuLrZVg9QFiBtqiosSKVz9PSwtAPq1 wsJs6E8NH6ln9UFoAeZuEq7i2LBpCz8PDgyjHy0zwXLoi8H5jmJU3JRBVLs8LmOb9PCw5g oQUVCi//bycLu7jmizyX8V1Swx4Sax4= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Nt3d30sZ6zJrKC; Thu, 12 Jan 2023 20:24:07 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 12 Jan 2023 20:25:25 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , Kefeng Wang Subject: [PATCH -next] mm: madvise: use vm_normal_folio() in madvise_free_pte_range() Date: Thu, 12 Jan 2023 20:40:28 +0800 Message-ID: <20230112124028.16964-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 272F240015 X-Rspam-User: X-Stat-Signature: z9pefpgc5ihumf5jhj5fwhzbkgwnfb8f X-HE-Tag: 1673526331-958449 X-HE-Meta: U2FsdGVkX18lcH2k5NL/aKOgM5lGEAKyAnoxM/5paVQSYv+YH20d3j1N/ZilF/e4VyTZlKJyIzMflNGHggk+hG3+WyY7E1bArSJa0VkUtLIKbES7H21U6Ry2N8J7oYKL81VIwVQM53czDVXaOzRhHiOAgPGFRb0bj0MXrJlyleSfbOiwdt0KtxTBW8CkD3b76YkqTwZj0WzM+bdYgl01FWLPJ1m/hg2OvvoD5roiFGO5LjiCUOYqjpiyGuNdMgg6khlKZUV5HffuDIahnYrPBVM9O4s/DcKAvV0sCcIrLFViOAfqA+p3Kdhpq61nGX2pivc2FkLOZVNbVMtMjfFjaCNyl0dxOYLQsf7EbJUBhqWiMVsYrIs7vEk1mhuhktklif05ZCImOL3fcZXsf41MoKLrD5ex0tqfUE4iXpnMdX0jhzHrQM7lo7Jy1NADEwwh8FwnkmcvPnK8l1TWAsYIsiCq83xnhjYiSwoR5WJ41E2qrDq8ogrDrT0+1GtsrqOVQ/mCRr2T629X56+TvCGfy97s5XdmfhHUcf7PLwnpFuiLKtupwphHw69zidEvz8VWaUQWbn3Zppo6FfsUxiK/U2v663ehhEtJFkMWA3V+YF5URZFENH5GLE/qVlU3QHDh6lcVLqHcgj6fRr9Wu7DraFUnER0eGJ0yGXG7I728K2A8qVJaPxwQBV/yz/p5hcA6uhMFohJsrkJhRY25zgNGb2Nt7Hg94kICNqp57m957/Ws/UXvbofe3SAqB2eda1XQH8njbx/py7Nf6b8K+FEkF84CGdW0K+MgGeIBnACy5yXr4iZHDiFPTeoYzEiBNogwhpWcJ4SGtRMYVXtkEmV5hcSnCSmY5TagTcmZ9xFng5z8L2VfbXG7iI+Y+EQRbl+Ntxu+BBKbAUXfKRTrgQzUsculy0NzZXmDH79bpYL90KI3e/+WVu1Bu4De82oUkfa/WzzCzZtmCuftsDeVp34 pz2eAPax 7J9BT 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: There is already a vm_normal_folio(), use it to make madvise_free_pte_range() only use a folio. Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) --- mm/madvise.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 4561aaa0e46c..7931d2649de1 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -614,7 +614,6 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, spinlock_t *ptl; pte_t *orig_pte, *pte, ptent; struct folio *folio; - struct page *page; int nr_swap = 0; unsigned long next; @@ -655,10 +654,9 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, continue; } - page = vm_normal_page(vma, addr, ptent); - if (!page || is_zone_device_page(page)) + folio = vm_normal_folio(vma, addr, ptent); + if (!folio || folio_is_zone_device(folio)) continue; - folio = page_folio(page); /* * If pmd isn't transhuge but the folio is large and