mm-madvise-allow-guard-page-install-remove-under-vma-lock.patch removed from -mm tree
The quilt patch titled
Subject: mm/madvise: allow guard page install/remove under VMA lock
has been removed from the -mm tree. Its filename was
mm-madvise-allow-guard-page-install-remove-under-vma-lock.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/madvise: allow guard page install/remove under VMA lock
Date: Mon, 10 Nov 2025 17:22:58 +0000
We only need to keep the page table stable so we can perform this operation under the VMA lock. PTE installation is stabilised via the PTE lock.
One caveat is that, if we prepare vma->anon_vma we must hold the mmap read lock. We can account for this by adapting the VMA locking logic to explicitly check for this case and prevent a VMA lock from being acquired should it be the case.
This check is safe, as while we might be raced on anon_vma installation, this would simply make the check conservative, there's no way for us to see an anon_vma and then for it to be cleared, as doing so requires the mmap/VMA write lock.
We abstract the VMA lock validity logic to is_vma_lock_sufficient() for this purpose, and add prepares_anon_vma() to abstract the anon_vma logic.
In order to do this we need to have a way of installing page tables explicitly for an identified VMA, so we export walk_page_range_vma() in an unsafe variant - walk_page_range_vma_unsafe() and use this should the VMA read lock be taken.
We additionally update the comments in madvise_guard_install() to more accurately reflect the cases in which the logic may be reattempted, specifically THP huge pages being present.
---
mm/internal.h | 3 + mm/madvise.c | 110 ++++++++++++++++++++++++++++++++++-------------- mm/pagewalk.c | 17 +++++-- 3 files changed, 94 insertions(+), 36 deletions(-)
mm/internal.h renamed from mm/internal.h~mm-madvise-allow-guard-page-install-remove-under-vma-lock +3 -0
@@ -1652,6 +1652,9 @@ static inline void accept_page(struct paint walk_page_range_mm_unsafe (struct mm_struct *mm,unsigned long start,unsigned long end,const struct mm_walk_ops *ops,void *private); +int walk_page_range_vma_unsafe (struct vm_area_struct *vma,unsigned long start, +unsigned long end,const struct mm_walk_ops *ops, +void *private);int walk_page_range_debug (struct mm_struct *mm,unsigned long start,unsigned long end,const struct mm_walk_ops *ops,pgd_t *pgd,void *private);
mm/madvise.c renamed from mm/madvise.c~mm-madvise-allow-guard-page-install-remove-under-vma-lock +79 -31
187 lines not on this page · raw message
mm/pagewalk.c renamed from mm/pagewalk.c~mm-madvise-allow-guard-page-install-remove-under-vma-lock +12 -5
@@ -694,9 +694,8 @@ int walk_page_range_debug(struct mm_strureturn walk_pgd_range (start, end, &walk); } -int walk_page_range_vma (struct vm_area_struct *vma,unsigned long start, -unsigned long end,const struct mm_walk_ops *ops, -void *private) +int walk_page_range_vma_unsafe (struct vm_area_struct *vma,unsigned long start, +unsigned long end,const struct mm_walk_ops *ops,void *private) {struct mm_walk walk = { .ops = ops,
@@ -709,14 +708,22 @@ int walk_page_range_vma(struct vm_area_sreturn -EINVAL ;if (start < vma->vm_start || end > vma->vm_end)return -EINVAL ; -if (!check_ops_safe (ops)) -return -EINVAL ;process_mm_walk_lock (walk.mm, ops->walk_lock);process_vma_walk_lock (vma, ops->walk_lock);return __walk_page_range (start, end, &walk); } +int walk_page_range_vma (struct vm_area_struct *vma,unsigned long start, +unsigned long end,const struct mm_walk_ops *ops, +void *private) +{ +if (!check_ops_safe (ops)) +return -EINVAL ; + +return walk_page_range_vma_unsafe (vma, start, end, ops, private); +} +int walk_page_vma (struct vm_area_struct *vma,const struct mm_walk_ops *ops,void *private) {
_
Patches currently in -mm which might be from [email protected] are
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