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: 13427172 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 46A6DCDB47E for ; Wed, 18 Oct 2023 14:26:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C728F8D015C; Wed, 18 Oct 2023 10:26:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C22B88D0016; Wed, 18 Oct 2023 10:26:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B111F8D015C; Wed, 18 Oct 2023 10:26:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A07768D0016 for ; Wed, 18 Oct 2023 10:26:57 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 50E57802D7 for ; Wed, 18 Oct 2023 14:26:57 +0000 (UTC) X-FDA: 81358808874.29.E2CABE8 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf26.hostedemail.com (Postfix) with ESMTP id 110B5140021 for ; Wed, 18 Oct 2023 14:26:44 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697639215; 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=ms2pbGLo7mG2bKDY2JPOUHEMK8SMoQKLkUCNA44AIfg=; b=feiwDez5V130mnsTe/0rKrXi6oqeB6WF7mgAeBfrp2Wge5ot5oizeAGAfK7wjO5fdgYUl3 VqePJtTCaWaHT1yYIAaZOiaMBTEYXquFNsFBwMlH4aqX63nqXkT6BgaxoPpjFTeT39vzW8 7YKfhdog++LJDOWVcksiqQf6091uuBc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697639215; a=rsa-sha256; cv=none; b=qrTjMLT6oV1qa6rJEZAov6SyHTGcKvjBeN316hUsyCmAE3/mvEvaKkB0axgvsHt9tT2JPt y3DkskGqkgoX+KFxqGoRvTfpxTmsq1rW6TjHGhF0l2uoK/3mP5cmEL63hsTn1JMKIThddX tvK+GXSpw75fUDayeobuweGmjkwRQqs= 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-Rspamd-Queue-Id: 110B5140021 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xfwpe1qw7qrxbwa3czj5bkoszziffgx4 X-HE-Tag: 1697639204-421139 X-HE-Meta: U2FsdGVkX1+IosNz9GOvoYuVV7xs51ToJj8ZhEzaUv9fP4tidkAMeGzOwarVQu95ZoAebxHeBicDFztaGi24kwNLSlbFZUPOIYYj6V1fhLrMas+BBnGXuyJxyFy2mii/11ZCmf2nsBvaBndy43ryWkYr0O3+XCHzgEnoOknWmokcLg4zpXmPVSYnq2ta3wIYorepgAaLOl+3l0Ljrn72aPETKG8htENw3zJvZ3dQnVHhxNBuDSPd7ud6K2l3m4cIrSoGSW0e6R1LdYb7u44YTY24rwSx4uiu+MrtN/Z/vWzzPLhrYHNbczbUXF2QzjKJBjfeaJW9xCjD1wfe1wul/KmhD5+mVN4R6xinIIk+Itc+DFJVbk1p3YsL5a6WyuKeAZe9gV/aMY54avpQQa0A6L+ggQSmdybWrSgfDAZ7kCSQH5nGMQFD6NxL32TVRvduLCCfZIThxKm78v1BLX5R4AxF0lGatHNfnok523mwZ9fTsGmxyQ1wT/keMHXeyjEyWfHX2UVanYqdtkGLxxYoPYUr2ciq/ZD2hn3QA3JxXxy9bVI5AtERdY7o8L7K+7xibjQMZ7S6kqLq0wUijgTfKw2VmKWkrzdyzHa3NbFz8IpZs+ZiJlTzlDMHOzOLIr+y5TLY4hRhx4U9rIB1ZYHC96rOcKC6rR/8GL5r0gyxUZ2llqqHMMxfybEMTUy0WhKNwopnEwHzb6gUwhLXd7cf2fHy01Ip0IW8gV/vrDfFO7KyZasrtJHlYcLyg2wxxtl6Jg3SJKDXYLLVnMfJj70Z5GB2BlvMHxHJBkNcB6Xv1DCreCp2VzBdMklH5ErfVFfnFCuyMZnlA4Y8lCEj1XSX3gpjb97F/erHdtNCfflOmnJ74tuegZanpb9NRB20ZWw/yFYQ7AD316mUYJgwJKmEIojQMcJp/uAosYWuYir4gtJFF3ECtDIusLB356xleXuS41o54WflZoldWzblsXF H8QIYUqL J7SBJmATwRNARnEnPWHQ+JorN48hDv+ywUKJxIev33S4PPEMR8vHKJpbBjbKEMF/owegQSVXwJFuQsxmVOgh0smoYFcaZ4RiQO6ysB6ADPWHzIrvYxpVe0NurVf8Pj6sRNPKD76wwQaizpEdF9ltQrxDqPiqbFoOGOLA55iywmpmTuMRXvK45b15N2qKjh5+NqFSFZSc/vtg52TUXHW1clX7y/7/vHZ8F9/6jOpjSBusmBujdJbFuQUgVnFpl1Lj7Yf0XZHNXOSlrCR3bTrvR+fqbsidYySCt26pI 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(), 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