Skip to contentSkip to conversation

mm: move the easily assessable conditions forward

PATCH In review Huan Yang 2 participants 2 messages Aug 15, 2024

Subsystems (2)
lore
Share & tools
lore

Huan Yang

author
#0 lore raw

PATCH 1/1 mm: move the easily assessable conditions forward

Current try_to_map_unused_to_zeropage try to use shared zero page to save some memory of sub page.

If forbids zeropage, no need to do anything rather than attempting to assess wthether to use it afterwards.

---
 mm/migrate.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mm/migrate.c +4 -1
index 6e32098ac2dc..d71cc4ff190f 100644
@@ -192,6 +192,9 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
 	VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page);
 
+	if (mm_forbids_zeropage(pvmw->vma->vm_mm))
+		return false;
+
 	if (PageMlocked(page) || (pvmw->vma->vm_flags & VM_LOCKED))
 		return false;
 
@@ -204,7 +207,7 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
 	contains_data = memchr_inv(addr, 0, PAGE_SIZE);
 	kunmap_local(addr);
 
-	if (contains_data || mm_forbids_zeropage(pvmw->vma->vm_mm))
+	if (contains_data)
 		return false;
 
 	newpte = pte_mkspecial(pfn_pte(my_zero_pfn(pvmw->address),

base-commit: edd1ec2e3a9f5de7fb267a3af73e4f00e7e052b7

Signature · 1 line
2.45.2
maintainer
#1 lore raw
Quoted 21 lines · On Thu, 15 Aug 2024 16:31:01 +0800 Huan Yang <[email protected]> wrote:

Current try_to_map_unused_to_zeropage try to use shared zero page to save some memory of sub page.

If forbids zeropage, no need to do anything rather than attempting to assess wthether to use it afterwards.

...

mm/migrate.c +3 -0
@@ -192,6 +192,9 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
 	VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page);
 
+	if (mm_forbids_zeropage(pvmw->vma->vm_mm))
+		return false;
+
 	if (PageMlocked(page) || (pvmw->vma->vm_flags & VM_LOCKED))
 		return false;
 

mm/migrate.c static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw, · line 212

Quoted 7 lines
mm/migrate.c +1 -1
@@ -204,7 +207,7 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
 	contains_data = memchr_inv(addr, 0, PAGE_SIZE);
 	kunmap_local(addr);
 
-	if (contains_data || mm_forbids_zeropage(pvmw->vma->vm_mm))
+	if (contains_data)
 		return false;
 

Looks sensible. I'll add it as a fixup to "mm: remap unused subpages to shared zeropage when splitting isolated thp".