From patchwork Fri Oct 13 08:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13420531 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 F053ECDB484 for ; Fri, 13 Oct 2023 08:59:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C96DD8E001B; Fri, 13 Oct 2023 04:58:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C20D48E0018; Fri, 13 Oct 2023 04:58:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A24DA8E001B; Fri, 13 Oct 2023 04:58:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 89EEE8E0018 for ; Fri, 13 Oct 2023 04:58:48 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5DE7B1201B7 for ; Fri, 13 Oct 2023 08:58:48 +0000 (UTC) X-FDA: 81339837936.14.9E79568 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf21.hostedemail.com (Postfix) with ESMTP id AF77C1C0019 for ; Fri, 13 Oct 2023 08:58:45 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1697187526; 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=IDFEY0yIS2sDy4+6Kv+KQSBp12SmVIAK2/oLPxAuO2qxGtL6MRcQaRqAxQv5Iz3HEDnrvp j6Ga5g+eFK2sji9GvALHOqMSl6xSBQp0+RiT751z94a5cJ71LJ2cj4a4as9sNIJchz8z/0 VCwrslvKMAJwOGVRvDblRGm0TbmciGE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697187526; a=rsa-sha256; cv=none; b=tJ3uxC0RSDJx+93OCkTF10tNRka8z1jY28rUigFrb1VqZr3+VSAxA4rVBq5jU/AAaHcVad TgVHLj349IgdM4c7fF9DcC2iIUD0A2X8a59IgnHLPOYkK4qaescj+CUm6rmt6qTNDV8GYd /adKexgtmQga9LFEqiBMurPxSvBuhm0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com 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 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-Rspamd-Queue-Id: AF77C1C0019 X-Rspam-User: X-Stat-Signature: stm8grg6wanask3mw3kmy4sbhqwxji6p X-Rspamd-Server: rspam03 X-HE-Tag: 1697187525-774262 X-HE-Meta: U2FsdGVkX19+OG5+FQxoDgl/ken/ipIH4pTLSz0r5C+xBEQtxxJLk2COd1vNTLuZqYF1KUmTHSoApX8iY/v5w9LSvqclHI+CteuwP5q68/EdYIkPkDA4T/ZbKGwAkB31of4fqzuWQROV3GRcZ28/SxUcSH00PDQDyneYqsACeYFd4Bd2cKHjRkFtLdKRjb8R8nn5zzKSB9P355VcHUtjuMxtZkaj0lOWAKwzDzc7WJBoJduAHs1B+pYqq8BNMT7vlio0ogAqDzpAigBcaR32ENLjsjML0g3LtuGY0x/Jmzbu3+2G0XRedpTUt2vPAzm6SPOONmAUnK06SjlgFuBg1Qh3O8Nn5PtPpj/T0W3C2X1EBq4VgzR2QfeVi+7BaB/MFTaPImr+gy/Kn0ytIwTRXvHCYV1KAtpTlzx94EK4UYvf40PehGXMciSvuxIMDAPTSSJCHW5jb9DQBbNV4BVHtxngQ5rhIEPWX84Bynrq9GiWruI9jM3zCRVw/alQ9WyFuotbMPi9cz0H8iZDs0UQUvPEXJmtFtGJIcfxljoKmQWULw0cawPMq9eI0Ol0JobPdwdlovyl8KrqKkQ0zeDSDOU8oQZ/HfNPJqVJHdtf1oVK9aicrDM7C4hzs1r8gCZdw5hKoF+Go0lTiABngka2ZzCx5ykuvsBTRJd64zqadwx+V53mzhKGF9OKUSvWzRlttEd6w23HgT4EuwGFKNrBCkbwfE97RCWlgmK8n/A5Hp7EuWbDB608cLMuo6qzLiu9ZwvtxdETR/i6az6jkkYuvowNYOz4qpAl7NCpzhKCVUlr9aiFs9WfhxiWkKGJrTVLXTcNWI2JHxwzRW8NMUclYRbHGyqllyMZDIfQlL075teYBtbmrk6DBhMDUAHcK2QDe4F8cSd3AksTerPZ+XBdiQdYNapKBHNQOT7dZUmaXrhw9xPCbjgvbgW3K5/iimNW5er/rsSvVVoz8EcjVNy VoBYnRau V0LehxuAxdA11b5sIw3P4vn+KWDiwJ6ZabuPhi+aF9CSTIK44Gu6rRvrqqZa4Ro17bLTuG1fZ9XVfhASsReNZPBx2+vb9g4IkbwX/SAIqVrd4plJdUfPf/zMSlHnra9QtCXRW96fJafjsUdWKXz+k+rp2yQKzeYkpNUqUWLpUy5KA4QiYLdOpbScRmUU+q7ojIw8fnlRo8no8g2k= 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