From patchwork Fri Nov 3 07:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444387 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 E05F6C4167D for ; Fri, 3 Nov 2023 07:29:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3367C280014; Fri, 3 Nov 2023 03:29:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E7E1280012; Fri, 3 Nov 2023 03:29:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1132A280014; Fri, 3 Nov 2023 03:29:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F1A45280012 for ; Fri, 3 Nov 2023 03:29:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CAA8514033B for ; Fri, 3 Nov 2023 07:29:18 +0000 (UTC) X-FDA: 81415817196.13.425EACB Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf04.hostedemail.com (Postfix) with ESMTP id 175E14000C for ; Fri, 3 Nov 2023 07:29:15 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698996557; 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:in-reply-to:references:references; bh=8hChM+nSnnRVSf3gsBcEIPIrRk98k1bA3SQNacWoQLo=; b=ICMp9tfAOTH+BVyvRk6RDtyTpPe12HhoMOy8DWeOXeT+wNI3ypU3L1A5qdogeDUUQs8hD0 /l/ne0Z/8D31wkHrNk/coUXIe8MJQL9F5Wo9fRKv8edM0/2UeDq5mqMadw1xnyFtBMr8fu TiZM4GrQ+rq8REUMHfcmzfwLic2B2C0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698996557; a=rsa-sha256; cv=none; b=q7z7PYFuSy91C6oBPG+OEOP1nYq9EfMf35Osa+irV2+4Dm7lPB2uCNbQX6UZOKqLpcijHj Zmro0ERjOhtu3mI8GDUgr4XSxQkfcj2ZZLzOZtmfQ994xcIKLiOj61NO348vvAbMmtpwBy aR0pn8wQUY/wEGUWWtEtmy3EzT1oCyg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMC1W2j3lzMmLh; Fri, 3 Nov 2023 15:24:47 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 15:29:09 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 3/5] mm: task_mmu: use a folio in clear_refs_pte_range() Date: Fri, 3 Nov 2023 15:29:04 +0800 Message-ID: <20231103072906.2000381-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> References: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 175E14000C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: pbrtkzcxwoifd3xzj5ka396g9w9c1zoo X-HE-Tag: 1698996555-412738 X-HE-Meta: U2FsdGVkX18nXZvjjGXpnfflGDCxJ9jgUHvhMpFLoN6rWCwFi1g05uYC2pWgkxFYXAoQXtTgF0cGOJQMH7Tfb6+AcTiaPjs0KGjXqnrMxvRZWu9YIQ4faiJ6NKgPSJ2o2vLCqHFF1u/THJ56VFFdvAqoVJpvYpD7Br0OY/cbaqrp7y5LdAyF4tUo6zbKSs75P3J4fSFwTmQ1astdDX+2y6uyin7GF3WCQTd0o/e9b2zmlcmNWFiWMnyQC3qZ+Av+PNGXpy7yrURieI3eJ1SaRzWu05E10Z1La0ZaSIN0aU65CCivK/RfCyEKplvYiDcsTe2+u8J9QfaeV8im2dCKk+0zA8aXwM1aQ7VI6s+9lPbhtrkXcmT8FKLomE2y929XTuUfj39blVsNrBoTg2BG1pCyY60nNRdHIaUfeIVvoHFmymaExKi7t5yjvmp5SPBC3XBJSA31gUSCfFxOeDlR5wP2btTABealRibPE2gLBPyzdJR13eqJ4O1ibVRWtvA6vBLsscXujMgfnHx+pmimXVteC4TA2PvfTkSC8pt1mZtpe2KQ0lIzrqXmd9VfokEb2zHxQZoVXwan9XMeB9uyH4mrb37M4ies5MUK6xf8WoDfuXbhxiQJrchzVd+bxT+CC2kDdYqM9a+E+62lOd7fmoY7YziyvLxeHTJVejFZj0WuZxiA0bYDasOVI11MCUW7f5447zT1p/i/ZN+gA8ce9RkbcWrLYt5jCCYF2QUIGIuEfykRuz0Daam7oVb+LcjlWpSgJpUixj24Z2/6Jt74yoi5AXsObug7IFj4er8eGLWKTalmNeCvPIZWgL23GUTXYYyUuKQSGtxcvOsnOJXiB6e9W1T8Gy8JJQMhlVSeij5AoXsWz+0u8brgnvoKNdQuxKu5oa28YhrtbY62VHHaqCLfmO6Ljjr6CN6u3oDzbAhrWOMHqVhMbdgCffj5NNUQWbu2C6cEIierR1IDYeZ ZpaWkeu7 rz0Jv3nAGRMxeKWEoegoRVdhX7IULpp9zUQJtM1SQuzU6pXMGu/euP7v38d2c/cdG78I0NA8t9MTMFqN3GApxxyxWyxizNPNlqbew3PpYUX2NP4Gt0iqobGNUBqF6sjZLCkn7kdTwA1IpWsnEoXl8EZLupASjymomU1boQVs2Q2w8ajBNyK2Oc2Vjn/ufto82RG7x 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: Use a folio to save two compound_head() calls in clear_refs_pte_range(). Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5ec06fee1f14..869f6bb89230 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1161,7 +1161,7 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, struct vm_area_struct *vma = walk->vma; pte_t *pte, ptent; spinlock_t *ptl; - struct page *page; + struct folio *folio; ptl = pmd_trans_huge_lock(pmd, vma); if (ptl) { @@ -1173,12 +1173,12 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (!pmd_present(*pmd)) goto out; - page = pmd_page(*pmd); + folio = page_folio(pmd_page(*pmd)); /* Clear accessed and referenced bits. */ pmdp_test_and_clear_young(vma, addr, pmd); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); out: spin_unlock(ptl); return 0; @@ -1200,14 +1200,14 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (!pte_present(ptent)) continue; - page = vm_normal_page(vma, addr, ptent); - if (!page) + folio = vm_normal_folio(vma, addr, ptent); + if (!folio) continue; /* Clear accessed and referenced bits. */ ptep_test_and_clear_young(vma, addr, pte); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); } pte_unmap_unlock(pte - 1, ptl); cond_resched();