Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm Merge from yamt-pagecache:



details:   https://anonhg.NetBSD.org/src/rev/6539a456d126
branches:  trunk
changeset: 967620:6539a456d126
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Dec 15 21:11:34 2019 +0000

description:
Merge from yamt-pagecache:

- do gang lookup of pages using radixtree.
- remove now unused uvm_object::uo_memq and vm_page::listq.queue.

diffstat:

 sys/arch/hppa/hppa/pmap.c                   |   19 +-
 sys/arch/sparc64/include/pmap.h             |    8 +-
 sys/arch/sparc64/sparc64/pmap.c             |   24 +-
 sys/miscfs/genfs/genfs_io.c                 |  232 +++++++++++----------------
 sys/nfs/nfs_subs.c                          |   15 +-
 sys/rump/librump/rumpkern/Makefile.rumpkern |    3 +-
 sys/rump/librump/rumpkern/vm.c              |    7 +-
 sys/ufs/lfs/lfs_pages.c                     |   71 +------
 sys/uvm/files.uvm                           |    3 +-
 sys/uvm/uvm_aobj.c                          |  107 +++---------
 sys/uvm/uvm_loan.c                          |   15 +-
 sys/uvm/uvm_object.c                        |   16 +-
 sys/uvm/uvm_object.h                        |    3 +-
 sys/uvm/uvm_page.c                          |   33 +--
 sys/uvm/uvm_page.h                          |    4 +-
 sys/uvm/uvm_page_array.c                    |  217 ++++++++++++++++++++++++++
 sys/uvm/uvm_page_array.h                    |   79 +++++++++
 17 files changed, 503 insertions(+), 353 deletions(-)

diffs (truncated from 1608 to 300 lines):

diff -r 1581dd117b49 -r 6539a456d126 sys/arch/hppa/hppa/pmap.c
--- a/sys/arch/hppa/hppa/pmap.c Sun Dec 15 20:33:22 2019 +0000
+++ b/sys/arch/hppa/hppa/pmap.c Sun Dec 15 21:11:34 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.100 2016/12/22 14:47:57 cherry Exp $        */
+/*     $NetBSD: pmap.c,v 1.101 2019/12/15 21:11:34 ad Exp $    */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.100 2016/12/22 14:47:57 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.101 2019/12/15 21:11:34 ad Exp $");
 
 #include "opt_cputype.h"
 
@@ -76,6 +76,7 @@
 #include <sys/mutex.h>
 
 #include <uvm/uvm.h>
+#include <uvm/uvm_page_array.h>
 
 #include <machine/reg.h>
 #include <machine/psl.h>
@@ -395,7 +396,7 @@
                pmap_pde_set(pmap, va, 0);
                pmap->pm_stats.resident_count--;
                if (pmap->pm_ptphint == ptp)
-                       pmap->pm_ptphint = TAILQ_FIRST(&pmap->pm_obj.memq);
+                       pmap->pm_ptphint = NULL;
                ptp->wire_count = 0;
 
                KASSERT((ptp->flags & PG_BUSY) == 0);
@@ -1101,7 +1102,9 @@
 pmap_destroy(pmap_t pmap)
 {
 #ifdef DIAGNOSTIC
+       struct uvm_page_array a;
        struct vm_page *pg;
+       off_t off;
 #endif
        int refs;
 
@@ -1115,12 +1118,18 @@
                return;
 
 #ifdef DIAGNOSTIC
-       while ((pg = TAILQ_FIRST(&pmap->pm_obj.memq))) {
+       uvm_page_array_init(&a);
+       off = 0;
+       mutex_enter(pmap->pm_lock);
+       while ((pg = uvm_page_array_fill_and_peek(&a, &pmap->pm_obj, off, 0, 0))
+           != NULL) {
                pt_entry_t *pde, *epde;
                struct vm_page *spg;
                struct pv_entry *pv, *npv;
                paddr_t pa;
 
+               off = pg->offset + PAGE_SIZE;
+               uvm_page_array_advance(&a);
                KASSERT(pg != pmap->pm_pdir_pg);
                pa = VM_PAGE_TO_PHYS(pg);
 
@@ -1152,6 +1161,8 @@
                }
                DPRINTF(PDB_FOLLOW, ("\n"));
        }
+       mutex_exit(pmap->pm_lock);
+       uvm_page_array_fini(&a);
 #endif
        pmap_sdir_set(pmap->pm_space, 0);
        mutex_enter(pmap->pm_lock);
diff -r 1581dd117b49 -r 6539a456d126 sys/arch/sparc64/include/pmap.h
--- a/sys/arch/sparc64/include/pmap.h   Sun Dec 15 20:33:22 2019 +0000
+++ b/sys/arch/sparc64/include/pmap.h   Sun Dec 15 21:11:34 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.62 2019/01/10 10:33:49 mrg Exp $    */
+/*     $NetBSD: pmap.h,v 1.63 2019/12/15 21:11:34 ad Exp $     */
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -126,10 +126,8 @@
 #endif
 
 struct pmap {
-       struct uvm_object pm_obj;
-       kmutex_t pm_obj_lock;
-#define pm_lock pm_obj.vmobjlock
-#define pm_refs pm_obj.uo_refs
+       unsigned int pm_refs;
+       TAILQ_HEAD(, vm_page) pm_ptps;
        LIST_ENTRY(pmap) pm_list[PMAP_LIST_MAXNUMCPU];  /* per cpu ctx used list */
 
        struct pmap_statistics pm_stats;
diff -r 1581dd117b49 -r 6539a456d126 sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c   Sun Dec 15 20:33:22 2019 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c   Sun Dec 15 21:11:34 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.310 2019/01/10 10:33:49 mrg Exp $   */
+/*     $NetBSD: pmap.c,v 1.311 2019/12/15 21:11:34 ad Exp $    */
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.310 2019/01/10 10:33:49 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.311 2019/12/15 21:11:34 ad Exp $");
 
 #undef NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define        HWREF
@@ -1473,10 +1473,8 @@
        memset(pm, 0, sizeof *pm);
        DPRINTF(PDB_CREATE, ("pmap_create(): created %p\n", pm));
 
-       mutex_init(&pm->pm_obj_lock, MUTEX_DEFAULT, IPL_NONE);
-       uvm_obj_init(&pm->pm_obj, NULL, false, 1);
-       uvm_obj_setlock(&pm->pm_obj, &pm->pm_obj_lock);
-
+       pm->pm_refs = 1;
+       TAILQ_INIT(&pm->pm_ptps);
        if (pm != pmap_kernel()) {
                while (!pmap_get_page(&pm->pm_physaddr)) {
                        uvm_wait("pmap_create");
@@ -1510,7 +1508,7 @@
 #else
 #define pmap_cpus_active 0
 #endif
-       struct vm_page *pg, *nextpg;
+       struct vm_page *pg;
 
        if ((int)atomic_dec_uint_nv(&pm->pm_refs) > 0) {
                return;
@@ -1538,22 +1536,18 @@
 #endif
 
        /* we could be a little smarter and leave pages zeroed */
-       for (pg = TAILQ_FIRST(&pm->pm_obj.memq); pg != NULL; pg = nextpg) {
+       while ((pg = TAILQ_FIRST(&pm->pm_ptps)) != NULL) {
 #ifdef DIAGNOSTIC
                struct vm_page_md *md = VM_PAGE_TO_MD(pg);
 #endif
 
-               KASSERT((pg->flags & PG_MARKER) == 0);
-               nextpg = TAILQ_NEXT(pg, listq.queue);
-               TAILQ_REMOVE(&pm->pm_obj.memq, pg, listq.queue);
+               TAILQ_REMOVE(&pm->pm_ptps, pg, pageq.queue);
                KASSERT(md->mdpg_pvh.pv_pmap == NULL);
                dcache_flush_page_cpuset(VM_PAGE_TO_PHYS(pg), pmap_cpus_active);
                uvm_pagefree(pg);
        }
        pmap_free_page((paddr_t)(u_long)pm->pm_segs, pmap_cpus_active);
 
-       uvm_obj_destroy(&pm->pm_obj, false);
-       mutex_destroy(&pm->pm_obj_lock);
        pool_cache_put(&pmap_cache, pm);
 }
 
@@ -1904,7 +1898,7 @@
                ptpg = PHYS_TO_VM_PAGE(ptp);
                if (ptpg) {
                        ptpg->offset = (uint64_t)va & (0xfffffLL << 23);
-                       TAILQ_INSERT_TAIL(&pm->pm_obj.memq, ptpg, listq.queue);
+                       TAILQ_INSERT_TAIL(&pm->pm_ptps, ptpg, pageq.queue);
                } else {
                        KASSERT(pm == pmap_kernel());
                }
@@ -1916,7 +1910,7 @@
                ptpg = PHYS_TO_VM_PAGE(ptp);
                if (ptpg) {
                        ptpg->offset = (((uint64_t)va >> 43) & 0x3ffLL) << 13;
-                       TAILQ_INSERT_TAIL(&pm->pm_obj.memq, ptpg, listq.queue);
+                       TAILQ_INSERT_TAIL(&pm->pm_ptps, ptpg, pageq.queue);
                } else {
                        KASSERT(pm == pmap_kernel());
                }
diff -r 1581dd117b49 -r 6539a456d126 sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c       Sun Dec 15 20:33:22 2019 +0000
+++ b/sys/miscfs/genfs/genfs_io.c       Sun Dec 15 21:11:34 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_io.c,v 1.77 2019/12/13 20:10:21 ad Exp $ */
+/*     $NetBSD: genfs_io.c,v 1.78 2019/12/15 21:11:34 ad Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.77 2019/12/13 20:10:21 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.78 2019/12/15 21:11:34 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,6 +50,7 @@
 
 #include <uvm/uvm.h>
 #include <uvm/uvm_pager.h>
+#include <uvm/uvm_page_array.h>
 
 static int genfs_do_directio(struct vmspace *, vaddr_t, size_t, struct vnode *,
     off_t, enum uio_rw);
@@ -785,13 +786,6 @@
  *     (e.g. vm_map) before calling flush.
  * => if neither PGO_CLEANIT nor PGO_SYNCIO is set, we will not block
  * => if PGO_ALLPAGES is set, then all pages in the object will be processed.
- * => NOTE: we rely on the fact that the object's memq is a TAILQ and
- *     that new pages are inserted on the tail end of the list.   thus,
- *     we can make a complete pass through the object in one go by starting
- *     at the head and working towards the tail (new pages are put in
- *     front of us).
- * => NOTE: we are allowed to lock the page queues, so the caller
- *     must not be holding the page queue lock.
  *
  * note on "cleaning" object and PG_BUSY pages:
  *     this routine is holding the lock on the object.   the only time
@@ -806,19 +800,6 @@
  *     object we need to wait for the other PG_BUSY pages to clear
  *     off (i.e. we need to do an iosync).   also note that once a
  *     page is PG_BUSY it must stay in its object until it is un-busyed.
- *
- * note on page traversal:
- *     we can traverse the pages in an object either by going down the
- *     linked list in "uobj->memq", or we can go over the address range
- *     by page doing hash table lookups for each address.    depending
- *     on how many pages are in the object it may be cheaper to do one
- *     or the other.   we set "by_list" to true if we are using memq.
- *     if the cost of a hash lookup was equal to the cost of the list
- *     traversal we could compare the number of pages in the start->stop
- *     range to the total number of pages in the object.   however, it
- *     seems that a hash table lookup is more expensive than the linked
- *     list traversal, so we multiply the number of pages in the
- *     range by an estimate of the relatively higher cost of the hash lookup.
  */
 
 int
@@ -841,7 +822,7 @@
 {
        struct uvm_object * const uobj = &vp->v_uobj;
        kmutex_t * const slock = uobj->vmobjlock;
-       off_t off;
+       off_t nextoff;
        int i, error, npages, nback;
        int freeflag;
        /*
@@ -850,8 +831,9 @@
         */
        struct vm_page *pgs[MAXPHYS / MIN_PAGE_SIZE];
 #define MAXPAGES (MAXPHYS / PAGE_SIZE)
-       struct vm_page *pg, *nextpg, *tpg, curmp, endmp;
-       bool wasclean, by_list, needs_clean, yld;
+       struct vm_page *pg, *tpg;
+       struct uvm_page_array a;
+       bool wasclean, needs_clean;
        bool async = (origflags & PGO_SYNCIO) == 0;
        bool pagedaemon = curlwp == uvm.pagedaemon_lwp;
        struct lwp * const l = curlwp ? curlwp : &lwp0;
@@ -944,12 +926,10 @@
 
        error = 0;
        wasclean = (vp->v_numoutput == 0);
-       off = startoff;
+       nextoff = startoff;
        if (endoff == 0 || flags & PGO_ALLPAGES) {
                endoff = trunc_page(LLONG_MAX);
        }
-       by_list = (uobj->uo_npages <=
-           ((endoff - startoff) >> PAGE_SHIFT) * UVM_PAGE_TREE_PENALTY);
 
        /*
         * if this vnode is known not to have dirty pages,
@@ -966,10 +946,7 @@
        }
 
        /*
-        * start the loop.  when scanning by list, hold the last page
-        * in the list before we start.  pages allocated after we start
-        * will be added to the end of the list, so we can stop at the
-        * current last page.
+        * start the loop to scan pages.
         */
 
        cleanall = (flags & PGO_CLEANIT) != 0 && wasclean &&
@@ -977,51 +954,48 @@
            (vp->v_iflag & VI_ONWORKLST) != 0;
        dirtygen = gp->g_dirtygen;
        freeflag = pagedaemon ? PG_PAGEOUT : PG_RELEASED;
-       if (by_list) {
-               curmp.flags = PG_MARKER;
-               endmp.flags = PG_MARKER;
-               pg = TAILQ_FIRST(&uobj->memq);
-               TAILQ_INSERT_TAIL(&uobj->memq, &endmp, listq.queue);
-       } else {
-               pg = uvm_pagelookup(uobj, off);
-       }
-       nextpg = NULL;
-       while (by_list || off < endoff) {



Home | Main Index | Thread Index | Old Index