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: 161185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855326vqu; Fri, 3 Nov 2023 00:29:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLRUdrbO5mF6AOCumiz/ft09C1C2ZxLxBHz25S5/g7dGeLi0k1nnuSiqpY3xYttvPNNcp8 X-Received: by 2002:a17:90b:1a92:b0:280:963d:9c5 with SMTP id ng18-20020a17090b1a9200b00280963d09c5mr2573213pjb.21.1698996578425; Fri, 03 Nov 2023 00:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996578; cv=none; d=google.com; s=arc-20160816; b=ktuUCGeWyd12QgBBpQuDx3KyOlyFwHHeTsCXM2rfaKKPZuf+NAAX/sbVAn/0AsZOG4 EBnn/DcqQX97Wk1nyzRxkcjX//pefEwK7v6bbQYhnkt4leKeiF0cn45Y5CPesk7KfrOS H95nf2UCqZQxtON5gSCrTwt9SjR23HMylCAaJgRqNCj8WW3ZIg3yLERkRE3VX4FgROfr x5EEzU7iKRgQFhoBCl64g2x0Jd3ZkFLKHK0UoDrKywSUa7J0j1uw7/nnYBUyXPDmMTSp 3zsd0JBD9LtD9P15K8egSPDu2pPop2KXnx5GHke3Tlf6Jq4ZkJow/uwf9M1x/K/SKipf Da8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8hChM+nSnnRVSf3gsBcEIPIrRk98k1bA3SQNacWoQLo=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=IYwhbFEnM/bo3j+nkAsjSSVKU0tq8VzkJMNGIp2SY0RR58PWc32zIpvt9mQQnv161z 7PcbJ9DtCHHmGFA2c8IMYUNI4J0R/USDu7kzG9lgYoAnFmgnM6ddkXNWrMsgj8DoAsED HNOTp9Xm0pdMZMjLO9JzZY/lAlVpGq6GQwURd/SoORwK53dLUO4wyRN5bCOs/ZOuRF18 iyE3YsvDP6jCgxxdd6AMEmDVdqLF4D5vurbg2T1ksBC1gLk9/pR60XANjUT3IVSXvb0I ARUMFYNajOOMPljA7hVtj1fhOcBtEOEEKUWEb3psVHNKmCKUUsyaAg/271z0ipbAQ8Oi 5P7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c3-20020a17090abf0300b00274d3f62044si1108355pjs.111.2023.11.03.00.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 571D8825F178; Fri, 3 Nov 2023 00:29:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346151AbjKCH3Y (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233105AbjKCH3P (ORCPT ); Fri, 3 Nov 2023 03:29:15 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 649EAD43; Fri, 3 Nov 2023 00:29:12 -0700 (PDT) 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527036423835368 X-GMAIL-MSGID: 1781527036423835368 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();