vm_fault: avoid vm_page_next()

Where vm_fault calls vm_page_next, replace it with a use of TAILQ_NEXT
and a KASSERT.  This avoids needless computation in a NODEBUG kernel
and makes the error checking clearer in a GENERIC kernel.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D46168
This commit is contained in:
Doug Moore 2024-07-27 16:11:53 -05:00
parent 21e98f6d19
commit b3cec803ea

View File

@ -485,7 +485,9 @@ vm_fault_populate_cleanup(vm_object_t object, vm_pindex_t first,
VM_OBJECT_ASSERT_WLOCKED(object);
MPASS(first <= last);
for (pidx = first, m = vm_page_lookup(object, pidx);
pidx <= last; pidx++, m = vm_page_next(m)) {
pidx <= last; pidx++, m = TAILQ_NEXT(m, listq)) {
KASSERT(m != NULL && m->pindex == pidx,
("%s: pindex mismatch", __func__));
vm_fault_populate_check_page(m);
vm_page_deactivate(m);
vm_page_xunbusy(m);
@ -623,9 +625,10 @@ vm_fault_populate(struct faultstate *fs)
}
for (pidx = pager_first, m = vm_page_lookup(fs->first_object, pidx);
pidx <= pager_last;
pidx += npages, m = vm_page_next(&m[npages - 1])) {
pidx += npages, m = TAILQ_NEXT(&m[npages - 1], listq)) {
vaddr = fs->entry->start + IDX_TO_OFF(pidx) - fs->entry->offset;
KASSERT(m != NULL && m->pindex == pidx,
("%s: pindex mismatch", __func__));
psind = m->psind;
while (psind > 0 && ((vaddr & (pagesizes[psind] - 1)) != 0 ||
pidx + OFF_TO_IDX(pagesizes[psind]) - 1 > pager_last ||