/* *Wearetheonlywriter,sononeedtousevma_refcount_put(). *Theconditionbelowisunlikelybecausethevmahasbeenalready *write-lockedandreaderscanincrementvm_refcntonlytemporarily *beforetheycheckvm_lock_seq,realizethevmaislockedanddrop *backthevm_refcnt.Thatisanarrowwindowforobservingaraised *vm_refcnt.
*/ if (unlikely(!refcount_dec_and_test(&vma->vm_refcnt))) { /* Wait until vma is detached with no readers. */ if (__vma_enter_locked(vma, true)) { bool detached;
rcu_read_lock();
retry:
vma = mas_walk(&mas); if (!vma) goto inval;
vma = vma_start_read(mm, vma); if (IS_ERR_OR_NULL(vma)) { /* Check if the VMA got isolated after we found it */ if (PTR_ERR(vma) == -EAGAIN) {
count_vm_vma_lock_event(VMA_LOCK_MISS); /* The area was replaced with another one */ goto retry;
}
/* Failed to lock the VMA */ goto inval;
} /* *Atthispoint,wehaveastablereferencetoaVMA:TheVMAis *lockedandweknowithasn'talreadybeenisolated. *Fromhereon,wecanaccesstheVMAwithoutworryingaboutwhich *fieldsareaccessibleforRCUreaders.
*/
/* Check if the vma we locked is the right one. */ if (unlikely(address < vma->vm_start || address >= vma->vm_end)) goto inval_end_read;
ret = mmap_read_lock_killable(mm); if (ret) return ERR_PTR(ret);
/* Lookup the vma at the last position again under mmap_read_lock */
vma_iter_set(vmi, from_addr);
vma = vma_next(vmi); if (vma) { /* Very unlikely vma->vm_refcnt overflow case */ if (unlikely(!vma_start_read_locked(vma)))
vma = ERR_PTR(-EAGAIN);
}
RCU_LOCKDEP_WARN(!rcu_read_lock_held(), "no rcu read lock held");
retry: /* Start mmap_lock speculation in case we need to verify the vma later */
mmap_unlocked = mmap_lock_speculate_try_begin(mm, &mm_wr_seq);
vma = vma_next(vmi); if (!vma) return NULL;
vma = vma_start_read(mm, vma); if (IS_ERR_OR_NULL(vma)) { /* *Retryimmediatelyifthevmagetsdetachedfromunderus. *Infiniteloopshouldnothappenbecausethevmawefindwill *havetobeconstantlyknockedoutfromunderus.
*/ if (PTR_ERR(vma) == -EAGAIN) { /* reset to search from the last address */
vma_iter_set(vmi, from_addr); goto retry;
}
goto fallback;
}
/* Verify the vma is not behind the last search position. */ if (unlikely(from_addr >= vma->vm_end)) goto fallback_unlock;
/* *vmacanbeaheadofthelastsearchpositionbutweneedtoverify *itwasnotshrunkafterwefounditandanothervmahasnotbeen *installedaheadofit.Otherwisewemightobserveagapthatshould *notbethere.
*/ if (from_addr < vma->vm_start) { /* Verify only if the address space might have changed since vma lookup. */ if (!mmap_unlocked || mmap_lock_speculate_retry(mm, mm_wr_seq)) {
vma_iter_set(vmi, from_addr); if (vma != vma_next(vmi)) goto fallback_unlock;
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.