The patch titled Subject: mm: move the easily assessable conditions forward has been added to the -mm mm-unstable branch. Its filename is mm-remap-unused-subpages-to-shared-zeropage-when-splitting-isolated-thp-fix.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-remap-unused-subpages-to-shared-zeropage-when-splitting-isolated-thp-fix.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Huan Yang <link@xxxxxxxx> Subject: mm: move the easily assessable conditions forward Date: Thu, 15 Aug 2024 16:31:01 +0800 Currently try_to_map_unused_to_zeropage() tries to use shared zero page to save some memory of sub page. If forbidding zeropage there is no need to do anything rather than attempting to assess wthether to use it afterwards. Link: https://lkml.kernel.org/r/20240815083102.653820-1-link@xxxxxxxx Signed-off-by: Huan Yang <link@xxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/migrate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/mm/migrate.c~mm-remap-unused-subpages-to-shared-zeropage-when-splitting-isolated-thp-fix +++ a/mm/migrate.c @@ -192,6 +192,9 @@ static bool try_to_map_unused_to_zeropag 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_zeropag 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), _ Patches currently in -mm which might be from link@xxxxxxxx are mm-remap-unused-subpages-to-shared-zeropage-when-splitting-isolated-thp-fix.patch