Skip to contentSkip to conversation

mm-memory-use-__zap_vma_range-in-zap_vma_for_reaping.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Mar 29

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/memory: use __zap_vma_range() in zap_vma_for_reaping()
has been removed from the -mm tree. Its filename was
mm-memory-use-__zap_vma_range-in-zap_vma_for_reaping.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: "David Hildenbrand (Arm)" <[email protected]>
Subject: mm/memory: use __zap_vma_range() in zap_vma_for_reaping()
Date: Fri, 27 Feb 2026 21:08:41 +0100

Let's call __zap_vma_range() instead of unmap_page_range() to prepare for further cleanups.

To keep the existing behavior, whereby we do not call uprobe_munmap() which could block, add a new "reaping" member to zap_details and use it.

Likely we should handle the possible blocking in uprobe_munmap() differently, but for now keep it unchanged.

Cc Alexander Gordeev <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Alice Ryhl <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc "Borislav Petkov (AMD)" <[email protected]>
Cc Carlos Llamas <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Claudio Imbrenda <[email protected]>
Cc Daniel Borkman <[email protected]>
Cc Dave Airlie <[email protected]>
Cc David Ahern <[email protected]>
Cc David Rientjes <[email protected]>
Cc David S. Miller <[email protected]>
Cc Dimitri Sivanich <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Gerald Schaefer <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Hartley Sweeten <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Ian Abbott <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jakub Kacinski <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Jann Horn <[email protected]>
Cc Janosch Frank <[email protected]>
Cc Jarkko Sakkinen <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Jonas Lahtinen <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Madhavan Srinivasan <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Miguel Ojeda <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Namhyung kim <[email protected]>
Cc Neal Cardwell <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Pedro Falcato <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Todd Kjos <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vincenzo Frascino <[email protected]>

---

 include/linux/mm.h |    1 +
 mm/memory.c        |   13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~mm-memory-use-__zap_vma_range-in-zap_vma_for_reaping +1 -0
@@ -2769,6 +2769,7 @@ struct zap_details {
 	struct folio *single_folio;	/* Locked folio to be unmapped */
 	bool skip_cows;			/* Do not zap COWed private pages */
 	bool reclaim_pt;		/* Need reclaim page tables? */
+	bool reaping;			/* Reaping, do not block. */
 	zap_flags_t zap_flags;		/* Extra flags for zapping */
 };
 
mm/memory.c renamed from mm/memory.c~mm-memory-use-__zap_vma_range-in-zap_vma_for_reaping +9 -4
@@ -2079,14 +2079,18 @@ static void __zap_vma_range(struct mmu_g
 		unsigned long start, unsigned long end,
 		struct zap_details *details)
 {
+	const bool reaping = details && details->reaping;
+
 	VM_WARN_ON_ONCE(start >= end || !range_in_vma(vma, start, end));
 
-	if (vma->vm_file)
+	/* uprobe_munmap() might sleep, so skip it when reaping. */
+	if (vma->vm_file && !reaping)
 		uprobe_munmap(vma, start, end);
 
 	if (unlikely(is_vm_hugetlb_page(vma))) {
 		zap_flags_t zap_flags = details ? details->zap_flags : 0;
 
+		VM_WARN_ON_ONCE(reaping);
 		/*
 		 * vm_file will be NULL when we fail early while instantiating
 		 * a new mapping. In this case, no pages were mapped yet and
@@ -2111,11 +2115,12 @@ static void __zap_vma_range(struct mmu_g
  */
 int zap_vma_for_reaping(struct vm_area_struct *vma)
 {
+	struct zap_details details = {
+		.reaping = true,
+	};
 	struct mmu_notifier_range range;
 	struct mmu_gather tlb;
 
-	VM_WARN_ON_ONCE(is_vm_hugetlb_page(vma));
-
 	mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma->vm_mm,
 				vma->vm_start, vma->vm_end);
 	tlb_gather_mmu(&tlb, vma->vm_mm);
@@ -2123,7 +2128,7 @@ int zap_vma_for_reaping(struct vm_area_s
 		tlb_finish_mmu(&tlb);
 		return -EBUSY;
 	}
-	unmap_page_range(&tlb, vma, range.start, range.end, NULL);
+	__zap_vma_range(&tlb, vma, range.start, range.end, &details);
 	mmu_notifier_invalidate_range_end(&range);
 	tlb_finish_mmu(&tlb);
 	return 0;

_

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