Skip to contentSkip to conversation

mm-mmap_lock-add-vma_is_attached-helper.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jan 27

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/mmap_lock: add vma_is_attached() helper
has been removed from the -mm tree. Its filename was
mm-mmap_lock-add-vma_is_attached-helper.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/mmap_lock: add vma_is_attached() helper
Date: Sun, 18 Jan 2026 14:50:43 +0000

This makes it easy to explicitly check for VMA detachment, which is useful for things like asserts.

Note that we intentionally do not allow this function to be available should CONFIG_PER_VMA_LOCK be set - this is because vma_assert_attached() and vma_assert_detached() are no-ops if !CONFIG_PER_VMA_LOCK, so there is no correct state for vma_is_attached() to be in if this configuration option is not specified.

Therefore users elsewhere must invoke this function only after checking for CONFIG_PER_VMA_LOCK.

We rework the assert functions to utilise this.

---

 include/linux/mmap_lock.h |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/mmap_lock.h renamed from include/linux/mmap_lock.h~mm-mmap_lock-add-vma_is_attached-helper +7 -2
@@ -251,6 +251,11 @@ static inline void vma_assert_locked(str
 		      !__is_vma_write_locked(vma, &mm_lock_seq), vma);
 }
 
+static inline bool vma_is_attached(struct vm_area_struct *vma)
+{
+	return refcount_read(&vma->vm_refcnt);
+}
+
 /*
  * WARNING: to avoid racing with vma_mark_attached()/vma_mark_detached(), these
  * assertions should be made either under mmap_write_lock or when the object
@@ -258,12 +263,12 @@ static inline void vma_assert_locked(str
  */
 static inline void vma_assert_attached(struct vm_area_struct *vma)
 {
-	WARN_ON_ONCE(!refcount_read(&vma->vm_refcnt));
+	WARN_ON_ONCE(!vma_is_attached(vma));
 }
 
 static inline void vma_assert_detached(struct vm_area_struct *vma)
 {
-	WARN_ON_ONCE(refcount_read(&vma->vm_refcnt));
+	WARN_ON_ONCE(vma_is_attached(vma));
 }
 
 static inline void vma_mark_attached(struct vm_area_struct *vma)

_

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

selftests-mm-remove-virtual_address_range-test.patch mm-vma-rename-vma_lock_offset-to-vm_refcnt_exclude_readers_flag.patch mm-vma-document-possible-vma-vm_refcnt-values-and-reference-comment.patch mm-vma-rename-is_vma_write_only-separate-out-shared-refcount-put.patch mm-vma-adduse-vma-lockdep-acquire-release-defines.patch mm-vma-de-duplicate-__vma_enter_locked-error-path.patch mm-vma-clean-up-__vma_enter-exit_locked.patch mm-vma-introduce-helper-struct-thread-through-exclusive-lock-fns.patch mm-vma-improve-and-document-__is_vma_write_locked.patch mm-vma-improve-and-document-__is_vma_write_locked-fix.patch mm-vma-update-vma_assert_locked-to-use-lockdep.patch mm-vma-update-vma_assert_locked-to-use-lockdep-fix.patch mm-vma-add-and-use-vma_assert_stabilised.patch mm-vma-remove-__private-sparse-decoration-from-vma_flags_t.patch mm-rename-vma_flag_test-set_atomic-to-vma_test-set_atomic_flag.patch mm-add-mk_vma_flags-bitmap-flag-macro-helper.patch tools-bitmap-add-missing-bitmap_.patch mm-add-basic-vma-flag-operation-helper-functions.patch mm-update-hugetlbfs-to-use-vma-flags-on-mmap_prepare.patch mm-update-secretmem-to-use-vma-flags-on-mmap_prepare.patch mm-update-shmem__file_-functions-to-use-vma_flags_t.patch mm-update-all-remaining-mmap_prepare-users-to-use-vma_flags_t.patch mm-make-vm_area_desc-utilise-vma_flags_t-only.patch tools-testing-vma-separate-vma-userland-tests-into-separate-files.patch tools-testing-vma-separate-out-vma_internalh-into-logical-headers.patch tools-testing-vma-add-vma-userland-tests-for-vma-flag-functions.patch