From patchwork Fri Nov 10 03:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13452058 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 A53F9C4167D for ; Fri, 10 Nov 2023 03:33:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0005F4401BE; Thu, 9 Nov 2023 22:33:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF2BF4401BC; Thu, 9 Nov 2023 22:33:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE1444401BE; Thu, 9 Nov 2023 22:33:56 -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 D02064401BC for ; Thu, 9 Nov 2023 22:33:56 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A6AA8A03DD for ; Fri, 10 Nov 2023 03:33:56 +0000 (UTC) X-FDA: 81440625672.25.83AEF6F Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf08.hostedemail.com (Postfix) with ESMTP id 50892160009 for ; Fri, 10 Nov 2023 03:33:53 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1699587235; 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=yLmVQ9KLbgFtHt55SBzSQPM0B7D9zMqtHQVIyqdaEig=; b=K0DjXw0yYh+f6JHlfLsGiDI/pRT/I7NHfxueezTpX4GiZ+r2lEu2D7pDhUOKAcHg37NSr9 VKGHnKWWttYLoeDzEM4rjSCbWRooAJYF2Hzn521oA0BZdj7XCpqjQQiYEqtklgUDMwQxs0 nunUvnV33NZewnEoYE+pUkHGV6ul7fw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1699587235; a=rsa-sha256; cv=none; b=teMPKn0EoFUi5Kq6KOgDhsvJH2PkvW4K6+x+pFvPnRCt+V0uOC7CxP23brg0+UK2/E4XsW 5bfvYBK73YIcmGAaDwN96APmteZVrI2A7aY6SiqSy/JzD8rwaLCjyS7rttTk+bpMyBnsfu 1X7Qf2frbDekPvb/Hqi9roFQl595HtE= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SRPYW5dvJzWhCv; Fri, 10 Nov 2023 11:33:35 +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, 10 Nov 2023 11:33:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 6/7] mm: task_mmu: use a folio in clear_refs_pte_range() Date: Fri, 10 Nov 2023 11:33:23 +0800 Message-ID: <20231110033324.2455523-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 50892160009 X-Stat-Signature: mkob6m7o3gibtd8f7hydyndx6emmmmbf X-Rspam-User: X-HE-Tag: 1699587233-437845 X-HE-Meta: U2FsdGVkX18Fj+wyLYBkvsMe16KxGM6/zMYAps2S7J9XPu5uN/STI1V6mMhAClWswp2ge7GPiDC6FT9Et0ft1knIlgxfhrX0s2ImyMcJNO3n3/Uv2RdkaFhtbpIv6sYNBSRqU618+UmYbY1R59T3YO+Vi1CZI2jcDcE3qRmNnH1LolvdcZ4OcxM6lL24ZC774PXUaAUDtWP9h3tuM9hRyXkNS4xvSQU6Z93rRu/IzjTQ3UWsfdsD8BRf5qBYKy5hPoFRqtr0Xs8e9EhVg2hlt3bG35Fd3tszldCy9ElE2RZUIjzgnt//+ppD7SstG+Ag7rcrUoK1600iYBiYGOvUgHmukuva4WE2lvvGUc6xoN1koSsgdfc7EAo7/keqySB2/MxrH16subVLUEF+Y305Iuzi/inZlesMRDivJfKlvSPdBN4KKo0Jde7K51YV5X2JauTNQKhYPLZ9QmnAVZOOUMxftzFnn50+OBZiHHLm78Dg13/7NbUUAFDNtlzvSWMG/UnYOXYpvW0ZIum5ge2fQmWtuuO9TZYp5Wg3OaNyYftkwhJolk9x+vkY43c2V0pg+U4snOIT8d81mzkQa5on2mMFKlQ/aLklY3Ra2QxEH7VgAGdtSuzXwUkh6HA12cpBm6PGa29o6/LQ3PNokyNxqu7o41Wsrp+ZYAUxTF5Tsbi3Sf9gA0kRyqMLfeLCeGCNvaDoa2KVwVU0gOLQmc+Oa5a/a/91D6FFShuQ+yE6QDVNWHhd8hA17Yld4BF2VISKiy94l0MkMvrtVI9eRwkkHY/q3xrkNjjjN++0GJGjw/ferT6cJf4gYFtR3h9ol2QZckso6fvPSuIT0GSeKeYJ7XK8ItXqoA9K8wcTd0cBn5aegY6Cp1tdqB62sWLgZ2VP9wNFQnUCCFZOvSbaIHjAmh3n9oW8B1Y9FzYfY0tSd/JBCXjQbalAhiSqK9zDu5QQ0KNfJiFwRV8E1xLxyuJ fJj1O4KH MhSJYFyuPN/ElV9W2527/hCatF5n/Qnargx+32874eiGJyReOF+qxp/qE9qpIHvLWo0wtkLVrkFWsc2mu5cNACivd9Wg5DYaezx4l8Kt8eHwLNBi4p2raUAnwRlsvamsKdhWxnvPTO68VQBoGEj/mFMlcXPMblRGvE6o0+Xzc+l0Lo619PXCpOa7TwD0GWugF8vHA 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 fe15f99a4908..740d5c4fa33c 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();