Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: tweak __vma_enter_locked()

Move the commentary on how __vma_enter_locked() behaves from the body of
__vma_start_write() to the head of __vma_enter_locked() and merge it with
the existing documentation. Also add a call to
mmap_assert_write_locked().

Link: https://lkml.kernel.org/r/20251119042639.3937024-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
ecf371b2 31807483

+5 -8
+5 -8
mm/mmap_lock.c
··· 46 46 #ifdef CONFIG_MMU 47 47 #ifdef CONFIG_PER_VMA_LOCK 48 48 /* 49 - * Return value: 0 if vma detached, 50 - * 1 if vma attached with no readers, 51 - * -EINTR if signal received, 49 + * __vma_enter_locked() returns 0 immediately if the vma is not 50 + * attached, otherwise it waits for any current readers to finish and 51 + * returns 1. Returns -EINTR if a signal is received while waiting. 52 52 */ 53 53 static inline int __vma_enter_locked(struct vm_area_struct *vma, 54 54 bool detaching, int state) 55 55 { 56 56 int err; 57 57 unsigned int tgt_refcnt = VMA_LOCK_OFFSET; 58 + 59 + mmap_assert_write_locked(vma->vm_mm); 58 60 59 61 /* Additional refcnt if the vma is attached. */ 60 62 if (!detaching) ··· 93 91 { 94 92 int locked; 95 93 96 - /* 97 - * __vma_enter_locked() returns false immediately if the vma is not 98 - * attached, otherwise it waits until refcnt is indicating that vma 99 - * is attached with no readers. 100 - */ 101 94 locked = __vma_enter_locked(vma, false, state); 102 95 if (locked < 0) 103 96 return locked;