Subject: UBC performance patch
To: None <tech-kern@netbsd.org>
From: None <eeh@netbsd.org>
List: tech-kern
Date: 01/23/2001 19:34:10
Here's a little fix I threw together to improve the performance of
UBC under I/O load.  What it does is put buffer cache pages on the
uvm inactive list when an IOP completes instead of leaving them on
the active list for the page scanner to reclaim.  This has several
effects:  it makes buffer cache pages more likely to be reclaimed
than other pages, and it slightly reduces the load on the pagedaemon.

Eduardo

Index: sys/uvm/uvm_bio.c
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_bio.c,v
retrieving revision 1.6
diff -u -r1.6 uvm_bio.c
--- sys/uvm/uvm_bio.c   2000/12/27 09:01:45     1.6
+++ sys/uvm/uvm_bio.c   2001/01/23 19:24:23
@@ -439,6 +439,7 @@
                (umap - ubc_object.umap) * ubc_winsize + slot_offset;
 }
     
+int ubc_reclaim = 1;
     
 void
 ubc_release(va, wlen)
@@ -463,6 +464,22 @@
        umap->writelen = 0;
        umap->refcount--;
        if (umap->refcount == 0) {
+#if 1
+               if (ubc_reclaim) {
+                       struct vm_page *p;
+    
+                       /* Take any pages in this uobj and put them on the inactive list. */
+                       TAILQ_FOREACH(p, &uobj->memq, listq) {
+                               if ((p->pqflags & PQ_ACTIVE) && !(p->flags & PG_BUSY)) {
+                                       pmap_page_protect(p, VM_PROT_NONE);
+                               /* no need to check wire_count as pg is "active" */
+                                       uvm_pagedeactivate(p);
+                                       uvmexp.pddeact++;
+                               }
+                       }
+               }
+       
+#endif
                if (UBC_RELEASE_UNMAP &&
                    (((struct vnode *)uobj)->v_flag & VTEXT)) {
                        vaddr_t va;