From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <willy@infradead.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <ying.huang@intel.com>,
<david@redhat.com>, Zi Yan <ziy@nvidia.com>,
Mike Kravetz <mike.kravetz@oracle.com>, <hughd@google.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>
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 [thread overview]
Message-ID: <20230918103213.4166210-7-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20230918103213.4166210-1-wangkefeng.wang@huawei.com>
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 <wangkefeng.wang@huawei.com>
---
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;
--
2.27.0
next prev parent reply other threads:[~2023-09-18 10:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 10:32 [PATCH 0/6] mm: convert numa balancing functions to use a folio Kefeng Wang
2023-09-18 10:32 ` [PATCH 1/6] sched/numa, mm: make numa migrate functions to take " Kefeng Wang
2023-09-20 3:05 ` Huang, Ying
2023-09-20 7:57 ` Kefeng Wang
2023-09-18 10:32 ` [PATCH 2/6] mm: mempolicy: make mpol_misplaced() " Kefeng Wang
2023-09-18 10:32 ` [PATCH 3/6] mm: memory: make numa_migrate_prep() " Kefeng Wang
2023-09-18 10:32 ` [PATCH 4/6] mm: memory: use a folio in do_numa_page() Kefeng Wang
2023-09-18 10:32 ` [PATCH 5/6] mm: memory: add vm_normal_pmd_folio() Kefeng Wang
2023-09-20 3:12 ` Huang, Ying
2023-09-20 8:07 ` Kefeng Wang
2023-09-18 10:32 ` Kefeng Wang [this message]
2023-09-18 12:57 ` [PATCH 0/6] mm: convert numa balancing functions to use a folio Matthew Wilcox
2023-09-18 23:59 ` Kefeng Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230918103213.4166210-7-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox