Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys a whole bunch of changes to improve performance and robu...



details:   https://anonhg.NetBSD.org/src/rev/53125d1d3690
branches:  trunk
changeset: 515010:53125d1d3690
user:      chs <chs%NetBSD.org@localhost>
date:      Sat Sep 15 20:36:31 2001 +0000

description:
a whole bunch of changes to improve performance and robustness under load:

 - remove special treatment of pager_map mappings in pmaps.  this is
   required now, since I've removed the globals that expose the address range.
   pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
   no longer any need to special-case it.
 - eliminate struct uvm_vnode by moving its fields into struct vnode.
 - rewrite the pageout path.  the pager is now responsible for handling the
   high-level requests instead of only getting control after a bunch of work
   has already been done on its behalf.  this will allow us to UBCify LFS,
   which needs tighter control over its pages than other filesystems do.
   writing a page to disk no longer requires making it read-only, which
   allows us to write wired pages without causing all kinds of havoc.
 - use a new PG_PAGEOUT flag to indicate that a page should be freed
   on behalf of the pagedaemon when it's unlocked.  this flag is very similar
   to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
   pageout fails due to eg. an indirect-block buffer being locked.
   this allows us to remove the "version" field from struct vm_page,
   and together with shrinking "loan_count" from 32 bits to 16,
   struct vm_page is now 4 bytes smaller.
 - no longer use PG_RELEASED for swap-backed pages.  if the page is busy
   because it's being paged out, we can't release the swap slot to be
   reallocated until that write is complete, but unlike with vnodes we
   don't keep a count of in-progress writes so there's no good way to
   know when the write is done.  instead, when we need to free a busy
   swap-backed page, just sleep until we can get it busy ourselves.
 - implement a fast-path for extending writes which allows us to avoid
   zeroing new pages.  this substantially reduces cpu usage.
 - encapsulate the data used by the genfs code in a struct genfs_node,
   which must be the first element of the filesystem-specific vnode data
   for filesystems which use genfs_{get,put}pages().
 - eliminate many of the UVM pagerops, since they aren't needed anymore
   now that the pager "put" operation is a higher-level operation.
 - enhance the genfs code to allow NFS to use the genfs_{get,put}pages
   instead of a modified copy.
 - clean up struct vnode by removing all the fields that used to be used by
   the vfs_cluster.c code (which we don't use anymore with UBC).
 - remove kmem_object and mb_object since they were useless.
   instead of allocating pages to these objects, we now just allocate
   pages with no object.  such pages are mapped in the kernel until they
   are freed, so we can use the mapping to find the page to free it.
   this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.

diffstat:

 sys/adosfs/adosfs.h               |    5 +-
 sys/adosfs/advfsops.c             |    7 +-
 sys/adosfs/advnops.c              |   11 +-
 sys/arch/alpha/alpha/pmap.c       |    8 +-
 sys/arch/arm/arm32/pmap.c         |   39 +-
 sys/arch/i386/i386/pmap.c         |  121 +----
 sys/arch/pc532/pc532/pmap.c       |   51 +-
 sys/arch/sh3/sh3/pmap.c           |   55 +--
 sys/arch/sun2/sun2/pmap.c         |   18 +-
 sys/arch/x86_64/x86_64/pmap.c     |   47 +-
 sys/conf/files                    |    3 +-
 sys/dev/pci/twe.c                 |    4 +-
 sys/filecorefs/filecore_node.h    |    5 +-
 sys/filecorefs/filecore_vfsops.c  |    5 +-
 sys/filecorefs/filecore_vnops.c   |   26 +-
 sys/isofs/cd9660/cd9660_node.h    |    5 +-
 sys/isofs/cd9660/cd9660_vfsops.c  |    7 +-
 sys/isofs/cd9660/cd9660_vnops.c   |   36 +-
 sys/kern/kern_malloc.c            |    6 +-
 sys/kern/kern_malloc_debug.c      |    8 +-
 sys/kern/kern_physio.c            |   10 +-
 sys/kern/uipc_mbuf.c              |    5 +-
 sys/kern/vfs_cluster.c            |  789 --------------------------------------
 sys/kern/vfs_subr.c               |  130 ++---
 sys/kern/vfs_vnops.c              |   14 +-
 sys/kern/vnode_if.src             |   33 +-
 sys/miscfs/genfs/Makefile         |    4 +-
 sys/miscfs/genfs/genfs.h          |    5 +-
 sys/miscfs/genfs/genfs_vnops.c    |  602 ++++++++++++++++++++++------
 sys/miscfs/specfs/spec_vnops.c    |   31 +-
 sys/miscfs/syncfs/sync_subr.c     |    5 +-
 sys/miscfs/union/union_vnops.c    |    6 +-
 sys/msdosfs/denode.h              |    6 +-
 sys/msdosfs/msdosfs_denode.c      |   24 +-
 sys/msdosfs/msdosfs_vfsops.c      |    4 +-
 sys/msdosfs/msdosfs_vnops.c       |   57 +-
 sys/nfs/nfs_bio.c                 |  693 ++++++--------------------------
 sys/nfs/nfs_node.c                |   37 +-
 sys/nfs/nfs_subs.c                |    8 +-
 sys/nfs/nfs_vfsops.c              |   10 +-
 sys/nfs/nfs_vnops.c               |   22 +-
 sys/nfs/nfsnode.h                 |    6 +-
 sys/sys/buf.h                     |    3 +-
 sys/sys/param.h                   |    3 +-
 sys/sys/vnode.h                   |   28 +-
 sys/ufs/ext2fs/ext2fs_balloc.c    |   44 +-
 sys/ufs/ext2fs/ext2fs_extern.h    |   14 +-
 sys/ufs/ext2fs/ext2fs_readwrite.c |   53 +-
 sys/ufs/ext2fs/ext2fs_vfsops.c    |   23 +-
 sys/ufs/ext2fs/ext2fs_vnops.c     |    7 +-
 sys/ufs/ffs/ffs_alloc.c           |   17 +-
 sys/ufs/ffs/ffs_balloc.c          |   30 +-
 sys/ufs/ffs/ffs_extern.h          |    7 +-
 sys/ufs/ffs/ffs_inode.c           |   25 +-
 sys/ufs/ffs/ffs_softdep.c         |   23 +-
 sys/ufs/ffs/ffs_vfsops.c          |   42 +-
 sys/ufs/ffs/ffs_vnops.c           |   80 ++-
 sys/ufs/lfs/lfs_alloc.c           |    8 +-
 sys/ufs/lfs/lfs_inode.c           |    3 +-
 sys/ufs/lfs/lfs_syscalls.c        |   12 +-
 sys/ufs/lfs/lfs_vfsops.c          |    9 +-
 sys/ufs/lfs/lfs_vnops.c           |    5 +-
 sys/ufs/ufs/inode.h               |    5 +-
 sys/ufs/ufs/ufs_extern.h          |    6 +-
 sys/ufs/ufs/ufs_inode.c           |   40 +-
 sys/ufs/ufs/ufs_readwrite.c       |  178 ++++---
 sys/ufs/ufs/ufs_vnops.c           |    7 +-
 sys/uvm/Makefile                  |    4 +-
 sys/uvm/uvm.h                     |    6 +-
 sys/uvm/uvm_amap.c                |   64 +--
 sys/uvm/uvm_anon.c                |   63 +-
 sys/uvm/uvm_aobj.c                |  467 ++++++++-------------
 sys/uvm/uvm_aobj.h                |    5 +-
 sys/uvm/uvm_bio.c                 |  253 ++++++-----
 sys/uvm/uvm_device.c              |   40 +-
 sys/uvm/uvm_extern.h              |   52 +-
 sys/uvm/uvm_fault.c               |  194 ++------
 sys/uvm/uvm_fault_i.h             |    4 +-
 sys/uvm/uvm_glue.c                |   17 +-
 sys/uvm/uvm_io.c                  |    4 +-
 sys/uvm/uvm_km.c                  |  253 +++--------
 sys/uvm/uvm_km.h                  |    4 +-
 sys/uvm/uvm_loan.c                |   21 +-
 sys/uvm/uvm_map.c                 |  147 +++---
 sys/uvm/uvm_mmap.c                |   21 +-
 sys/uvm/uvm_object.h              |   16 +-
 sys/uvm/uvm_page.c                |  241 +++-------
 sys/uvm/uvm_page.h                |   26 +-
 sys/uvm/uvm_page_i.h              |   68 +--
 sys/uvm/uvm_pager.c               |  633 ++++-------------------------
 sys/uvm/uvm_pager.h               |   79 +--
 sys/uvm/uvm_pdaemon.c             |  472 ++++++++--------------
 sys/uvm/uvm_pglist.c              |   59 +-
 sys/uvm/uvm_stat.c                |    8 +-
 sys/uvm/uvm_swap.c                |   72 +--
 sys/uvm/uvm_vnode.c               |  721 ++++------------------------------
 sys/uvm/uvm_vnode.h               |   59 --
 97 files changed, 2470 insertions(+), 5243 deletions(-)

diffs (truncated from 14324 to 300 lines):

diff -r 97f03c26ec60 -r 53125d1d3690 sys/adosfs/adosfs.h
--- a/sys/adosfs/adosfs.h       Sat Sep 15 19:51:38 2001 +0000
+++ b/sys/adosfs/adosfs.h       Sat Sep 15 20:36:31 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adosfs.h,v 1.17 1999/07/08 01:05:58 wrstuden Exp $     */
+/*     $NetBSD: adosfs.h,v 1.18 2001/09/15 20:36:31 chs Exp $  */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,6 +31,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <miscfs/genfs/genfs_node.h>
+
 /*
  * Arguments to mount amigados filesystems.
  */
@@ -62,6 +64,7 @@
  * table for f/e. it is always ANODETABSZ(ap) bytes in size.
  */
 struct anode {
+       struct genfs_node gnode;
        LIST_ENTRY(anode) link;
        enum anode_type type;
        char name[31];          /* (r/d/f) name for object */
diff -r 97f03c26ec60 -r 53125d1d3690 sys/adosfs/advfsops.c
--- a/sys/adosfs/advfsops.c     Sat Sep 15 19:51:38 2001 +0000
+++ b/sys/adosfs/advfsops.c     Sat Sep 15 20:36:31 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advfsops.c,v 1.47 2001/09/15 16:12:54 chs Exp $        */
+/*     $NetBSD: advfsops.c,v 1.48 2001/09/15 20:36:32 chs Exp $        */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -587,8 +587,9 @@
        ap->mtime.mins = adoswordn(bp, ap->nwords - 22);
        ap->mtime.ticks = adoswordn(bp, ap->nwords - 21);
 
-       *vpp = vp;              /* return vp */
-       brelse(bp);             /* release buffer */
+       *vpp = vp;
+       brelse(bp);
+       vp->v_size = ap->fsize;
        return (0);
 }
 
diff -r 97f03c26ec60 -r 53125d1d3690 sys/adosfs/advnops.c
--- a/sys/adosfs/advnops.c      Sat Sep 15 19:51:38 2001 +0000
+++ b/sys/adosfs/advnops.c      Sat Sep 15 20:36:31 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advnops.c,v 1.60 2001/05/30 11:40:35 mrg Exp $ */
+/*     $NetBSD: advnops.c,v 1.61 2001/09/15 20:36:32 chs Exp $ */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -144,7 +144,7 @@
        { &vop_update_desc, adosfs_update },            /* update */
        { &vop_bwrite_desc, adosfs_bwrite },            /* bwrite */
        { &vop_getpages_desc, genfs_getpages },         /* getpages */
-       { &vop_size_desc, genfs_size },                 /* size */
+       { &vop_putpages_desc, genfs_putpages },         /* putpages */
        { NULL, NULL }
 };
 
