Skip to content

Commit

Permalink
vm_fault: avoid vm_page_next()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Doug Moore authored and Doug Moore committed Jul 27, 2024
1 parent 21e98f6 commit b3cec80
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sys/vm/vm_fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ||
Expand Down

0 comments on commit b3cec80

Please sign in to comment.