From patchwork Wed Oct 18 14:07:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 154897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4818302vqb; Wed, 18 Oct 2023 07:10:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFv3fK77BIgWnUNSIF/14rDNSoJu686FrJ4pnPT+0Skr6ekAXjUxfs0UBllznBbiGI00DE+ X-Received: by 2002:a05:6a00:1c92:b0:690:d0d4:6fb0 with SMTP id y18-20020a056a001c9200b00690d0d46fb0mr5428821pfw.3.1697638202389; Wed, 18 Oct 2023 07:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697638202; cv=none; d=google.com; s=arc-20160816; b=iaUFkG7r0AagpjCmJS7skEgpoXO0MyTtKbSiBsP/9McIrMKocAshDVWEItCH8QBOmt olkTnzDdmzo7VPN743rw2uJbM/KZJMi0HIElz+RYXBoW0ilmavG6jpdDRja/68fA1eu2 lXnE+9pSaLn3JdcC8Pkhyn0ZesPudFgChxJuUj4rSQOZfEu5NLJjSgQXOnJJLHWYT4Lp NzSH8+5m2c9cNOhMkwn16izbKsz1dJNlH+b/IcYiCMMmvGHKuQSlR8mrO+8vqmmIQaX3 UXHCFwl8azGEGoid9e13M3MP8UYyg4yMguTQOfgDmCZA+v/Rz3iO18fL2f/n+mYjUUul /b8g== 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=It25NxDJ1GQwku4IzV4a2HWg5jbxh+f5OlakU3rQa8JgMb7d6pxOsAdBX3HPoqPsHq y57g7IvuxuiQnQ1RHQ1Fs6VAwDFh0F3fvmbcK5W06N3nCGF5zXiQPrk2rn/5N6D74WjZ t1/ElYULhRlU6WxloEmxWsZSl6l7RnUicc5Nf74sdtoGBsJQtzJ4tmGYWjtUdiWpluMK m9ltYG2dv5ZKga5Vxren1TRbdfsuW8kDUbnkqoVjflsfpY9kLtWHX0dE4BKEzEPwpRJy ZJc4lCLMIFVFeUfYO8k09AoLI4eMDmqohwGS7UVBHBE41nFt0vvIKrYFYviU90+T80Qv +IHQ== 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:5 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. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id by3-20020a056a02058300b00578b9757214si2450949pgb.163.2023.10.18.07.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 07:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 30448802940E; Wed, 18 Oct 2023 07:09:56 -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 S1344901AbjJROJY (ORCPT + 23 others); Wed, 18 Oct 2023 10:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344856AbjJROJK (ORCPT ); Wed, 18 Oct 2023 10:09:10 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE5B095 for ; Wed, 18 Oct 2023 07:09:07 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9Xdw4TSzzvQ9v; Wed, 18 Oct 2023 22:04:20 +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; Wed, 18 Oct 2023 22:09:04 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Kefeng Wang Subject: [PATCH v3 10/19] mm: huge_memory: use a folio in change_huge_pmd() Date: Wed, 18 Oct 2023 22:07:57 +0800 Message-ID: <20231018140806.2783514-11-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> References: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 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]); Wed, 18 Oct 2023 07:09:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780102675711861792 X-GMAIL-MSGID: 1780102675711861792 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