#ifdef CONFIG_MMU
#ifdef CONFIG_PER_VMA_LOCK
+
+static inline void __vma_exit_locked(struct vm_area_struct *vma, bool *detached)
+{
+ *detached = refcount_sub_and_test(VM_REFCNT_EXCLUDE_READERS_FLAG,
+ &vma->vm_refcnt);
+ __vma_lockdep_release_exclusive(vma);
+}
+
/*
* __vma_enter_locked() returns 0 immediately if the vma is not
* attached, otherwise it waits for any current readers to finish and
refcount_read(&vma->vm_refcnt) == tgt_refcnt,
state);
if (err) {
- if (refcount_sub_and_test(VM_REFCNT_EXCLUDE_READERS_FLAG, &vma->vm_refcnt)) {
+ bool detached;
+
+ __vma_exit_locked(vma, &detached);
+ if (detached) {
/*
* The wait failed, but the last reader went away
* as well. Tell the caller the VMA is detached.
WARN_ON_ONCE(!detaching);
err = 0;
}
- __vma_lockdep_release_exclusive(vma);
return err;
}
__vma_lockdep_stat_mark_acquired(vma);
return 1;
}
-static inline void __vma_exit_locked(struct vm_area_struct *vma, bool *detached)
-{
- *detached = refcount_sub_and_test(VM_REFCNT_EXCLUDE_READERS_FLAG,
- &vma->vm_refcnt);
- __vma_lockdep_release_exclusive(vma);
-}
-
int __vma_start_write(struct vm_area_struct *vma, unsigned int mm_lock_seq,
int state)
{