@@ -279,7 +279,7 @@
                        if (bytelen == 0) {
                                break;
                        }
-                       win = ubc_alloc(&vp->v_uvm.u_obj, uio->uio_offset,
+                       win = ubc_alloc(&vp->v_uobj, uio->uio_offset,
                                        &bytelen, UBC_READ);
                        error = uiomove(win, bytelen, uio);
                        ubc_release(win, 0);
@@ -314,8 +314,6 @@
                        brelse(bp);
                        goto reterr;
                }
-               sp->a_vp->v_lastr = lbn;
-
                if (!IS_FFS(amp)) {
                        if (bp->b_resid > 0)
                                error = EIO; /* OFS needs the complete block */
@@ -875,7 +873,7 @@
 #endif
        VOP_UNLOCK(vp, 0);
        /* XXX this needs to check if file was deleted */
-       vrecycle(vp, (struct simplelock *)0, p);
+       vrecycle(vp, NULL, p);
 
 #ifdef ADOSFS_DIAGNOSTIC
        printf(" 0)");
@@ -913,7 +911,6 @@
        return(0);
 }
 
-
 /*
  * POSIX pathconf info, grabbed from kern/u fs, probably need to 
  * investigate exactly what each return type means as they are probably
diff -r 97f03c26ec60 -r 53125d1d3690 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Sat Sep 15 19:51:38 2001 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Sat Sep 15 20:36:31 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.187 2001/08/31 04:44:54 simonb Exp $ */
+/* $NetBSD: pmap.c,v 1.188 2001/09/15 20:36:32 chs Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -154,7 +154,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.187 2001/08/31 04:44:54 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.188 2001/09/15 20:36:32 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1482,10 +1482,6 @@
                PMAP_HEAD_TO_MAP_LOCK();
                simple_lock(&pg->mdpage.pvh_slock);
                for (pv = pg->mdpage.pvh_list; pv != NULL; pv = pv->pv_next) {
-                       /* XXX Don't write-protect pager mappings. */
-                       if (pv->pv_va >= uvm.pager_sva &&
-                           pv->pv_va < uvm.pager_eva)
-                               continue;
                        PMAP_LOCK(pv->pv_pmap);
                        if (*pv->pv_pte & (PG_KWE | PG_UWE)) {
                                *pv->pv_pte &= ~(PG_KWE | PG_UWE);
diff -r 97f03c26ec60 -r 53125d1d3690 sys/arch/arm/arm32/pmap.c
--- a/sys/arch/arm/arm32/pmap.c Sat Sep 15 19:51:38 2001 +0000
+++ b/sys/arch/arm/arm32/pmap.c Sat Sep 15 20:36:31 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.22 2001/09/13 23:56:01 chris Exp $  */
+/*     $NetBSD: pmap.c,v 1.23 2001/09/15 20:36:33 chs Exp $    */
 
 /*
  * Copyright (c) 2001 Richard Earnshaw
@@ -142,7 +142,7 @@
 #include <machine/param.h>
 #include <machine/katelib.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.22 2001/09/13 23:56:01 chris Exp $");        
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.23 2001/09/15 20:36:33 chs Exp $");        
 #ifdef PMAP_DEBUG
 #define        PDEBUG(_lev_,_stat_) \
        if (pmap_debug_level >= (_lev_)) \
@@ -563,36 +563,22 @@
         * if not, try to allocate one.
         */
 
-       s = splvm();   /* must protect kmem_map/kmem_object with splvm! */
+
        if (pv_cachedva == 0) {
-               pv_cachedva = uvm_km_kmemalloc(kmem_map, uvmexp.kmem_object,
+               s = splvm();
+               pv_cachedva = uvm_km_kmemalloc(kmem_map, NULL,
                    PAGE_SIZE, UVM_KMF_TRYLOCK|UVM_KMF_VALLOC);
+               splx(s);
                if (pv_cachedva == 0) {
-                       splx(s);
                        return (NULL);
                }
        }
 
-       /*
-        * we have a VA, now let's try and allocate a page in the object
-        * note: we are still holding splvm to protect kmem_object
-        */
-
-       if (!simple_lock_try(&uvmexp.kmem_object->vmobjlock)) {
-               splx(s);
-               return (NULL);
-       }
-
-       pg = uvm_pagealloc(uvmexp.kmem_object, pv_cachedva -
-                          vm_map_min(kernel_map),
-                          NULL, UVM_PGA_USERESERVE);
+       pg = uvm_pagealloc(NULL, pv_cachedva - vm_map_min(kernel_map), NULL,
+           UVM_PGA_USERESERVE);
        if (pg)
                pg->flags &= ~PG_BUSY;  /* never busy */
 
-       simple_unlock(&uvmexp.kmem_object->vmobjlock);
-       splx(s);
-       /* splvm now dropped */
-
        if (pg == NULL)
                return (NULL);
 
@@ -3193,15 +3179,6 @@
         */
        for (pv = pvh->pvh_list; pv; pv = pv->pv_next) {
                va = pv->pv_va;
-
-               /*
-                * XXX don't write protect pager mappings
-                */
-               if (va >= uvm.pager_sva && va < uvm.pager_eva) {
-                       printf("pmap_clearbit: found page VA on pv_list\n");
-                       continue;
-               }
-
                pv->pv_flags &= ~maskbits;
                pte = pmap_pte(pv->pv_pmap, va);
                KASSERT(pte != NULL);
diff -r 97f03c26ec60 -r 53125d1d3690 sys/arch/i386/i386/pmap.c
--- a/sys/arch/i386/i386/pmap.c Sat Sep 15 19:51:38 2001 +0000
+++ b/sys/arch/i386/i386/pmap.c Sat Sep 15 20:36:31 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.129 2001/09/10 21:19:15 chris Exp $ */
+/*     $NetBSD: pmap.c,v 1.130 2001/09/15 20:36:33 chs Exp $   */
 
 /*
  *
@@ -892,7 +892,7 @@
                npages += (vm_physmem[lcv].end - vm_physmem[lcv].start);
        s = (vsize_t) (sizeof(struct pv_head) * npages +
                       sizeof(char) * npages);
-       s = round_page(s); /* round up */
+       s = round_page(s);
        addr = (vaddr_t) uvm_km_zalloc(kernel_map, s);
        if (addr == 0)
                panic("pmap_init: unable to allocate pv_heads");
@@ -978,19 +978,15 @@
        struct pv_entry *pv;
 
        simple_lock(&pvalloc_lock);
-
-       if (pv_freepages.tqh_first != NULL) {
-               pvpage = pv_freepages.tqh_first;
+       pvpage = TAILQ_FIRST(&pv_freepages);
+       if (pvpage != NULL) {
                pvpage->pvinfo.pvpi_nfree--;
                if (pvpage->pvinfo.pvpi_nfree == 0) {
                        /* nothing left in this one? */
                        TAILQ_REMOVE(&pv_freepages, pvpage, pvinfo.pvpi_list);
                }
                pv = pvpage->pvinfo.pvpi_pvfree;
-#ifdef DIAGNOSTIC
-               if (pv == NULL)
-                       panic("pmap_alloc_pv: pvpi_nfree off");
-#endif
+               KASSERT(pv);
                pvpage->pvinfo.pvpi_pvfree = pv->pv_next;
                pv_nfpvents--;  /* took one from pool */
        } else {
@@ -1009,7 +1005,6 @@
                else
                        (void) pmap_alloc_pvpage(pmap, ALLOCPV_NONEED);
        }
-
        simple_unlock(&pvalloc_lock);
        return(pv);
 }
@@ -1040,22 +1035,18 @@
         * if we need_entry and we've got unused pv_pages, allocate from there
         */
 
-       if (mode != ALLOCPV_NONEED && pv_unusedpgs.tqh_first != NULL) {
+       pvpage = TAILQ_FIRST(&pv_unusedpgs);
+       if (mode != ALLOCPV_NONEED && pvpage != NULL) {
 
                /* move it to pv_freepages list */
-               pvpage = pv_unusedpgs.tqh_first;
                TAILQ_REMOVE(&pv_unusedpgs, pvpage, pvinfo.pvpi_list);
                TAILQ_INSERT_HEAD(&pv_freepages, pvpage, pvinfo.pvpi_list);
 
                /* allocate a pv_entry */
                pvpage->pvinfo.pvpi_nfree--;    /* can't go to zero */
                pv = pvpage->pvinfo.pvpi_pvfree;
-#ifdef DIAGNOSTIC
-               if (pv == NULL)
-                       panic("pmap_alloc_pvpage: pvpi_nfree off");
-#endif
+               KASSERT(pv);
                pvpage->pvinfo.pvpi_pvfree = pv->pv_next;
-
                pv_nfpvents--;  /* took one from pool */
                return(pv);
        }
@@ -1065,38 +1056,20 @@
         * if not, try to allocate one.
         */
 
-       s = splvm();   /* must protect kmem_map/kmem_object with splvm! */
        if (pv_cachedva == 0) {
-               pv_cachedva = uvm_km_kmemalloc(kmem_map, uvmexp.kmem_object,
-                   PAGE_SIZE, UVM_KMF_TRYLOCK|UVM_KMF_VALLOC);
+               s = splvm();   /* must protect kmem_map with splvm! */
+               pv_cachedva = uvm_km_kmemalloc(kmem_map, NULL, PAGE_SIZE,
+                   UVM_KMF_TRYLOCK|UVM_KMF_VALLOC);
+               splx(s);
                if (pv_cachedva == 0) {
-                       splx(s);
                        return (NULL);
                }
        }
-
-       /*



Home | Main Index | Thread Index | Old Index