From patchwork Mon Sep 18 10:32:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13389378 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 158B4C46CA1 for ; Mon, 18 Sep 2023 10:33:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E39C6B02D9; Mon, 18 Sep 2023 06:33:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96DBE6B02DA; Mon, 18 Sep 2023 06:33:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E6A16B02DB; Mon, 18 Sep 2023 06:33:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6FCDA6B02D9 for ; Mon, 18 Sep 2023 06:33:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 46AA31CA9BD for ; Mon, 18 Sep 2023 10:33:13 +0000 (UTC) X-FDA: 81249355866.26.CE0AEAC Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf04.hostedemail.com (Postfix) with ESMTP id 164C64000C for ; Mon, 18 Sep 2023 10:33:10 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1695033191; 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=o3O6hmLLoJvLAdN2vXw7QU0xANFE3e9WK0chunZ4xxk=; b=KC83zIADjLUIxGrV+vDG2eX0xTSAk1K1ReCiyb4PHs0SRkB7QWwfoFByMA6fiiQm1p0liG VyS65YotlmQdbbZExlXw5lI03AsnDcPH6EbkhBmR6oEHdhuQXiNcPttnydglExPinC6Ele U/178tF1M05sha7pMUO9WZ9ywlAWhhw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1695033191; a=rsa-sha256; cv=none; b=VZHVm6f8hfDCWXCXM29rg8KZw1hgjcr8teqc3dcWAJR/DYYovMIsGnZi8xDdtyQBr9D65W 0FiA+IzfYShMJK4hdIb8IHb3jBAETzj4lZoUR03FgRd3WLI1JCMVKLWhwwAUYEE79RjFnu HSiKMJ6C0TcdTNf0br2//ZxtVs9/CsE= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Rq1KL21nhz15NQY; Mon, 18 Sep 2023 18:30:46 +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; Mon, 18 Sep 2023 18:32:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH 6/6] mm: huge_memory: use a folio in do_huge_pmd_numa_page() Date: Mon, 18 Sep 2023 18:32:13 +0800 Message-ID: <20230918103213.4166210-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230918103213.4166210-1-wangkefeng.wang@huawei.com> References: <20230918103213.4166210-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 164C64000C X-Rspam-User: X-Stat-Signature: qsrjragb6nafpsg9tkp389ynije3ket8 X-Rspamd-Server: rspam01 X-HE-Tag: 1695033190-398841 X-HE-Meta: U2FsdGVkX18jIvzKlMF+35tPixCQ0PBmo6+vo2YpGa4WsV6TeAMePGc6NtmDbRy9vfnjzzcKxFYtT/P0dpm49+9DJTwsdBcjsSRZB4GkDt9DiM4wwYDH2V0UzvnaYJoY2Vtm59fwiIzaDPq10uvIL40tLxyrwVqo8pfg2CFew/+UbiSxCfOvZf6uYmOwRs/lbw8AZJzzqVVpY3Ed7MpOy39eP25atekkMWV8j3LXdMvDhldl8JoNgS+aB7SGfxOKYLWqjz6J8mJEnSdGW301cJlpzgaY6MpJjEHlo0LcfYTQLbg5w0MsnohlDVXUr0ni8hmNy0GG4fSOL19m6pnisaAPpUdsGhNbUD2ZMWoz9DcpAyJ+qdl5bNvfkMAumoAsg9t31oTHK0X6OsxeBA6Y/8oEZFtw19dtrhuiQkkLR2ryOY7SSvZtwsEsgqPipDVLyzMVBXiXv9ldupWgfzi55hj53wY2Q4dELWJuyKpJ1q7YQjprB3VAibqq1JCwzXG5nRUmPNiV9c+2RYPcWNQ1rcasG1wX9X69RwKWSTzfM8j1pzvTiSW5oIOl/9wVdgoRaAGDNtXsOPAaw12CcRG6SHlgubpxKLdchpgWhYfTzV1RT/3cWOnyYxinlZpzHRvSi+x0WDWPyB8NFtQD/uvqGOcCBP/Hkz3/jKLdv/tHNJ894YECAV96BMwTVNCo1xypQfvlKSTP5eZ/hUtWTAhu1/mTvXsJpzO8MDjNtPrVVN7YC38RD9l4TJQgEMlPTRcztFSgvtD4oP5ufnlkFE0bzXwJqhdu489ugEyOQTr0ZbPogWOAr53JWOiwzrVl0dIzGQUtoMk7eOi4qLYC41oNBlfBuN6szAofwW11YalUPcTp+Y+qs24Ay/LZG3VU7h1Cvgptnz8XWuJHIVjfWr4Bo1mrWKGx1innvuivW0HnBdTKXoNB95dFiIpUuYOFHduo2ttrz1JuE/vylf4kYGq NQckrgY3 TkNsck+A2YQ/969OFGzygItVWtNs9CJymyzJIoQb+KVB6Yk6+MMG7QukH9cz64AiMRiUxL/27u2naX22nK2ScHUgA5LwwixoNhPmHb4z6h9GSkl9OMl6aIaLnynmn9eWEZUpxe3z34VH6C3CGXCN4JT/9Srn5HJhIyzKXaWDBzKt2wouWhap+xCoMc+x8L293zhR/ 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 do_huge_pmd_numa_page(), reduce three page_folio() calls to one, no functional change intended. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3e34a48fbdd8..5c015ca40fea 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1517,9 +1517,9 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; pmd_t oldpmd = vmf->orig_pmd; pmd_t pmd; - struct page *page; + struct folio *folio; unsigned long haddr = vmf->address & HPAGE_PMD_MASK; - int page_nid = NUMA_NO_NODE; + int nid = NUMA_NO_NODE; int target_nid, last_cpupid = (-1 & LAST_CPUPID_MASK); bool migrated = false, writable = false; int flags = 0; @@ -1541,36 +1541,35 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) can_change_pmd_writable(vma, vmf->address, pmd)) writable = true; - page = vm_normal_page_pmd(vma, haddr, pmd); - if (!page) + folio = vm_normal_pmd_folio(vma, haddr, pmd); + if (!folio) goto out_map; /* See similar comment in do_numa_page for explanation */ if (!writable) flags |= TNF_NO_GROUP; - page_nid = page_to_nid(page); + nid = folio_nid(folio); /* * For memory tiering mode, cpupid of slow memory page is used * to record page access time. So use default value. */ - if (node_is_toptier(page_nid)) - last_cpupid = page_cpupid_last(page); - target_nid = numa_migrate_prep(page_folio(page), vma, haddr, page_nid, - &flags); + if (node_is_toptier(nid)) + last_cpupid = page_cpupid_last(&folio->page); + target_nid = numa_migrate_prep(folio, vma, haddr, nid, &flags); if (target_nid == NUMA_NO_NODE) { - put_page(page); + folio_put(folio); goto out_map; } spin_unlock(vmf->ptl); writable = false; - migrated = migrate_misplaced_folio(page_folio(page), vma, target_nid); + migrated = migrate_misplaced_folio(folio, vma, target_nid); if (migrated) { flags |= TNF_MIGRATED; - page_nid = target_nid; + nid = target_nid; } else { flags |= TNF_MIGRATE_FAIL; vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); @@ -1582,9 +1581,8 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) } out: - if (page_nid != NUMA_NO_NODE) - task_numa_fault(last_cpupid, page_nid, HPAGE_PMD_NR, - flags); + if (nid != NUMA_NO_NODE) + task_numa_fault(last_cpupid, nid, HPAGE_PMD_NR, flags); return 0;