From patchwork Tue Sep 26 00:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 144661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1592180vqu; Mon, 25 Sep 2023 18:00:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDG6w6tDxuAy7ZPIIjzk9/DT1sc43HA9MgN2tjXxaWkt+vIdCIvEl0N0oZLf2sMt4Ec7Hn X-Received: by 2002:a05:6a20:1602:b0:15a:4c23:870b with SMTP id l2-20020a056a20160200b0015a4c23870bmr1619302pzj.23.1695690046626; Mon, 25 Sep 2023 18:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695690046; cv=none; d=google.com; s=arc-20160816; b=kevt/faCU2s9U6FjXayHgXMP7clp5k9+DE3P964Yv48bop/mFjV45mif2JrPdxZUW8 vhnLP5BEHPfqaL6n+yypl4xAInYkBs0AyAAB1XzHohcElWpQsLo0dqedpve6LXa15QLn zNEOB+owgLrwWO0ZTH05eDG86kayCODDrgTwQpS0dPCWrOhPUyvDwS8DFW8DYXd9Xx1r X0DHHslETqeDZtelhyq8XOV+HNscmLKCdMaAX5eXzWV+NdHFfUX9NZ6muyLcFOPO6UX9 RGv1m3rj7SdeK3HK5hKzt/P7jtWtFXgmOVimctTxgKoK2zA3V1RYLLtbBM+gKY5VdGAI onRw== 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=xLDhMjCrVSLoYbaa4gzJ4uRL0hqY2r45hKznONkN8B8=; fh=FiTqiBStz9H28Qh/9rW0myzOFac7M9VOPFJTunt8oTE=; b=UTVuFKXocmeF+NctqeEYN1GPuH4GTBmIOMgdW8nUG05JDK2UcAqTZgd7WBdi18jWnF yFOEuhVF637+Tz08VBNUdranIZIyTJ876KVmpEvajTVIzeEdqepovvWVivKaqSaVJKOw 3G+MlWNCpAtbQZvg1IdYrPLrWgRO8bIkdo6nW0ltpDZOovWC1GWbY7SbPmh/89pX9nHK nK1IcJMkxBGpouui8n1+LhswqSYU9FL7xcvUDLRyDYaU0LpA7mE0CiYoT8AZ24vNe9sa ayyFZRZOwr4FPhNf9omUSI/biZFJ7i1nQFuaI/THPdzJAtW8nD0e5MLrzzLqaC3ddA9y fuXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r200-20020a632bd1000000b00578afd89baasi11124817pgr.744.2023.09.25.18.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 18:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 85B4C81FDB9B; Mon, 25 Sep 2023 17:53:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232166AbjIZAx3 (ORCPT + 27 others); Mon, 25 Sep 2023 20:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbjIZAxS (ORCPT ); Mon, 25 Sep 2023 20:53:18 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDDF010E for ; Mon, 25 Sep 2023 17:53:11 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Rvh4c4Mp8z15Mq5; Tue, 26 Sep 2023 08:50:56 +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; Tue, 26 Sep 2023 08:53:09 +0800 From: Kefeng Wang To: Andrew Morton CC: Mike Rapoport , Matthew Wilcox , David Hildenbrand , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 3/9] mm: huge_memory: use a folio in change_huge_pmd() Date: Tue, 26 Sep 2023 08:52:48 +0800 Message-ID: <20230926005254.2861577-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230926005254.2861577-1-wangkefeng.wang@huawei.com> References: <20230926005254.2861577-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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 25 Sep 2023 17:53:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778059886172032331 X-GMAIL-MSGID: 1778059886172032331 Use a folio in change_huge_pmd(), this is in preparation for xchg_page_access_time() to folio conversion. 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 0f93a73115f7..c7efa214add8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1849,7 +1849,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)); @@ -1858,7 +1858,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)); @@ -1880,7 +1880,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 @@ -1893,8 +1893,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 @@ -1905,7 +1905,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)); + xchg_page_access_time(&folio->page, + jiffies_to_msecs(jiffies)); } /* * In case prot_numa, we are under mmap_read_lock(mm). It's critical