Skip to content

Commit 6b0ed7b

Browse files
Baolin Wangakpm00
Baolin Wang
authored andcommitted
mm: factor out the numa mapping rebuilding into a new helper
Patch series "support multi-size THP numa balancing", v2. This patchset tries to support mTHP numa balancing, as a simple solution to start, the NUMA balancing algorithm for mTHP will follow the THP strategy as the basic support. Please find details in each patch. This patch (of 2): To support large folio's numa balancing, factor out the numa mapping rebuilding into a new helper as a preparation. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/8bc2586bdd8dbbe6d83c09b77b360ec8fcac3736.1711683069.git.baolin.wang@linux.alibaba.com Signed-off-by: Baolin Wang <[email protected]> Reviewed-by: "Huang, Ying" <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: John Hubbard <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Ryan Roberts <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 68dbcf4 commit 6b0ed7b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

mm/memory.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5063,6 +5063,20 @@ int numa_migrate_prep(struct folio *folio, struct vm_fault *vmf,
50635063
return mpol_misplaced(folio, vmf, addr);
50645064
}
50655065

5066+
static void numa_rebuild_single_mapping(struct vm_fault *vmf, struct vm_area_struct *vma,
5067+
bool writable)
5068+
{
5069+
pte_t pte, old_pte;
5070+
5071+
old_pte = ptep_modify_prot_start(vma, vmf->address, vmf->pte);
5072+
pte = pte_modify(old_pte, vma->vm_page_prot);
5073+
pte = pte_mkyoung(pte);
5074+
if (writable)
5075+
pte = pte_mkwrite(pte, vma);
5076+
ptep_modify_prot_commit(vma, vmf->address, vmf->pte, old_pte, pte);
5077+
update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1);
5078+
}
5079+
50665080
static vm_fault_t do_numa_page(struct vm_fault *vmf)
50675081
{
50685082
struct vm_area_struct *vma = vmf->vma;
@@ -5168,13 +5182,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
51685182
* Make it present again, depending on how arch implements
51695183
* non-accessible ptes, some can allow access by kernel mode.
51705184
*/
5171-
old_pte = ptep_modify_prot_start(vma, vmf->address, vmf->pte);
5172-
pte = pte_modify(old_pte, vma->vm_page_prot);
5173-
pte = pte_mkyoung(pte);
5174-
if (writable)
5175-
pte = pte_mkwrite(pte, vma);
5176-
ptep_modify_prot_commit(vma, vmf->address, vmf->pte, old_pte, pte);
5177-
update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1);
5185+
numa_rebuild_single_mapping(vmf, vma, writable);
51785186
pte_unmap_unlock(vmf->pte, vmf->ptl);
51795187
goto out;
51805188
}

0 commit comments

Comments
 (0)