Author: alc
Date: Fri Jul  2 19:59:18 2010
New Revision: 209650
URL: http://svn.freebsd.org/changeset/base/209650

Log:
  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.

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==============================================================================
--- head/sys/vm/vm_fault.c      Fri Jul  2 17:22:15 2010        (r209649)
+++ head/sys/vm/vm_fault.c      Fri Jul  2 19:59:18 2010        (r209650)
@@ -214,7 +214,7 @@ vm_fault(vm_map_t map, vm_offset_t vaddr
        boolean_t growstack, wired;
        int map_generation;
        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 faultcount, ahead, behind, alloc_req;
        struct faultstate fs;
@@ -465,26 +465,28 @@ readrest:
                            fs.first_object->type != OBJT_DEVICE &&
                            fs.first_object->type != OBJT_PHYS &&
                            fs.first_object->type != OBJT_SG) {
-                               vm_pindex_t firstpindex, tmppindex;
+                               vm_pindex_t firstpindex;
 
                                if (fs.first_pindex < 2 * VM_FAULT_READ)
                                        firstpindex = 0;
                                else
                                        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 
                                 * included in the lookahead - NFS piecemeal
                                 * writes will barf on it badly.
                                 */
-                               for (tmppindex = fs.first_pindex - 1;
-                                       tmppindex >= firstpindex;
-                                       --tmppindex) {
-                                       vm_page_t mt;
-
-                                       mt = vm_page_lookup(fs.first_object, 
tmppindex);
-                                       if (mt == NULL || (mt->valid != 
VM_PAGE_BITS_ALL))
-                                               break;
+                               while ((mt = mt_prev) != NULL &&
+                                   mt->pindex >= firstpindex &&
+                                   mt->valid == VM_PAGE_BITS_ALL) {
+                                       mt_prev = vm_page_prev(mt);
                                        if (mt->busy ||
                                            (mt->oflags & VPO_BUSY))
                                                continue;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to