The quilt patch titled Subject: mm-support-multi-size-thp-numa-balancing-v3 has been removed from the -mm tree. Its filename was mm-support-multi-size-thp-numa-balancing-v3.patch This patch was dropped because it was folded into mm-support-multi-size-thp-numa-balancing.patch ------------------------------------------------------ From: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Subject: mm-support-multi-size-thp-numa-balancing-v3 Date: Wed, 3 Apr 2024 16:39:10 +0800 - Reuse numa_rebuild_single_mapping() to remove duplicate code per Kefeng Wang. - Remove an unnecessary vma_wants_manual_pte_write_upgrad() per Huang, Ying. Link: https://lkml.kernel.org/r/c33a5c0b0a0323b1f8ed53772f50501f4b196e25.1712132950.git.baolin.wang@xxxxxxxxxxxxxxxxx Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Reviewed-by: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Ryan Roberts <ryan.roberts@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) --- a/mm/memory.c~mm-support-multi-size-thp-numa-balancing-v3 +++ a/mm/memory.c @@ -5064,32 +5064,32 @@ int numa_migrate_prep(struct folio *foli } static void numa_rebuild_single_mapping(struct vm_fault *vmf, struct vm_area_struct *vma, + unsigned long fault_addr, pte_t *fault_pte, bool writable) { pte_t pte, old_pte; - old_pte = ptep_modify_prot_start(vma, vmf->address, vmf->pte); + old_pte = ptep_modify_prot_start(vma, fault_addr, fault_pte); pte = pte_modify(old_pte, vma->vm_page_prot); pte = pte_mkyoung(pte); if (writable) pte = pte_mkwrite(pte, vma); - ptep_modify_prot_commit(vma, vmf->address, vmf->pte, old_pte, pte); - update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1); + ptep_modify_prot_commit(vma, fault_addr, fault_pte, old_pte, pte); + update_mmu_cache_range(vmf, vma, fault_addr, fault_pte, 1); } static void numa_rebuild_large_mapping(struct vm_fault *vmf, struct vm_area_struct *vma, - struct folio *folio, pte_t fault_pte, bool ignore_writable) + struct folio *folio, pte_t fault_pte, + bool ignore_writable, bool pte_write_upgrade) { int nr = pte_pfn(fault_pte) - folio_pfn(folio); unsigned long start = max(vmf->address - nr * PAGE_SIZE, vma->vm_start); unsigned long end = min(vmf->address + (folio_nr_pages(folio) - nr) * PAGE_SIZE, vma->vm_end); pte_t *start_ptep = vmf->pte - (vmf->address - start) / PAGE_SIZE; - bool pte_write_upgrade = vma_wants_manual_pte_write_upgrade(vma); unsigned long addr; /* Restore all PTEs' mapping of the large folio */ for (addr = start; addr != end; start_ptep++, addr += PAGE_SIZE) { - pte_t pte, old_pte; pte_t ptent = ptep_get(start_ptep); bool writable = false; @@ -5107,13 +5107,7 @@ static void numa_rebuild_large_mapping(s writable = true; } - old_pte = ptep_modify_prot_start(vma, addr, start_ptep); - pte = pte_modify(old_pte, vma->vm_page_prot); - pte = pte_mkyoung(pte); - if (writable) - pte = pte_mkwrite(pte, vma); - ptep_modify_prot_commit(vma, addr, start_ptep, old_pte, pte); - update_mmu_cache_range(vmf, vma, addr, start_ptep, 1); + numa_rebuild_single_mapping(vmf, vma, addr, start_ptep, writable); } } @@ -5123,6 +5117,7 @@ static vm_fault_t do_numa_page(struct vm struct folio *folio = NULL; int nid = NUMA_NO_NODE; bool writable = false, ignore_writable = false; + bool pte_write_upgrade = vma_wants_manual_pte_write_upgrade(vma); int last_cpupid; int target_nid; pte_t pte, old_pte; @@ -5148,7 +5143,7 @@ static vm_fault_t do_numa_page(struct vm * is only valid while holding the PT lock. */ writable = pte_write(pte); - if (!writable && vma_wants_manual_pte_write_upgrade(vma) && + if (!writable && pte_write_upgrade && can_change_pte_writable(vma, vmf->address, pte)) writable = true; @@ -5221,9 +5216,11 @@ out_map: * non-accessible ptes, some can allow access by kernel mode. */ if (folio && folio_test_large(folio)) - numa_rebuild_large_mapping(vmf, vma, folio, pte, ignore_writable); + numa_rebuild_large_mapping(vmf, vma, folio, pte, ignore_writable, + pte_write_upgrade); else - numa_rebuild_single_mapping(vmf, vma, writable); + numa_rebuild_single_mapping(vmf, vma, vmf->address, vmf->pte, + writable); pte_unmap_unlock(vmf->pte, vmf->ptl); goto out; } _ Patches currently in -mm which might be from baolin.wang@xxxxxxxxxxxxxxxxx are mm-record-the-migration-reason-for-struct-migration_target_control.patch mm-hugetlb-make-the-hugetlb-migration-strategy-consistent.patch docs-hugetlbpagerst-add-hugetlb-migration-description.patch mm-factor-out-the-numa-mapping-rebuilding-into-a-new-helper.patch mm-support-multi-size-thp-numa-balancing.patch mm-huge_memory-add-the-missing-folio_test_pmd_mappable-for-thp-split-statistics.patch mm-huge_memory-add-the-missing-folio_test_pmd_mappable-for-thp-split-statistics-v2.patch mm-page_alloc-use-the-correct-thp-order-for-thp-pcp.patch mm-set-pageblock_order-to-hpage_pmd_order-in-case-with-config_hugetlb_page-but-thp-enabled.patch mm-page_alloc-allowing-mthp-compaction-to-capture-the-freed-page-directly.patch