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/vma: de-duplicate __vma_enter_locked() error path

We're doing precisely the same thing that __vma_exit_locked() does, so
de-duplicate this code and keep the refcount primitive in one place.

No functional change intended.

Link: https://lkml.kernel.org/r/c9759b593f6a158e984fa87abe2c3cbd368ef825.1769198904.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Waiman Long <longman@redhat.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
e5aeb75d 1f2e7efc

+12 -9
+12 -9
mm/mmap_lock.c
··· 45 45 46 46 #ifdef CONFIG_MMU 47 47 #ifdef CONFIG_PER_VMA_LOCK 48 + 49 + static inline void __vma_exit_locked(struct vm_area_struct *vma, bool *detached) 50 + { 51 + *detached = refcount_sub_and_test(VM_REFCNT_EXCLUDE_READERS_FLAG, 52 + &vma->vm_refcnt); 53 + __vma_lockdep_release_exclusive(vma); 54 + } 55 + 48 56 /* 49 57 * __vma_enter_locked() returns 0 immediately if the vma is not 50 58 * attached, otherwise it waits for any current readers to finish and ··· 85 77 refcount_read(&vma->vm_refcnt) == tgt_refcnt, 86 78 state); 87 79 if (err) { 88 - if (refcount_sub_and_test(VM_REFCNT_EXCLUDE_READERS_FLAG, &vma->vm_refcnt)) { 80 + bool detached; 81 + 82 + __vma_exit_locked(vma, &detached); 83 + if (detached) { 89 84 /* 90 85 * The wait failed, but the last reader went away 91 86 * as well. Tell the caller the VMA is detached. ··· 96 85 WARN_ON_ONCE(!detaching); 97 86 err = 0; 98 87 } 99 - __vma_lockdep_release_exclusive(vma); 100 88 return err; 101 89 } 102 90 __vma_lockdep_stat_mark_acquired(vma); 103 91 104 92 return 1; 105 - } 106 - 107 - static inline void __vma_exit_locked(struct vm_area_struct *vma, bool *detached) 108 - { 109 - *detached = refcount_sub_and_test(VM_REFCNT_EXCLUDE_READERS_FLAG, 110 - &vma->vm_refcnt); 111 - __vma_lockdep_release_exclusive(vma); 112 93 } 113 94 114 95 int __vma_start_write(struct vm_area_struct *vma, unsigned int mm_lock_seq,