From patchwork Tue Oct 10 06:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414853 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 C65AACD68F1 for ; Tue, 10 Oct 2023 06:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B6746B01F8; Tue, 10 Oct 2023 02:47:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 267B98D006D; Tue, 10 Oct 2023 02:47:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E0F96B01FB; Tue, 10 Oct 2023 02:47:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EB0B66B01F8 for ; Tue, 10 Oct 2023 02:47:18 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B9FBC120187 for ; Tue, 10 Oct 2023 06:47:18 +0000 (UTC) X-FDA: 81328620156.06.258907B Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf15.hostedemail.com (Postfix) with ESMTP id 83BFCA001C for ; Tue, 10 Oct 2023 06:47:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696920437; a=rsa-sha256; cv=none; b=mhloFbfGuChHtjEnSKSvbVExi6q0qDLU7qdTfebsSjeHVUCxdcKQwzhOI6UQluLdkRoEyq lF8fi7YcGqfNU80rGCCieR1BY534j9OItXmUsbv7B+rGmrtkwGr8BNFx68wpgipyE+eFE2 Dc+7nbpsKlOjcf6cxD/3sg4VigngEpo= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696920437; 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=D2Q+I9WNfmiKTucK67xuyjIk0gAn9DIZRjRlHWYIALk=; b=lnsDbCcQagdgSJq4fwyivEkkJuLvDE0+aBv4P0cPCLD9k03mjBJcPvcWSLiEExtKQhPV/x BQPRqUSIkHEDhoctc9rD1R5qPFmSkqg1rdUcS9Xb3hQ6SVa6tqtU32Ubc982n0z4JhxuZp W1ppE83NtdZbCVuKl+mSpu8Qsn7rAMU= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4S4RDZ077WzkY36; Tue, 10 Oct 2023 14:43:10 +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, 10 Oct 2023 14:47:06 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 3/7] mm: huge_memory: use a folio in change_huge_pmd() Date: Tue, 10 Oct 2023 14:45:40 +0800 Message-ID: <20231010064544.4162286-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 83BFCA001C X-Stat-Signature: 88kxy87uisw5zsy78xg5yboi4fxmipqx X-HE-Tag: 1696920436-31342 X-HE-Meta: U2FsdGVkX19pW7MYoRNjRGTcGyrClCKaAP9/aZpl3eCNAf81Q/XNSdsnd8giDc98S/gAbgdvS8pF1M3mT7zf+CkYzskPCqhM9JIPxxZ01uqtlhBDaB8s46w1ARZaGbzgoATlkzSLtXExDM5HPo/I1wLIYtwETNpJmk8bAaetPWsxeu6pGGBqMn+GGDMinTefHMui+2PuGtri76Kx4SNrJ8KlNmWow5vC2Fz8+ad73+MrQ9u7Mnf8NRpIPo4kvjeXx5sCu/FO3lc6y9gj2YjnayJZ5j3WzAa72gTbXmD4oVvpto7Cntah/mtiriqB+nI8vuXEHWXXVa5WY5NR3AJPV+xQzajVIO2HIyjj40uOaC5Wm4Oj17b3EU6fYWpb6W43Zq6OuzMdbomuidDZ2O+bDS7Qp/aknEUf73pNjHf1n5aS1idi83HKkdV3b7Hj8U7DLOYuAlxDGA6gQSerdgndMMe01YQTB2Xd8is6RaNGTP8Qp3GDCLvnitK+A+paBiyWjjgCz7KD39rn1wFCki6+tPrm/Kam5BAV0e/ZsFb6cDTxhcobz6BUrKg2lynSQ/5pBf3yVdUJAvmfU5H/mWf9aoJUqn3Fq0bTq5/cLx2WZrsxylvRPunXpGeVsXVJBSnPfls8wTltNrmWsTce3jCy3zD75/XUT3zcWi3cHyo1/9NR5ilSbrwYOlq8ji4FiglJV1oiG3k2NS2noGgz1PxgazS3Rfil14Olfv2ydOCB+D8NOUCcIE/C7KsQQiHs9h5/DPsGh7Zx3HxPzzv8heTAwZwMHD6hROS7FqLktOUT9kPYGN81m5E00VrUi+NznRQaNE/x6EKnElki4Tkgp7ZDNRCd2a04vX4z5tcuwPeWAwCyxzt1kTPrJDb0DD7mRP+Z95I7Km32Oh2Bx0VX5HTj90fGQATJ58PMJDcshz7l7kJiNmbQ2sxnpm2ceOdFKfmv1ybdTQUfBWWj0ENhgzu 3TJQsnxB jCdLXNs5ftBCwodu9El9/OSxtaUf+s3y3k/7n4Dwe+3s+GDdI8w8vyTmRaFzJspWz4GZ0hv9PNgLdvXB4hTaLGwdHUmoWkzqmAb+jc0aVLZ0zqk370XYMveng1GG8ki3u5XPa6YkX97ZXNhnXvZTqVLL1eg1z9gteWEsHdYFb8nGmKdQflLtvxlk2aqR5IGMWt0SA 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: 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 c9cbcbf6697e..344c8db904e1 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)); + xchg_page_access_time(&folio->page, + jiffies_to_msecs(jiffies)); } /* * In case prot_numa, we are under mmap_read_lock(mm). It's critical