Use vm_page_prev() instead of vm_page_lookup() in the implementation of

vm_fault()'s automatic delete-behind heuristic.
vm_page_prev() is typically faster.
This commit is contained in:
alc 2010-07-02 19:59:18 +00:00
parent 395ada5313
commit 3e4ac0b6ee

View File

@ -214,7 +214,7 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
boolean_t growstack, wired; boolean_t growstack, wired;
int map_generation; int map_generation;
vm_object_t next_object; vm_object_t next_object;
vm_page_t marray[VM_FAULT_READ]; vm_page_t marray[VM_FAULT_READ], mt, mt_prev;
int hardfault; int hardfault;
int faultcount, ahead, behind, alloc_req; int faultcount, ahead, behind, alloc_req;
struct faultstate fs; struct faultstate fs;
@ -465,26 +465,28 @@ readrest:
fs.first_object->type != OBJT_DEVICE && fs.first_object->type != OBJT_DEVICE &&
fs.first_object->type != OBJT_PHYS && fs.first_object->type != OBJT_PHYS &&
fs.first_object->type != OBJT_SG) { fs.first_object->type != OBJT_SG) {
vm_pindex_t firstpindex, tmppindex; vm_pindex_t firstpindex;
if (fs.first_pindex < 2 * VM_FAULT_READ) if (fs.first_pindex < 2 * VM_FAULT_READ)
firstpindex = 0; firstpindex = 0;
else else
firstpindex = fs.first_pindex - 2 * VM_FAULT_READ; firstpindex = fs.first_pindex - 2 * VM_FAULT_READ;
mt = fs.first_object != fs.object ?
fs.first_m : fs.m;
KASSERT(mt != NULL, ("vm_fault: missing mt"));
KASSERT((mt->oflags & VPO_BUSY) != 0,
("vm_fault: mt %p not busy", mt));
mt_prev = vm_page_prev(mt);
/* /*
* note: partially valid pages cannot be * note: partially valid pages cannot be
* included in the lookahead - NFS piecemeal * included in the lookahead - NFS piecemeal
* writes will barf on it badly. * writes will barf on it badly.
*/ */
for (tmppindex = fs.first_pindex - 1; while ((mt = mt_prev) != NULL &&
tmppindex >= firstpindex; mt->pindex >= firstpindex &&
--tmppindex) { mt->valid == VM_PAGE_BITS_ALL) {
vm_page_t mt; mt_prev = vm_page_prev(mt);
mt = vm_page_lookup(fs.first_object, tmppindex);
if (mt == NULL || (mt->valid != VM_PAGE_BITS_ALL))
break;
if (mt->busy || if (mt->busy ||
(mt->oflags & VPO_BUSY)) (mt->oflags & VPO_BUSY))
continue; continue;