Skip to contentSkip to conversation

mm-add-ability-to-take-further-action-in-vm_area_desc.patch removed from -mm tree

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

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: add ability to take further action in vm_area_desc
has been removed from the -mm tree. Its filename was
mm-add-ability-to-take-further-action-in-vm_area_desc.patch

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

------------------------------------------------------
From: Lorenzo Stoakes <[email protected]>
Subject: mm: add ability to take further action in vm_area_desc
Date: Mon, 20 Oct 2025 13:11:27 +0100

Some drivers/filesystems need to perform additional tasks after the VMA is set up. This is typically in the form of pre-population.

The forms of pre-population most likely to be performed are a PFN remap or the insertion of normal folios and PFNs into a mixed map.

We start by implementing the PFN remap functionality, ensuring that we perform the appropriate actions at the appropriate time - that is setting flags at the point of .mmap_prepare, and performing the actual remap at the point at which the VMA is fully established.

This prevents the driver from doing anything too crazy with a VMA at any stage, and we retain complete control over how the mm functionality is applied.

Unfortunately callers still do often require some kind of custom action, so we add an optional success/error _hook to allow the caller to do something after the action has succeeded or failed.

This is done at the point when the VMA has already been established, so the harm that can be done is limited.

The error hook can be used to filter errors if necessary.

There may be cases in which the caller absolutely must hold the file rmap lock until the operation is entirely complete. It is an edge case, but certainly the hugetlbfs mmap hook requires it.

To accommodate this, we add the hide_from_rmap_until_complete flag to the mmap_action type. In this case, if a new VMA is allocated, we will hold the file rmap lock until the operation is entirely completed (including any success/error hooks).

Note that we do not need to update __compat_vma_mmap() to accommodate this flag, as this function will be invoked from an .mmap handler whose VMA is not yet visible, so we implicitly hide it from the rmap.

If any error arises on these final actions, we simply unmap the VMA altogether.

Also update the stacked filesystem compatibility layer to utilise the action behaviour, and update the VMA tests accordingly.

While we're here, rename __compat_vma_mmap_prepare() to __compat_vma_mmap() as we are now performing actions invoked by the mmap_prepare in addition to just the mmap_prepare hook.

Cc Alexander Gordeev <[email protected]>
Cc Al Viro <[email protected]>
Cc Andreas Larsson <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Baolin Wang <[email protected]>
Cc Baoquan He <[email protected]>
Cc Chatre, Reinette <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Dan Williams <[email protected]>
Cc Dave Jiang <[email protected]>
Cc Dave Martin <[email protected]>
Cc Dave Young <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc David S. Miller <[email protected]>
Cc Dmitriy Vyukov <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Guo Ren <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc James Morse <[email protected]>
Cc Jan Kara <[email protected]>
Cc Jann Horn <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Kevin Tian <[email protected]>
Cc Konstantin Komarov <[email protected]>
Cc Liam Howlett <[email protected]>
Cc "Luck, Tony" <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Muchun Song <[email protected]>
Cc Nicolas Pitre <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Pedro Falcato <[email protected]>
Cc Robin Murohy <[email protected]>
Cc Sumanth Korikkar <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Sven Schnelle <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc "Uladzislau Rezki (Sony)" <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vishal Verma <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Will Deacon <[email protected]>

---

 include/linux/fs.h               |    6 -
 include/linux/mm.h               |   74 ++++++++++++++
 include/linux/mm_types.h         |   53 ++++++++++
 mm/util.c                        |  146 ++++++++++++++++++++++++++---
 mm/vma.c                         |  113 ++++++++++++++++------
 tools/testing/vma/vma_internal.h |   98 ++++++++++++++++++-
 6 files changed, 441 insertions(+), 49 deletions(-)
include/linux/fs.h renamed from include/linux/fs.h~mm-add-ability-to-take-further-action-in-vm_area_desc +3 -3
@@ -2393,14 +2393,14 @@ static inline bool can_mmap_file(struct
 	return true;
 }
 
