Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp820021rdg; Fri, 13 Oct 2023 01:59:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYk4i6H4uuY8WCpZVXFlPp06eykiRSkN2m98E///XhYIxPq1NJBSHzhiiF65182w21WqRt X-Received: by 2002:a05:6a21:6d99:b0:173:f8c9:a776 with SMTP id wl25-20020a056a216d9900b00173f8c9a776mr7079540pzb.26.1697187559794; Fri, 13 Oct 2023 01:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697187559; cv=none; d=google.com; s=arc-20160816; b=DVmt1d4hZZ6V3jf/eQdym3Lw627+vtRLDylyRxo9pTwgIcT8Spxr1Lp7a/EIOsaJ6f bgcZDDLMwoqmneTb5N3ElJ7Vhsz0q+HJc+BLnIiAd2x6A0DniCTzTCKa9OkxTXAunqfm nGStKav3jknIqcjiwa/usIqn1+QyuqOCc+zUeyQjAqbcMuYG0LlMA8KAPuPo+QSomUmi JdOwJofs07yQ2Opq9Ub9UrNxoM/e/cWFJsksTAOCtQJn3pw/gYxSxz67xnP2xczad21W RQhRyKzaqVwwn/X5/ywT+Pc3cvW7EuJzOTvJTHMykG18bVD0u2B9Vpy2DuAUewEYTxnm qP4g== 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=ms2pbGLo7mG2bKDY2JPOUHEMK8SMoQKLkUCNA44AIfg=; fh=Q+Hibf2y+6rOlBpt37Lm5i0wTMmcQsnxMBqJTtvbZCs=; b=Hw7wy6ElgZmkObaVmjYErHzs/IHM/bRedLdUuv7v1Gnk4RaNeOTgajGOX68+pumeml kXE0o/fxlIV1dMYIRKD2tjoGPnWh9jPLjBCFHRLVmAQfPVCnr8uxJ3Syl4+acolT2+t8 8b2OZKMcpypPu1A/Xo9fmMLyhEryv5lBDzWHzJRc3hOvxy9lYsS6A20hm/HSypEbgHsq TSOLnRYZtgTJp+AomLequ5wsS3b4rvXi3snQqQQLokdjX9NGKX6ci/i5ga2cYKTazrDZ /YIGYvtfrxj6zAyVhOBWECRpLbATZETXALmapSiCZGzzQGulWhOi58Dvq6j4a5Wyx9Uk 0p5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id b5-20020a170903228500b001c57c952622si2784763plh.446.2023.10.13.01.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:59:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id DD47F839D9E1; Fri, 13 Oct 2023 01:59:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231264AbjJMI65 (ORCPT + 99 others); Fri, 13 Oct 2023 04:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbjJMI6b (ORCPT ); Fri, 13 Oct 2023 04:58:31 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5FB1B8 for ; Fri, 13 Oct 2023 01:58:28 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S6L0k0jsvzLqSx; Fri, 13 Oct 2023 16:54:30 +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, 13 Oct 2023 16:58:26 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Kefeng Wang Subject: [PATCH -next v2 10/19] mm: huge_memory: use a folio in change_huge_pmd() Date: Fri, 13 Oct 2023 16:55:54 +0800 Message-ID: <20231013085603.1227349-11-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231013085603.1227349-1-wangkefeng.wang@huawei.com> References: <20231013085603.1227349-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 13 Oct 2023 01:59:14 -0700 (PDT) Use a folio in change_huge_pmd(), which helps to remove last xchg_page_access_time() caller. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 5455dfe4c3c7..f01f345141da 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1856,7 +1856,7 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (is_swap_pmd(*pmd)) { swp_entry_t entry = pmd_to_swp_entry(*pmd); - struct page *page = pfn_swap_entry_to_page(entry); + struct folio *folio = page_folio(pfn_swap_entry_to_page(entry)); pmd_t newpmd; VM_BUG_ON(!is_pmd_migration_entry(*pmd)); @@ -1865,7 +1865,7 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, * A protection check is difficult so * just be safe and disable write */ - if (PageAnon(page)) + if (folio_test_anon(folio)) entry = make_readable_exclusive_migration_entry(swp_offset(entry)); else entry = make_readable_migration_entry(swp_offset(entry)); @@ -1887,7 +1887,7 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, #endif if (prot_numa) { - struct page *page; + struct folio *folio; bool toptier; /* * Avoid trapping faults against the zero page. The read-only @@ -1900,8 +1900,8 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (pmd_protnone(*pmd)) goto unlock; - page = pmd_page(*pmd); - toptier = node_is_toptier(page_to_nid(page)); + folio = page_folio(pmd_page(*pmd)); + toptier = node_is_toptier(folio_nid(folio)); /* * Skip scanning top tier node if normal numa * balancing is disabled @@ -1912,7 +1912,8 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING && !toptier) - xchg_page_access_time(page, jiffies_to_msecs(jiffies)); + folio_xchg_access_time(folio, + jiffies_to_msecs(jiffies)); } /* * In case prot_numa, we are under mmap_read_lock(mm). It's critical -- 2.27.0