Skip to contentSkip to conversation

mm-vma-do-not-register-private-anon-mappings-with-khugepaged-during-mmap.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Mar 17, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/vma: do not register private-anon mappings with khugepaged during mmap
has been removed from the -mm tree. Its filename was
mm-vma-do-not-register-private-anon-mappings-with-khugepaged-during-mmap.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Dev Jain <[email protected]>
Subject: mm/vma: do not register private-anon mappings with khugepaged during mmap
Date: Thu, 6 Mar 2025 12:00:37 +0530

We already are registering private-anon VMAs with khugepaged during fault time, in do_huge_pmd_anonymous_page(). Commit "register suitable readonly file vmas for khugepaged" moved the khugepaged registration logic from shmem_mmap to the generic mmap path.

The userspace-visible effect should be this: khugepaged will unnecessarily scan mm's which haven't yet faulted in. Note that it won't actually collapse because all PTEs are none.

Now that I think about it, the mm is going to have a file VMA anyways during fork+exec, so the mm already gets registered during mmap due to the non-anon case (I *think*), so at least one of either the mmap registration or fault-time registration is redundant.

Make this logic specific for non-anon mappings.

Fixes 613bec092fe7 ("mm: mmap: register suitable readonly file vmas for khugepaged")
Cc "Aneesh Kumar K.V" <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Jann Horn <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Matthew Wilcow (Oracle) <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Yang Shi <[email protected]>
Cc Zi Yan <[email protected]>

---

 mm/vma.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vma.c renamed from mm/vma.c~mm-vma-do-not-register-private-anon-mappings-with-khugepaged-during-mmap +2 -1
@@ -2381,7 +2381,8 @@ static int __mmap_new_vma(struct mmap_st
 	 * vma_merge_new_range() calls khugepaged_enter_vma() too, the below
 	 * call covers the non-merge case.
 	 */
-	khugepaged_enter_vma(vma, map->flags);
+	if (!vma_is_anonymous(vma))
+		khugepaged_enter_vma(vma, map->flags);
 	ksm_add_vma(vma);
 	*vmap = vma;
 	return 0;

_

Patches currently in -mm which might be from [email protected] are

mm-remove-redundant-return-in-set_huge_zero_folio.patch