-int __compat_vma_mmap_prepare(const struct file_operations *f_op,
+int __compat_vma_mmap(const struct file_operations *f_op,
 		struct file *file, struct vm_area_struct *vma);
-int compat_vma_mmap_prepare(struct file *file, struct vm_area_struct *vma);
+int compat_vma_mmap(struct file *file, struct vm_area_struct *vma);
 
 static inline int vfs_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	if (file->f_op->mmap_prepare)
-		return compat_vma_mmap_prepare(file, vma);
+		return compat_vma_mmap(file, vma);
 
 	return file->f_op->mmap(file, vma);
 }
include/linux/mm.h renamed from include/linux/mm.h~mm-add-ability-to-take-further-action-in-vm_area_desc +74 -0

80 lines not on this page · raw message

include/linux/mm_types.h renamed from include/linux/mm_types.h~mm-add-ability-to-take-further-action-in-vm_area_desc +53 -0

65 lines not on this page · raw message

mm/util.c renamed from mm/util.c~mm-add-ability-to-take-further-action-in-vm_area_desc +135 -11

194 lines not on this page · raw message

mm/vma.c renamed from mm/vma.c~mm-add-ability-to-take-further-action-in-vm_area_desc +85 -28

217 lines not on this page · raw message

tools/testing/vma/vma_internal.h renamed from tools/testing/vma/vma_internal.h~mm-add-ability-to-take-further-action-in-vm_area_desc +91 -7

147 lines not on this page · raw message

_

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

mm-introduce-vm_maybe_guard-and-make-visible-in-proc-pid-smaps.patch mm-add-atomic-vma-flags-and-set-vm_maybe_guard-as-such.patch mm-add-atomic-vma-flags-and-set-vm_maybe_guard-as-such-fix.patch mm-implement-sticky-vma-flags.patch mm-introduce-copy-on-fork-vmas-and-make-vm_maybe_guard-one.patch mm-set-the-vm_maybe_guard-flag-on-guard-region-install.patch mm-set-the-vm_maybe_guard-flag-on-guard-region-install-fix.patch tools-testing-vma-add-vma-sticky-userland-tests.patch tools-testing-selftests-mm-add-madv_collapse-test-case.patch tools-testing-selftests-mm-add-smaps-visibility-guard-region-test.patch mm-correctly-handle-uffd-pte-markers.patch mm-introduce-leaf-entry-type-and-use-to-simplify-leaf-entry-logic.patch mm-avoid-unnecessary-uses-of-is_swap_pte.patch mm-eliminate-is_swap_pte-when-softleaf_from_pte-suffices.patch mm-use-leaf-entries-in-debug-pgtable-remove-is_swap_pte.patch fs-proc-task_mmu-refactor-pagemap_pmd_range.patch mm-avoid-unnecessary-use-of-is_swap_pmd.patch mm-huge_memory-refactor-copy_huge_pmd-non-present-logic.patch mm-huge_memory-refactor-change_huge_pmd-non-present-logic.patch mm-replace-pmd_to_swp_entry-with-softleaf_from_pmd.patch mm-introduce-pmd_is_huge-and-use-where-appropriate.patch mm-remove-remaining-is_swap_pmd-users-and-is_swap_pmd.patch mm-remove-non_swap_entry-and-use-softleaf-helpers-instead.patch mm-remove-is_hugetlb_entry_.patch mm-eliminate-further-swapops-predicates.patch mm-replace-remaining-pte_to_swp_entry-with-softleaf_from_pte.patch mm-rename-walk_page_range_mm.patch mm-madvise-allow-guard-page-install-remove-under-vma-lock.patch mm-propagate-vm_softdirty-on-merge.patch testing-selftests-mm-add-soft-dirty-merge-self-test.patch mm-declare-vma-flags-by-bit.patch mm-declare-vma-flags-by-bit-fix.patch mm-declare-vma-flags-by-bit-fix-2.patch mm-simplify-and-rename-mm-flags-function-for-clarity.patch tools-testing-vma-eliminate-dependency-on-vma-__vm_flags.patch mm-introduce-vma-flags-bitmap-type.patch