head    1.4;
access;
symbols;
locks
       cherry:1.4; strict;
comment @# @;


1.4
date    2016.12.22.16.18.14;    author cherry;  state Exp;
branches;
next    1.3;

1.3
date    2016.12.22.11.19.46;    author cherry;  state Exp;
branches;
next    1.2;

1.2
date    2016.12.22.09.31.46;    author cherry;  state Exp;
branches;
next    1.1;

1.1
date    2016.12.19.13.19.31;    author cherry;  state Exp;
branches;
next    ;


desc
@Post commit MD stuff for uvm_hotplug(9)
@


1.4
log
@This is hopefully the final diff - it's the last chunk that will truly enable the hotplug feature.
@
text
@Index: arch/acorn26/acorn26/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn26/acorn26/pmap.c,v
retrieving revision 1.36
diff -u -r1.36 pmap.c
--- arch/acorn26/acorn26/pmap.c 11 May 2012 15:39:17 -0000      1.36
+++ arch/acorn26/acorn26/pmap.c 22 Dec 2016 16:13:10 -0000
@@@@ -293,19 +293,26 @@@@
vaddr_t
pmap_steal_memory(vsize_t size, vaddr_t *vstartp, vaddr_t *vendp)
{
-       int i;
       vaddr_t addr;
+       uvm_physseg_t bank;
+
       UVMHIST_FUNC("pmap_steal_memory");

       UVMHIST_CALLED(pmaphist);
       addr = 0;
       size = round_page(size);
-       for (i = 0; i < vm_nphysseg; i++) {
-               if (VM_PHYSMEM_PTR(i)->avail_start < VM_PHYSMEM_PTR(i)->avail_end) {
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               if (uvm_physseg_get_avail_start(bank) < uvm_physseg_get_avail_end(bank)) {
+                       paddr_t avail_start = uvm_physseg_get_avail_start(bank);
+
                       addr = (vaddr_t)
                           ((char*)MEMC_PHYS_BASE +
-                               ptoa(VM_PHYSMEM_PTR(i)->avail_start));
-                       VM_PHYSMEM_PTR(i)->avail_start++;
+                               ptoa(avail_start));
+                       avail_start++;
+                       uvm_physseg_set_avail_start(avail_start);
+
                       break;
               }
       }
Index: arch/alpha/alpha/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/machdep.c,v
retrieving revision 1.348
diff -u -r1.348 machdep.c
--- arch/alpha/alpha/machdep.c  22 Dec 2016 14:47:54 -0000      1.348
+++ arch/alpha/alpha/machdep.c  22 Dec 2016 16:13:10 -0000
@@@@ -227,7 +227,6 @@@@
       struct mddt *mddtp;
       struct mddt_cluster *memc;
       int i, mddtweird;
-       struct vm_physseg *vps;
       struct pcb *pcb0;
       vaddr_t kernstart, kernend, v;
       paddr_t kernstartpfn, kernendpfn, pfn0, pfn1;
@@@@ -611,23 +610,24 @@@@
        * Initialize error message buffer (at end of core).
        */
       {
+               paddr_t end;
               vsize_t sz = (vsize_t)round_page(MSGBUFSIZE);
               vsize_t reqsz = sz;
+               uvm_physseg_t bank;

-               vps = VM_PHYSMEM_PTR(vm_nphysseg - 1);
+               bank = uvm_physseg_get_last();

               /* shrink so that it'll fit in the last segment */
-               if ((vps->avail_end - vps->avail_start) < atop(sz))
-                       sz = ptoa(vps->avail_end - vps->avail_start);
+               if (uvm_physseg_get_avail_end(bank) - uvm_physseg_get_avail_start(bank) < atop(sz))
+                       sz = ptoa(uvm_physseg_get_avail_end(bank) - uvm_physseg_get_avail_start(bank));

-               vps->end -= atop(sz);
-               vps->avail_end -= atop(sz);
-               msgbufaddr = (void *) ALPHA_PHYS_TO_K0SEG(ptoa(vps->end));
-               initmsgbuf(msgbufaddr, sz);
+               end = uvm_physseg_get_end(bank);
+               end -= atop(sz);
+
+               uvm_physseg_unplug(end, atop(sz));
+               msgbufaddr = (void *) ALPHA_PHYS_TO_K0SEG(ptoa(end));

-               /* Remove the last segment if it now has no pages. */
-               if (vps->start == vps->end)
-                       vm_nphysseg--;
+               initmsgbuf(msgbufaddr, sz);

               /* warn if the message buffer had to be shrunk */
               if (sz != reqsz)
Index: arch/alpha/alpha/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/pmap.c,v
retrieving revision 1.260
diff -u -r1.260 pmap.c
--- arch/alpha/alpha/pmap.c     5 Nov 2015 06:26:15 -0000       1.260
+++ arch/alpha/alpha/pmap.c     22 Dec 2016 16:13:11 -0000
@@@@ -784,8 +784,8 @@@@
        * the fact that BSEARCH sorts the vm_physmem[] array
        * for us.
        */
-       avail_start = ptoa(VM_PHYSMEM_PTR(0)->start);
-       avail_end = ptoa(VM_PHYSMEM_PTR(vm_nphysseg - 1)->end);
+       avail_start = ptoa(uvm_physseg_get_avail_start(uvm_physseg_get_first()));
+       avail_end = ptoa(uvm_physseg_get_avail_end(uvm_physseg_get_last()));
       virtual_end = VM_MIN_KERNEL_ADDRESS + lev3mapsize * PAGE_SIZE;

#if 0
@@@@ -1007,10 +1007,12 @@@@
vaddr_t
pmap_steal_memory(vsize_t size, vaddr_t *vstartp, vaddr_t *vendp)
{
-       int bank, npgs, x;
+       int npgs;
       vaddr_t va;
-       paddr_t pa;
+       paddr_t pa;

+       uvm_physseg_t bank;
+
       size = round_page(size);
       npgs = atop(size);

@@@@ -1018,50 +1020,36 @@@@
       printf("PSM: size 0x%lx (npgs 0x%x)\n", size, npgs);
#endif

-       for (bank = 0; bank < vm_nphysseg; bank++) {
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
               if (uvm.page_init_done == true)
                       panic("pmap_steal_memory: called _after_ bootstrap");

#if 0
-               printf("     bank %d: avail_start 0x%lx, start 0x%lx, "
-                   "avail_end 0x%lx\n", bank, VM_PHYSMEM_PTR(bank)->avail_start,
+               printf("     bank %d: avail_start 0x%"PRIxPADDR", start 0x%"PRIxPADDR", "
+                   "avail_end 0x%"PRIxPADDR"\n", bank, VM_PHYSMEM_PTR(bank)->avail_start,
                   VM_PHYSMEM_PTR(bank)->start, VM_PHYSMEM_PTR(bank)->avail_end);
#endif

-               if (VM_PHYSMEM_PTR(bank)->avail_start != VM_PHYSMEM_PTR(bank)->start ||
-                   VM_PHYSMEM_PTR(bank)->avail_start >= VM_PHYSMEM_PTR(bank)->avail_end)
+               if (uvm_physseg_get_avail_start(bank) != uvm_physseg_get_start(bank) ||
+                   uvm_physseg_get_avail_start(bank) >= uvm_physseg_get_avail_end(bank))
                       continue;

#if 0
-               printf("             avail_end - avail_start = 0x%lx\n",
+               printf("             avail_end - avail_start = 0x%"PRIxPADDR"\n",
                   VM_PHYSMEM_PTR(bank)->avail_end - VM_PHYSMEM_PTR(bank)->avail_start);
#endif

-               if ((VM_PHYSMEM_PTR(bank)->avail_end - VM_PHYSMEM_PTR(bank)->avail_start)
+               if (uvm_physseg_get_avail_end(bank) - uvm_physseg_get_avail_start(bank)
                   < npgs)
                       continue;

               /*
                * There are enough pages here; steal them!
                */
-               pa = ptoa(VM_PHYSMEM_PTR(bank)->avail_start);
-               VM_PHYSMEM_PTR(bank)->avail_start += npgs;
-               VM_PHYSMEM_PTR(bank)->start += npgs;
-
-               /*
-                * Have we used up this segment?
-                */
-               if (VM_PHYSMEM_PTR(bank)->avail_start == VM_PHYSMEM_PTR(bank)->end) {
-                       if (vm_nphysseg == 1)
-                               panic("pmap_steal_memory: out of memory!");
-
-                       /* Remove this segment from the list. */
-                       vm_nphysseg--;
-                       for (x = bank; x < vm_nphysseg; x++) {
-                               /* structure copy */
-                               VM_PHYSMEM_PTR_SWAP(x, x + 1);
-                       }
-               }
+               pa = ptoa(uvm_physseg_get_start(bank));
+               uvm_physseg_unplug(atop(pa), npgs);

               va = ALPHA_PHYS_TO_K0SEG(pa);
               memset((void *)va, 0, size);
Index: arch/amd64/amd64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/machdep.c,v
retrieving revision 1.241
diff -u -r1.241 machdep.c
--- arch/amd64/amd64/machdep.c  22 Dec 2016 14:47:54 -0000      1.241
+++ arch/amd64/amd64/machdep.c  22 Dec 2016 16:13:11 -0000
@@@@ -789,6 +789,7 @@@@
       paddr_t p, pstart, pend;
       struct vm_page *pg;
       int i;
+       uvm_physseg_t upm;

       /*
        * Mark all memory pages, then unmark pages that are uninteresting.
@@@@ -805,10 +806,25 @@@@
                       setbit(sparse_dump_physmap, p);
               }
       }
-       for (i = 0; i < vm_nphysseg; i++) {
-               struct vm_physseg *seg = VM_PHYSMEM_PTR(i);
+        for (upm = uvm_physseg_get_first();
+            uvm_physseg_valid_p(upm);
+            upm = uvm_physseg_get_next(upm)) {
+               paddr_t pfn;

-               for (pg = seg->pgs; pg < seg->lastpg; pg++) {
+               if (uvm_physseg_valid_p(upm) == false)
+                       break;
+
+               const paddr_t startpfn = uvm_physseg_get_start(upm);
+               const paddr_t endpfn = uvm_physseg_get_end(upm);
+
+               KASSERT(startpfn != -1 && endpfn != -1);
+
+               /*
+                * We assume that seg->start to seg->end are
+                * uvm_page_physload()ed
+                */
+               for (pfn = startpfn; pfn <= endpfn; pfn++) {
+                       pg = PHYS_TO_VM_PAGE(ptoa(pfn));
                       if (pg->uanon || (pg->pqflags & PQ_FREE) ||
                           (pg->uobject && pg->uobject->pgops)) {
                               p = VM_PAGE_TO_PHYS(pg) / PAGE_SIZE;
@@@@ -1452,57 +1468,30 @@@@
static void
init_x86_64_msgbuf(void)
{
-       /* Message buffer is located at end of core. */
-       struct vm_physseg *vps;
-       psize_t sz = round_page(MSGBUFSIZE);
-       psize_t reqsz = sz;
-       int x;
-
- search_again:
-       vps = NULL;
-
-       for (x = 0; x < vm_nphysseg; x++) {
-               vps = VM_PHYSMEM_PTR(x);
-               if (ctob(vps->avail_end) == avail_end)
-                       break;
-       }
-       if (x == vm_nphysseg)
-               panic("init_x86_64: can't find end of memory");
+        /* Message buffer is located at end of core. */
+       psize_t reqsz = round_page(MSGBUFSIZE);
+       psize_t sz = 0;

-       /* Shrink so it'll fit in the last segment. */
-       if ((vps->avail_end - vps->avail_start) < atop(sz))
-               sz = ctob(vps->avail_end - vps->avail_start);
-
-       vps->avail_end -= atop(sz);
-       vps->end -= atop(sz);
-            msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
-            msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(vps->avail_end);
-
-       /* Remove the last segment if it now has no pages. */
-       if (vps->start == vps->end) {
-               for (vm_nphysseg--; x < vm_nphysseg; x++)
-                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
-       }
-
-       /* Now find where the new avail_end is. */
-       for (avail_end = 0, x = 0; x < vm_nphysseg; x++)
-               if (VM_PHYSMEM_PTR(x)->avail_end > avail_end)
-                       avail_end = VM_PHYSMEM_PTR(x)->avail_end;
-       avail_end = ctob(avail_end);
+       for (sz = 0; sz < reqsz; sz += PAGE_SIZE) {
+               paddr_t stolenpa;

-       if (sz == reqsz)
-               return;
+               if (!uvm_page_physget(&stolenpa))
+                       break;

-       reqsz -= sz;
-       if (msgbuf_p_cnt == VM_PHYSSEG_MAX) {
-               /* No more segments available, bail out. */
-               printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n",
-                   (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz));
-               return;
+               if (stolenpa == (msgbuf_p_seg[msgbuf_p_cnt].paddr
+                       + PAGE_SIZE)) {
+                       /* contiguous: append it to current buf alloc */
+                       msgbuf_p_seg[msgbuf_p_cnt].sz += PAGE_SIZE;
+               } else  {
+                       /* non-contiguous: start a new msgbuf seg */
+                       msgbuf_p_seg[msgbuf_p_cnt].sz = PAGE_SIZE;
+                       msgbuf_p_seg[msgbuf_p_cnt++].paddr = stolenpa;
+               }
       }

-       sz = reqsz;
-       goto search_again;
+       if (sz != reqsz)
+               printf("%s: could only allocate %ld bytes of requested %ld bytes\n",
+                   __func__, sz, reqsz);
}

static void
Index: arch/arm/arm32/bus_dma.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/bus_dma.c,v
retrieving revision 1.96
diff -u -r1.96 bus_dma.c
--- arch/arm/arm32/bus_dma.c    5 Nov 2016 14:26:23 -0000       1.96
+++ arch/arm/arm32/bus_dma.c    22 Dec 2016 16:13:11 -0000
@@@@ -1365,11 +1365,11 @@@@
                * The page can only be direct mapped if was allocated out
                * of the arm poolpage vm freelist.
                */
-               int lcv = vm_physseg_find(atop(pa), NULL);
-               KASSERT(lcv != -1);
+               uvm_physseg_t upm = uvm_physseg_find(atop(pa), NULL);
+               KASSERT(uvm_physseg_valid_p(upm));
               if (direct_mapable) {
                       direct_mapable =
-                           (arm_poolpage_vmfreelist == VM_PHYSMEM_PTR(lcv)->free_list);
+                           (arm_poolpage_vmfreelist == uvm_physseg_get_free_list(upm));
               }
#endif

Index: arch/arm/arm32/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/pmap.c,v
retrieving revision 1.341
diff -u -r1.341 pmap.c
--- arch/arm/arm32/pmap.c       17 Dec 2016 14:36:29 -0000      1.341
+++ arch/arm/arm32/pmap.c       22 Dec 2016 16:13:11 -0000
@@@@ -6453,8 +6453,8 @@@@
        * One could argue whether this should be the entire memory or just
        * the memory that is useable in a user process.
        */
-       avail_start = ptoa(VM_PHYSMEM_PTR(0)->start);
-       avail_end = ptoa(VM_PHYSMEM_PTR(vm_nphysseg - 1)->end);
+       avail_start = ptoa(uvm_physseg_get_avail_start(uvm_physseg_get_first()));
+       avail_end = ptoa(uvm_physseg_get_avail_end(uvm_physseg_get_last()));

       /*
        * Now we need to free enough pv_entry structures to allow us to get
Index: arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.771
diff -u -r1.771 machdep.c
--- arch/i386/i386/machdep.c    22 Dec 2016 14:47:58 -0000      1.771
+++ arch/i386/i386/machdep.c    22 Dec 2016 16:13:23 -0000
@@@@ -1037,57 +1037,30 @@@@
static void
init386_msgbuf(void)
{
-       /* Message buffer is located at end of core. */
-       struct vm_physseg *vps;
-       psize_t sz = round_page(MSGBUFSIZE);
-       psize_t reqsz = sz;
-       unsigned int x;
-
- search_again:
-       vps = NULL;
-       for (x = 0; x < vm_nphysseg; ++x) {
-               vps = VM_PHYSMEM_PTR(x);
-               if (ctob(vps->avail_end) == avail_end) {
-                       break;
-               }
-       }
-       if (x == vm_nphysseg)
-               panic("init386: can't find end of memory");
+        /* Message buffer is located at end of core. */
+       psize_t reqsz = round_page(MSGBUFSIZE);
+       psize_t sz = 0;

-       /* Shrink so it'll fit in the last segment. */
-       if (vps->avail_end - vps->avail_start < atop(sz))
-               sz = ctob(vps->avail_end - vps->avail_start);
-
-       vps->avail_end -= atop(sz);
-       vps->end -= atop(sz);
-       msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
-       msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(vps->avail_end);
-
-       /* Remove the last segment if it now has no pages. */
-       if (vps->start == vps->end) {
-               for (--vm_nphysseg; x < vm_nphysseg; x++)
-                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
-       }
-
-       /* Now find where the new avail_end is. */
-       for (avail_end = 0, x = 0; x < vm_nphysseg; x++)
-               if (VM_PHYSMEM_PTR(x)->avail_end > avail_end)
-                       avail_end = VM_PHYSMEM_PTR(x)->avail_end;
-       avail_end = ctob(avail_end);
+       for (sz = 0; sz < reqsz; sz += PAGE_SIZE) {
+               paddr_t stolenpa;

-       if (sz == reqsz)
-               return;
+               if (!uvm_page_physget(&stolenpa))
+                       break;

-       reqsz -= sz;
-       if (msgbuf_p_cnt == VM_PHYSSEG_MAX) {
-               /* No more segments available, bail out. */
-               printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n",
-                   (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz));
-               return;
+               if (stolenpa == (msgbuf_p_seg[msgbuf_p_cnt].paddr
+                       + PAGE_SIZE)) {
+                       /* contiguous: append it to current buf alloc */
+                       msgbuf_p_seg[msgbuf_p_cnt].sz += PAGE_SIZE;
+               } else  {
+                       /* non-contiguous: start a new msgbuf seg */
+                       msgbuf_p_seg[msgbuf_p_cnt].sz = PAGE_SIZE;
+                       msgbuf_p_seg[msgbuf_p_cnt++].paddr = stolenpa;
+               }
       }

-       sz = reqsz;
-       goto search_again;
+       if (sz != reqsz)
+               printf("%s: could only allocate %ld bytes of requested %ld bytes\n",
+                   __func__, sz, reqsz);
}

#ifndef XEN
Index: arch/ia64/ia64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/ia64/ia64/machdep.c,v
retrieving revision 1.36
diff -u -r1.36 machdep.c
--- arch/ia64/ia64/machdep.c    22 Dec 2016 14:47:58 -0000      1.36
+++ arch/ia64/ia64/machdep.c    22 Dec 2016 16:13:23 -0000
@@@@ -175,18 +175,19 @@@@
        * Display any holes after the first chunk of extended memory.
        */
       if (bootverbose) {
-               int lcv, sizetmp;
-
+               int sizetmp, vm_nphysseg;
+               uvm_physseg_t upm;
+
               printf("Physical memory chunk(s):\n");
-               for (lcv = 0;
-                   lcv < vm_nphysseg || VM_PHYSMEM_PTR(lcv)->avail_end != 0;
-                   lcv++) {
-                       sizetmp = VM_PHYSMEM_PTR(lcv)->avail_end -
-                           VM_PHYSMEM_PTR(lcv)->avail_start;
+               for (vm_nphysseg = 0, upm = uvm_physseg_get_first();
+                    uvm_physseg_valid_p(upm);
+                    vm_nphysseg++, upm = uvm_physseg_get_next(upm)) {
+                       sizetmp = uvm_physseg_get_avail_end(upm) -
+                           uvm_physseg_get_avail_start(upm);

                       printf("0x%016lx - 0x%016lx, %ld bytes (%d pages)\n",
-                           ptoa(VM_PHYSMEM_PTR(lcv)->avail_start),
-                               ptoa(VM_PHYSMEM_PTR(lcv)->avail_end) - 1,
+                           ptoa(uvm_physseg_get_avail_start(upm)),
+                           ptoa(uvm_physseg_get_avail_end(upm)) - 1,
                                   ptoa(sizetmp), sizetmp);
               }
               printf("Total number of segments: vm_nphysseg = %d \n",
@@@@ -467,7 +468,6 @@@@
       uvmexp.pagesize = PAGE_SIZE;
       uvm_md_init();

-
       /*
        * Find out how much memory is available, by looking at
        * the memory descriptors.
Index: arch/ia64/ia64/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/ia64/ia64/pmap.c,v
retrieving revision 1.32
diff -u -r1.32 pmap.c
--- arch/ia64/ia64/pmap.c       10 Mar 2014 13:47:45 -0000      1.32
+++ arch/ia64/ia64/pmap.c       22 Dec 2016 16:13:23 -0000
@@@@ -94,6 +94,7 @@@@
#include <sys/lock.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/pal.h>
#include <machine/atomic.h>
@@@@ -316,47 +317,33 @@@@
vaddr_t
pmap_steal_memory(vsize_t size, vaddr_t *vstartp, vaddr_t *vendp)
{
-       int lcv, npgs, x;
+       int npgs;
+       uvm_physseg_t upm;
       vaddr_t va;
       paddr_t pa;

       size = round_page(size);
       npgs = atop(size);

-       for (lcv = 0; lcv < vm_nphysseg; lcv++) {
+       for (upm = uvm_physseg_get_first();
+            uvm_physseg_valid_p(upm);
+            upm = uvm_physseg_get_next(upm)) {
               if (uvm.page_init_done == true)
                       panic("pmap_steal_memory: called _after_ bootstrap");

-               if (VM_PHYSMEM_PTR(lcv)->avail_start != VM_PHYSMEM_PTR(lcv)->start ||
-                   VM_PHYSMEM_PTR(lcv)->avail_start >= VM_PHYSMEM_PTR(lcv)->avail_end)
+               if (uvm_physseg_get_avail_start(upm) != uvm_physseg_get_start(upm) ||
+                   uvm_physseg_get_avail_start(upm) >= uvm_physseg_get_avail_end(upm))
                       continue;

-               if ((VM_PHYSMEM_PTR(lcv)->avail_end - VM_PHYSMEM_PTR(lcv)->avail_start)
+               if ((uvm_physseg_get_avail_end(upm) - uvm_physseg_get_avail_start(upm))
                   < npgs)
                       continue;

               /*
                * There are enough pages here; steal them!
                */
-               pa = ptoa(VM_PHYSMEM_PTR(lcv)->avail_start);
-               VM_PHYSMEM_PTR(lcv)->avail_start += npgs;
-               VM_PHYSMEM_PTR(lcv)->start += npgs;
-
-               /*
-                * Have we used up this segment?
-                */
-               if (VM_PHYSMEM_PTR(lcv)->avail_start ==
-                   VM_PHYSMEM_PTR(lcv)->end) {
-                       if (vm_nphysseg == 1)
-                               panic("pmap_steal_memory: out of memory!");
-
-                       /* Remove this segment from the list. */
-                       vm_nphysseg--;
-                       for (x = lcv; x < vm_nphysseg; x++) {
-                               /* structure copy */
-                               VM_PHYSMEM_PTR_SWAP(x, x + 1);
-                       }
-               }
+               pa = ptoa(uvm_physseg_get_start(bank));
+               uvm_physseg_unplug(atop(pa), npgs);

               va = IA64_PHYS_TO_RR7(pa);
               memset((void *)va, 0, size);
@@@@ -380,31 +367,34 @@@@
static vaddr_t
pmap_steal_vhpt_memory(vsize_t size)
{
-       int lcv, npgs, x;
+       int npgs;
+       uvm_physseg_t upm;
       vaddr_t va;
-       paddr_t pa;
+       paddr_t tmppa, pa = 0;
       paddr_t vhpt_start = 0, start1, start2, end1, end2;

       size = round_page(size);
       npgs = atop(size);

-       for (lcv = 0; lcv < vm_nphysseg; lcv++) {
+       for (upm = uvm_physseg_get_first();
+            uvm_physseg_valid_p(upm);
+            upm = uvm_physseg_get_next(upm)) {
               if (uvm.page_init_done == true)
                       panic("pmap_vhpt_steal_memory: called _after_ bootstrap");

-               if (VM_PHYSMEM_PTR(lcv)->avail_start != VM_PHYSMEM_PTR(lcv)->start || /* XXX: ??? */
-                   VM_PHYSMEM_PTR(lcv)->avail_start >= VM_PHYSMEM_PTR(lcv)->avail_end)
+               if (uvm_physseg_get_avail_start(upm) != uvm_physseg_get_start(upm) || /* XXX: ??? */
+                   uvm_physseg_get_avail_start(upm) >= uvm_physseg_get_avail_end(upm))
                       continue;

               /* Break off a VHPT sized, aligned chunk off this segment. */

-               start1 = VM_PHYSMEM_PTR(lcv)->avail_start;
+               start1 = uvm_physseg_get_avail_start(upm);

               /* Align requested start address on requested size boundary */
               end1 = vhpt_start = roundup(start1, npgs);

               start2 = vhpt_start + npgs;
-               end2 = VM_PHYSMEM_PTR(lcv)->avail_end;
+               end2 = uvm_physseg_get_avail_end(upm);

               /* Case 1: Doesn't fit. skip this segment */

@@@@ -423,7 +413,7 @@@@
                */
               if (start1 == end1 &&
                   start2 == end2 &&
-                   vm_nphysseg == 1) {
+                   uvm_physseg_get_first() == uvm_physseg_get_last() /* single segment */) {
#ifdef DEBUG
                       printf("pmap_vhpt_steal_memory: out of memory!");
#endif
@@@@ -431,11 +421,13 @@@@
               }

               /* Remove this segment from the list. */
-               vm_nphysseg--;
-               for (x = lcv; x < vm_nphysseg; x++)
-                       /* structure copy */
-                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
-
+               if (uvm_physseg_unplug(uvm_physseg_get_start(upm),
+                       uvm_physseg_get_end(upm) - uvm_physseg_get_start(upm)) == false) {
+                       panic("%s: uvm_physseg_unplug(%"PRIxPADDR", %"PRIxPADDR") failed\n",
+                           __func__, uvm_physseg_get_start(upm),
+                           uvm_physseg_get_end(upm) - uvm_physseg_get_start(upm));
+               }
+
               /* Case 2: Perfect fit - skip segment reload. */

               if (start1 == end1 && start2 == end2) break;
Index: arch/luna68k/luna68k/pmap_bootstrap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/luna68k/pmap_bootstrap.c,v
retrieving revision 1.37
diff -u -r1.37 pmap_bootstrap.c
--- arch/luna68k/luna68k/pmap_bootstrap.c       22 Dec 2016 16:05:15 -0000      1.37
+++ arch/luna68k/luna68k/pmap_bootstrap.c       22 Dec 2016 16:13:23 -0000
@@@@ -1,4 +1,4 @@@@
-/*     $NetBSD: pmap_bootstrap.c,v 1.37 2016/12/22 16:05:15 cherry Exp $       */
+/*     $NetBSD: pmap_bootstrap.c,v 1.36 2013/01/26 15:46:24 tsutsui Exp $      */

/*
 * Copyright (c) 1991, 1993
@@@@ -36,7 +36,7 @@@@
 */

#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.37 2016/12/22 16:05:15 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.36 2013/01/26 15:46:24 tsutsui Exp $");

#include "opt_m68k_arch.h"

Index: arch/m68k/m68k/pmap_motorola.c
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/m68k/pmap_motorola.c,v
retrieving revision 1.68
diff -u -r1.68 pmap_motorola.c
--- arch/m68k/m68k/pmap_motorola.c      22 Dec 2016 14:47:58 -0000      1.68
+++ arch/m68k/m68k/pmap_motorola.c      22 Dec 2016 16:13:24 -0000
@@@@ -133,6 +133,7 @@@@
#include <machine/pcb.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <m68k/cacheops.h>

@@@@ -295,10 +296,11 @@@@
static inline struct pv_header *
pa_to_pvh(paddr_t pa)
{
-       int bank, pg = 0;       /* XXX gcc4 -Wuninitialized */
-
-       bank = vm_physseg_find(atop((pa)), &pg);
-       return &VM_PHYSMEM_PTR(bank)->pmseg.pvheader[pg];
+       uvm_physseg_t bank = 0; /* XXX gcc4 -Wuninitialized */
+       psize_t pg = 0;
+
+       bank = uvm_physseg_find(atop((pa)), &pg);
+       return &uvm_physseg_get_pmseg(bank)->pvheader[pg];
}

/*
@@@@ -412,7 +414,7 @@@@
       struct pv_header *pvh;
       int             rv;
       int             npages;
-       int             bank;
+       uvm_physseg_t   bank;

       PMAP_DPRINTF(PDB_FOLLOW, ("pmap_init()\n"));

@@@@ -434,8 +436,10 @@@@
        * Allocate memory for random pmap data structures.  Includes the
        * initial segment table, pv_head_table and pmap_attributes.
        */
-       for (page_cnt = 0, bank = 0; bank < vm_nphysseg; bank++)
-               page_cnt += VM_PHYSMEM_PTR(bank)->end - VM_PHYSMEM_PTR(bank)->start;
+       for (page_cnt = 0, bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank))
+               page_cnt += uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank);
       s = M68K_STSIZE;                                        /* Segtabzero */
       s += page_cnt * sizeof(struct pv_header);       /* pv table */
       s = round_page(s);
@@@@ -461,9 +465,11 @@@@
        * assign them to the memory segments.
        */
       pvh = pv_table;
-       for (bank = 0; bank < vm_nphysseg; bank++) {
-               npages = VM_PHYSMEM_PTR(bank)->end - VM_PHYSMEM_PTR(bank)->start;
-               VM_PHYSMEM_PTR(bank)->pmseg.pvheader = pvh;
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               npages = uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank);
+               uvm_physseg_get_pmseg(bank)->pvheader = pvh;
               pvh += npages;
       }

@@@@ -1704,17 +1710,20 @@@@
static void
pmap_collect(void)
{
-       int bank, s;
-
+       int s;
+       uvm_physseg_t bank;
+
       /*
        * XXX This is very bogus.  We should handle kernel PT
        * XXX pages much differently.
        */

       s = splvm();
-       for (bank = 0; bank < vm_nphysseg; bank++) {
-               pmap_collect1(pmap_kernel(), ptoa(VM_PHYSMEM_PTR(bank)->start),
-                   ptoa(VM_PHYSMEM_PTR(bank)->end));
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               pmap_collect1(pmap_kernel(), ptoa(uvm_physseg_get_start(bank)),
+                   ptoa(uvm_physseg_get_end(bank)));
       }
       splx(s);
}
Index: arch/mips/include/pmap.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/include/pmap.h,v
retrieving revision 1.68
diff -u -r1.68 pmap.h
--- arch/mips/include/pmap.h    11 Jul 2016 16:15:35 -0000      1.68
+++ arch/mips/include/pmap.h    22 Dec 2016 16:13:25 -0000
@@@@ -116,7 +116,7 @@@@
#define PMAP_SEGTAB_ALIGN __aligned(sizeof(void *)*NSEGPG) __section(".data1")
#endif

-struct vm_physseg;
+#include <uvm/uvm_physseg.h>

void   pmap_md_init(void);
void   pmap_md_icache_sync_all(void);
@@@@ -125,7 +125,7 @@@@
bool   pmap_md_vca_add(struct vm_page *, vaddr_t, pt_entry_t *);
void   pmap_md_vca_clean(struct vm_page *, int);
void   pmap_md_vca_remove(struct vm_page *, vaddr_t, bool, bool);
-bool   pmap_md_ok_to_steal_p(const struct vm_physseg *, size_t);
+bool   pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t);
bool   pmap_md_tlb_check_entry(void *, vaddr_t, tlb_asid_t, pt_entry_t);

static inline bool
Index: arch/mips/mips/mips_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/mips_machdep.c,v
retrieving revision 1.275
diff -u -r1.275 mips_machdep.c
--- arch/mips/mips/mips_machdep.c       22 Dec 2016 07:56:38 -0000      1.275
+++ arch/mips/mips/mips_machdep.c       22 Dec 2016 16:13:26 -0000
@@@@ -145,6 +145,7 @@@@
#endif

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/mm.h>
@@@@ -2008,38 +2009,34 @@@@
{
       vsize_t sz = (vsize_t)round_page(MSGBUFSIZE);
       vsize_t reqsz = sz;
-       u_int bank = vm_nphysseg - 1;
-       struct vm_physseg *vps = VM_PHYSMEM_PTR(bank);
+       uvm_physseg_t bank = uvm_physseg_get_last();
#ifndef _LP64
       /*
        * Fist the physical segment that can be mapped to KSEG0
        */
-       for (; vps >= vm_physmem; vps--, bank--) {
-               if (vps->avail_start + atop(sz) <= atop(MIPS_PHYS_MASK))
+       for (; uvm_physseg_valid_p(bank); bank = uvm_physseg_get_prev(bank)) {
+               if (uvm_physseg_get_avail_start(bank) + atop(sz) <= atop(MIPS_PHYS_MASK))
                       break;
       }
#endif

+       paddr_t start = uvm_physseg_get_start(bank);
+       paddr_t end = uvm_physseg_get_end(bank);
+
       /* shrink so that it'll fit in the last segment */
-       if ((vps->avail_end - vps->avail_start) < atop(sz))
-               sz = ptoa(vps->avail_end - vps->avail_start);
+       if ((end - start) < atop(sz))
+               sz = ptoa(end - start);

-       vps->end -= atop(sz);
-       vps->avail_end -= atop(sz);
+       end -= atop(sz);
+       uvm_physseg_unplug(end, atop(sz));
+
#ifdef _LP64
-       msgbufaddr = (void *) MIPS_PHYS_TO_XKPHYS_CACHED(ptoa(vps->end));
+       msgbufaddr = (void *) MIPS_PHYS_TO_XKPHYS_CACHED(ptoa(end));
#else
-       msgbufaddr = (void *) MIPS_PHYS_TO_KSEG0(ptoa(vps->end));
+       msgbufaddr = (void *) MIPS_PHYS_TO_KSEG0(ptoa(end));
#endif
       initmsgbuf(msgbufaddr, sz);

-       /* Remove the [last] segment if it now has no pages. */
-       if (vps->start == vps->end) {
-               for (vm_nphysseg--; bank < vm_nphysseg - 1; bank++) {
-                       VM_PHYSMEM_PTR_SWAP(bank, bank + 1);
-               }
-       }
-
       /* warn if the message buffer had to be shrunk */
       if (sz != reqsz)
               printf("WARNING: %"PRIdVSIZE" bytes not available for msgbuf "
Index: arch/mips/mips/pmap_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/pmap_machdep.c,v
retrieving revision 1.11
diff -u -r1.11 pmap_machdep.c
--- arch/mips/mips/pmap_machdep.c       5 Sep 2016 06:59:25 -0000       1.11
+++ arch/mips/mips/pmap_machdep.c       22 Dec 2016 16:13:26 -0000
@@@@ -133,6 +133,7 @@@@
#endif

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <mips/cache.h>
#include <mips/cpuregs.h>
@@@@ -306,12 +307,12 @@@@
}

bool
-pmap_md_ok_to_steal_p(const struct vm_physseg *seg, size_t npgs)
+pmap_md_ok_to_steal_p(const uvm_physseg_t bank, size_t npgs)
{
#ifndef _LP64
-       if (seg->avail_start + npgs >= atop(MIPS_PHYS_MASK + 1)) {
-               aprint_debug("%s: seg %zu: not enough in KSEG0 for %zu pages\n",
-                   __func__, seg - VM_PHYSMEM_PTR(0), npgs);
+       if (uvm_physseg_get_avail_start(bank) + npgs >= atop(MIPS_PHYS_MASK + 1)) {
+               aprint_debug("%s: seg not enough in KSEG0 for %zu pages\n",
+                   __func__, npgs);
               return false;
       }
#endif
@@@@ -393,8 +394,8 @@@@
        * for us.  Must do this before uvm_pageboot_alloc()
        * can be called.
        */
-       pmap_limits.avail_start = ptoa(VM_PHYSMEM_PTR(0)->start);
-       pmap_limits.avail_end = ptoa(VM_PHYSMEM_PTR(vm_nphysseg - 1)->end);
+       pmap_limits.avail_start = ptoa(uvm_physseg_get_start(uvm_physseg_get_first()));
+       pmap_limits.avail_end = ptoa(uvm_physseg_get_end(uvm_physseg_get_last()));
       pmap_limits.virtual_end = pmap_limits.virtual_start + (vaddr_t)sysmap_size * NBPG;

#ifndef _LP64
Index: arch/powerpc/ibm4xx/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/pmap.c,v
retrieving revision 1.73
diff -u -r1.73 pmap.c
--- arch/powerpc/ibm4xx/pmap.c  22 Dec 2016 14:47:58 -0000      1.73
+++ arch/powerpc/ibm4xx/pmap.c  22 Dec 2016 16:13:27 -0000
@@@@ -199,7 +199,7 @@@@
{
       int bank, pg;

-       bank = vm_physseg_find(atop(pa), &pg);
+       bank = uvm_physseg_find(atop(pa), &pg);
       if (bank == -1)
               return NULL;
       return &VM_PHYSMEM_PTR(bank)->pmseg.pvent[pg];
@@@@ -210,7 +210,7 @@@@
{
       int bank, pg;

-       bank = vm_physseg_find(atop(pa), &pg);
+       bank = uvm_physseg_find(atop(pa), &pg);
       if (bank == -1)
               return NULL;
       return &VM_PHYSMEM_PTR(bank)->pmseg.attrs[pg];
Index: arch/powerpc/isa/isadma_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/isa/isadma_machdep.c,v
retrieving revision 1.10
diff -u -r1.10 isadma_machdep.c
--- arch/powerpc/isa/isadma_machdep.c   26 Feb 2016 18:17:39 -0000      1.10
+++ arch/powerpc/isa/isadma_machdep.c   22 Dec 2016 16:13:27 -0000
@@@@ -168,9 +168,11 @@@@
       size_t cookiesize;
       paddr_t avail_end = 0;

-       for (bank = 0; bank < vm_nphysseg; bank++) {
-               if (avail_end < VM_PHYSMEM_PTR(bank)->avail_end << PGSHIFT)
-                       avail_end = VM_PHYSMEM_PTR(bank)->avail_end << PGSHIFT;
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               if (avail_end < uvm_physseg_get_avail_end(bank) << PGSHIFT)
+                       avail_end = uvm_physseg_get_avail_end(bank) << PGSHIFT;
       }

       /* Call common function to create the basic map. */
@@@@ -598,9 +600,11 @@@@
       paddr_t high, avail_end = 0;
       int bank;

-       for (bank = 0; bank < vm_nphysseg; bank++) {
-               if (avail_end < VM_PHYSMEM_PTR(bank)->avail_end << PGSHIFT)
-                       avail_end = VM_PHYSMEM_PTR(bank)->avail_end << PGSHIFT;
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               if (avail_end < uvm_physseg_get_avail_end(bank) << PGSHIFT)
+                       avail_end = uvm_physseg_get_avail_end(bank) << PGSHIFT;
       }

       if (avail_end > ISA_DMA_BOUNCE_THRESHOLD)
Index: arch/powerpc/oea/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/pmap.c,v
retrieving revision 1.93
diff -u -r1.93 pmap.c
--- arch/powerpc/oea/pmap.c     14 Feb 2016 18:07:49 -0000      1.93
+++ arch/powerpc/oea/pmap.c     22 Dec 2016 16:13:27 -0000
@@@@ -81,6 +81,7 @@@@
#include <sys/atomic.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/powerpc.h>
#include <powerpc/bat.h>
@@@@ -2909,9 +2910,9 @@@@
{
       vsize_t size;
       vaddr_t va;
-       paddr_t pa = 0;
-       int npgs, bank;
-       struct vm_physseg *ps;
+       paddr_t start, end, pa = 0;
+       int npgs, freelist;
+       uvm_physseg_t bank;

       if (uvm.page_init_done == true)
               panic("pmap_steal_memory: called _after_ bootstrap");
@@@@ -2926,11 +2927,18 @@@@
        * PA 0 will never be among those given to UVM so we can use it
        * to indicate we couldn't steal any memory.
        */
-       for (bank = 0; bank < vm_nphysseg; bank++) {
-               ps = VM_PHYSMEM_PTR(bank);
-               if (ps->free_list == VM_FREELIST_FIRST256 &&
-                   ps->avail_end - ps->avail_start >= npgs) {
-                       pa = ptoa(ps->avail_start);
+
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+
+               freelist = uvm_physseg_get_free_list(bank);
+               start = uvm_physseg_get_start(bank);
+               end = uvm_physseg_get_end(bank);
+
+               if (freelist == VM_FREELIST_FIRST256 &&
+                   (end - start) >= npgs) {
+                       pa = ptoa(start);
                       break;
               }
       }
@@@@ -2938,25 +2946,7 @@@@
       if (pa == 0)
               panic("pmap_steal_memory: no approriate memory to steal!");

-       ps->avail_start += npgs;
-       ps->start += npgs;
-
-       /*
-        * If we've used up all the pages in the segment, remove it and
-        * compact the list.
-        */
-       if (ps->avail_start == ps->end) {
-               /*
-                * If this was the last one, then a very bad thing has occurred
-                */
-               if (--vm_nphysseg == 0)
-                       panic("pmap_steal_memory: out of memory!");
-
-               printf("pmap_steal_memory: consumed bank %d\n", bank);
-               for (; bank < vm_nphysseg; bank++, ps++) {
-                       ps[0] = ps[1];
-               }
-       }
+       uvm_physseg_unplug(start, npgs);

       va = (vaddr_t) pa;
       memset((void *) va, 0, size);
@@@@ -2964,9 +2954,10 @@@@
#ifdef DEBUG
       if (pmapdebug && npgs > 1) {
               u_int cnt = 0;
-               for (bank = 0; bank < vm_nphysseg; bank++) {
-                       ps = VM_PHYSMEM_PTR(bank);
-                       cnt += ps->avail_end - ps->avail_start;
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               cnt += uvm_physseg_get_avail_end(bank) - uvm_physseg_get_avail_start(bank);
               }
               printf("pmap_steal_memory: stole %u (total %u) pages (%u left)\n",
                   npgs, pmap_pages_stolen, cnt);
@@@@ -3446,15 +3437,18 @@@@
#ifdef DEBUG
       if (pmapdebug & PMAPDEBUG_BOOT) {
               u_int cnt;
-               int bank;
+               uvm_physseg_t bank;
               char pbuf[9];
-               for (cnt = 0, bank = 0; bank < vm_nphysseg; bank++) {
-                       cnt += VM_PHYSMEM_PTR(bank)->avail_end - VM_PHYSMEM_PTR(bank)->avail_start;
+               for (cnt = 0, bank = uvm_physseg_get_first();
+                    uvm_physseg_valid_p(bank);
+                    bank = uvm_physseg_get_next(bank)) {
+                       cnt += uvm_physseg_get_avail_end(bank) -
+                           uvm_physseg_get_avail_start(bank);
                       printf("pmap_bootstrap: vm_physmem[%d]=%#" _PRIxpa "-%#" _PRIxpa "/%#" _PRIxpa "\n",
                           bank,
-                           ptoa(VM_PHYSMEM_PTR(bank)->avail_start),
-                           ptoa(VM_PHYSMEM_PTR(bank)->avail_end),
-                           ptoa(VM_PHYSMEM_PTR(bank)->avail_end - VM_PHYSMEM_PTR(bank)->avail_start));
+                           ptoa(uvm_physseg_get_avail_start(bank)),
+                           ptoa(uvm_physseg_get_avail_end(bank)),
+                           ptoa(uvm_physseg_get_avail_end(bank) - uvm_physseg_get_avail_start(bank)));
               }
               format_bytes(pbuf, sizeof(pbuf), ptoa((u_int64_t) cnt));
               printf("pmap_bootstrap: UVM memory = %s (%u pages)\n",
Index: arch/powerpc/powerpc/bus_dma.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/bus_dma.c,v
retrieving revision 1.46
diff -u -r1.46 bus_dma.c
--- arch/powerpc/powerpc/bus_dma.c      1 Feb 2012 09:54:03 -0000       1.46
+++ arch/powerpc/powerpc/bus_dma.c      22 Dec 2016 16:13:27 -0000
@@@@ -45,6 +45,7 @@@@
#include <sys/intr.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#ifdef PPC_BOOKE
#define        EIEIO   __asm volatile("mbar\t0")
@@@@ -544,13 +545,15 @@@@
_bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags)
{
       paddr_t start = 0xffffffff, end = 0;
-       int bank;
+       uvm_physseg_t bank;

-       for (bank = 0; bank < vm_nphysseg; bank++) {
-               if (start > ptoa(VM_PHYSMEM_PTR(bank)->avail_start))
-                       start = ptoa(VM_PHYSMEM_PTR(bank)->avail_start);
-               if (end < ptoa(VM_PHYSMEM_PTR(bank)->avail_end))
-                       end = ptoa(VM_PHYSMEM_PTR(bank)->avail_end);
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               if (start > ptoa(uvm_physseg_get_avail_start(bank)))
+                       start = ptoa(uvm_physseg_get_avail_start(bank));
+               if (end < ptoa(uvm_physseg_get_avail_end(bank)))
+                       end = ptoa(uvm_physseg_get_avail_end(bank));
       }

       return _bus_dmamem_alloc_range(t, size, alignment, boundary, segs,
Index: arch/sh3/sh3/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/pmap.c,v
retrieving revision 1.78
diff -u -r1.78 pmap.c
--- arch/sh3/sh3/pmap.c 3 Sep 2016 09:07:54 -0000       1.78
+++ arch/sh3/sh3/pmap.c 22 Dec 2016 16:13:27 -0000
@@@@ -39,6 +39,7 @@@@
#include <sys/socketvar.h>     /* XXX: for sock_loan_thresh */

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <sh3/mmu.h>
#include <sh3/cache.h>
@@@@ -107,8 +108,8 @@@@
       /* Steal msgbuf area */
       initmsgbuf((void *)uvm_pageboot_alloc(MSGBUFSIZE), MSGBUFSIZE);

-       avail_start = ptoa(VM_PHYSMEM_PTR(0)->start);
-       avail_end = ptoa(VM_PHYSMEM_PTR(vm_nphysseg - 1)->end);
+       avail_start = ptoa(uvm_physseg_get_start(uvm_physseg_get_first()));
+       avail_end = ptoa(uvm_physseg_get_end(uvm_physseg_get_last()));
       __pmap_kve = VM_MIN_KERNEL_ADDRESS;

       pmap_kernel()->pm_refcnt = 1;
@@@@ -126,39 +127,28 @@@@
vaddr_t
pmap_steal_memory(vsize_t size, vaddr_t *vstart, vaddr_t *vend)
{
-       struct vm_physseg *bank;
-       int i, j, npage;
+       int npage;
       paddr_t pa;
       vaddr_t va;
+       uvm_physseg_t bank;

       KDASSERT(!uvm.page_init_done);

       size = round_page(size);
       npage = atop(size);

-       bank = NULL;
-       for (i = 0; i < vm_nphysseg; i++) {
-               bank = VM_PHYSMEM_PTR(i);
-               if (npage <= bank->avail_end - bank->avail_start)
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+               if (npage <= uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank))
                       break;
       }
-       KDASSERT(i != vm_nphysseg);
-       KDASSERT(bank != NULL);

-       /* Steal pages */
-       pa = ptoa(bank->avail_start);
-       bank->avail_start += npage;
-       bank->start += npage;
-
-       /* GC memory bank */
-       if (bank->avail_start == bank->end) {
-               /* Remove this segment from the list. */
-               vm_nphysseg--;
-               KDASSERT(vm_nphysseg > 0);
-               for (j = i; i < vm_nphysseg; j++)
-                       VM_PHYSMEM_PTR_SWAP(j, j + 1);
-       }
+       KDASSERT(uvm_physseg_valid_p(bank));

+       /* Steal pages */
+       pa = ptoa(uvm_physseg_get_start(bank));
+       uvm_physseg_unplug(start, npage);
       va = SH3_PHYS_TO_P1SEG(pa);
       memset((void *)va, 0, size);

Index: arch/sh3/sh3/vm_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/vm_machdep.c,v
retrieving revision 1.76
diff -u -r1.76 vm_machdep.c
--- arch/sh3/sh3/vm_machdep.c   7 Nov 2013 21:45:04 -0000       1.76
+++ arch/sh3/sh3/vm_machdep.c   22 Dec 2016 16:13:27 -0000
@@@@ -102,6 +102,7 @@@@

#include <uvm/uvm_extern.h>
#include <uvm/uvm_page.h>
+#include <uvm/uvm_physseg.h>

#include <sh3/locore.h>
#include <sh3/cpu.h>
@@@@ -387,7 +388,7 @@@@
mm_md_physacc(paddr_t pa, vm_prot_t prot)
{

-       if (atop(pa) < vm_physmem[0].start || PHYS_TO_VM_PAGE(pa) != NULL) {
+       if (atop(pa) < uvm_physseg_get_start(uvm_physseg_get_first()) || PHYS_TO_VM_PAGE(pa) != NULL) {
               return 0;
       }
       return EFAULT;
Index: arch/vax/vax/ka650.c
===================================================================
RCS file: /cvsroot/src/sys/arch/vax/vax/ka650.c,v
retrieving revision 1.36
diff -u -r1.36 ka650.c
--- arch/vax/vax/ka650.c        14 Dec 2010 23:44:49 -0000      1.36
+++ arch/vax/vax/ka650.c        22 Dec 2016 16:13:31 -0000
@@@@ -106,7 +106,7 @@@@

       ka650setcache(CACHEON);
       if (ctob(physmem) > ka650merr_ptr->merr_qbmbr) {
-               printf("physmem(0x%x) > qbmbr(0x%x)\n",
+               printf("physmem(%"PRIxPSIZE") > qbmbr(0x%x)\n",
                   ctob(physmem), (int)ka650merr_ptr->merr_qbmbr);
               panic("qbus map unprotected");
       }
Index: arch/vax/vax/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/vax/vax/pmap.c,v
retrieving revision 1.183
diff -u -r1.183 pmap.c
--- arch/vax/vax/pmap.c 22 Dec 2016 14:48:00 -0000      1.183
+++ arch/vax/vax/pmap.c 22 Dec 2016 16:13:31 -0000
@@@@ -51,6 +51,7 @@@@
#include <sys/mutex.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#ifdef PMAPDEBUG
#include <dev/cons.h>
@@@@ -475,7 +476,8 @@@@
{
       vaddr_t v;
       int npgs;
-
+       uvm_physseg_t bank;
+
       PMDEBUG(("pmap_steal_memory: size 0x%lx start %p end %p\n",
                   size, vstartp, vendp));

@@@@ -490,10 +492,10 @@@@
       /*
        * A vax only have one segment of memory.
        */
+       bank = uvm_physseg_get_first();

-       v = (VM_PHYSMEM_PTR(0)->avail_start << PGSHIFT) | KERNBASE;
-       VM_PHYSMEM_PTR(0)->avail_start += npgs;
-       VM_PHYSMEM_PTR(0)->start += npgs;
+       v = (uvm_physseg_get_start(bank) << PGSHIFT) | KERNBASE;
+       uvm_physseg_unplug(uvm_physseg_get_start(bank), npgs);
       memset((void *)v, 0, size);
       return v;
}
Index: arch/x68k/x68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x68k/x68k/machdep.c,v
retrieving revision 1.194
diff -u -r1.194 machdep.c
--- arch/x68k/x68k/machdep.c    2 Dec 2016 12:43:07 -0000       1.194
+++ arch/x68k/x68k/machdep.c    22 Dec 2016 16:13:33 -0000
@@@@ -102,6 +102,7 @@@@

#define        MAXMEM  64*1024 /* XXX - from cmap.h */
#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/bus.h>
#include <machine/autoconf.h>
@@@@ -553,10 +554,7 @@@@
{
       cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
       struct m68k_kcore_hdr *m = &h->un._m68k;
-       psize_t size;
-#ifdef EXTENDED_MEMORY
-       int i, seg;
-#endif
+       uvm_physseg_t i;

       memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));

@@@@ -605,20 +603,25 @@@@
       /*
        * X68k has multiple RAM segments on some models.
        */
-       size = phys_basemem_seg.end - phys_basemem_seg.start;
-       m->ram_segs[0].start = phys_basemem_seg.start;
-       m->ram_segs[0].size  = size;
-#ifdef EXTENDED_MEMORY
-       seg = 1;
-       for (i = 0; i < EXTMEM_SEGS; i++) {
-               size = phys_extmem_seg[i].end - phys_extmem_seg[i].start;
-               if (size == 0)
-                       continue;
-               m->ram_segs[seg].start = phys_extmem_seg[i].start;
-               m->ram_segs[seg].size  = size;
-               seg++;
+       m->ram_segs[0].start = lowram;
+       m->ram_segs[0].size = mem_size - lowram;
+
+       i = uvm_physseg_get_first();
+
+        for (uvm_physseg_get_next(i); uvm_physseg_valid_p(i); i = uvm_physseg_get_next(i)) {
+               if (uvm_physseg_valid_p(i) == false)
+                       break;
+
+               const paddr_t startpfn = uvm_physseg_get_start(i);
+               const paddr_t endpfn = uvm_physseg_get_end(i);
+
+               KASSERT(startpfn != -1 && endpfn != -1);
+
+               m->ram_segs[i].start =
+                   ctob(startpfn);
+               m->ram_segs[i].size  =
+                   ctob(endpfn - startpfn);
       }
-#endif
}

/*
@@@@ -1249,11 +1252,14 @@@@
int
mm_md_physacc(paddr_t pa, vm_prot_t prot)
{
-       int i;
+       uvm_physseg_t i;
+
+       for (i = uvm_physseg_get_first(); uvm_physseg_valid_p(i); i = uvm_physseg_get_next(i)) {
+               if (uvm_physseg_valid_p(i) == false)
+                       break;

-       for (i = 0; i < vm_nphysseg; i++) {
-               if (ctob(vm_physmem[i].start) <= pa &&
-                   pa < ctob(vm_physmem[i].end))
+               if (ctob(uvm_physseg_get_start(i)) <= pa &&
+                   pa < ctob(uvm_physseg_get_end(i)))
                       return 0;
       }
       return EFAULT;
Index: uvm/files.uvm
===================================================================
RCS file: /cvsroot/src/sys/uvm/files.uvm,v
retrieving revision 1.27
diff -u -r1.27 files.uvm
--- uvm/files.uvm       1 Dec 2016 02:09:03 -0000       1.27
+++ uvm/files.uvm       22 Dec 2016 16:13:39 -0000
@@@@ -15,6 +15,7 @@@@
defflag                                PDPOLICY_CLOCKPRO
defparam                       USER_VA0_DISABLE_DEFAULT
defflag opt_uvm_page_trkown.h  UVM_PAGE_TRKOWN
+defflag opt_uvm_hotplug.h      UVM_HOTPLUG

define uvm
defflag        opt_uvm.h                       UVM
@@@@ -42,6 +43,7 @@@@
file   uvm/uvm_pdpolicy_clock.c        !pdpolicy_clockpro
file   uvm/uvm_pdpolicy_clockpro.c     pdpolicy_clockpro
file   uvm/uvm_pglist.c                uvm
+file   uvm/uvm_physseg.c               uvm
file   uvm/uvm_readahead.c             uvm
file   uvm/uvm_stat.c                  uvm
file   uvm/uvm_swap.c                  vmswap
Index: uvm/uvm_init.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_init.c,v
retrieving revision 1.47
diff -u -r1.47 uvm_init.c
--- uvm/uvm_init.c      22 Dec 2016 12:55:21 -0000      1.47
+++ uvm/uvm_init.c      22 Dec 2016 16:13:39 -0000
@@@@ -46,6 +46,7 @@@@

#include <uvm/uvm.h>
#include <uvm/uvm_pdpolicy.h>
+#include <uvm/uvm_physseg.h>
#include <uvm/uvm_readahead.h>

/*
@@@@ -77,6 +78,7 @@@@
uvm_md_init(void)
{
       uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
}

/*
Index: uvm/uvm_page.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_page.c,v
retrieving revision 1.189
diff -u -r1.189 uvm_page.c
--- uvm/uvm_page.c      22 Dec 2016 16:05:15 -0000      1.189
+++ uvm/uvm_page.c      22 Dec 2016 16:13:39 -0000
@@@@ -1,4 +1,4 @@@@
-/*     $NetBSD: uvm_page.c,v 1.189 2016/12/22 16:05:15 cherry Exp $    */
+/*     $NetBSD: uvm_page.c,v 1.188 2016/12/22 13:26:25 cherry Exp $    */

/*
 * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@@@ -66,7 +66,7 @@@@
 */

#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.189 2016/12/22 16:05:15 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.188 2016/12/22 13:26:25 cherry Exp $");

#include "opt_ddb.h"
#include "opt_uvm.h"
@@@@ -81,24 +81,13 @@@@
#include <sys/proc.h>
#include <sys/atomic.h>
#include <sys/cpu.h>
+#include <sys/extent.h>

#include <uvm/uvm.h>
#include <uvm/uvm_ddb.h>
#include <uvm/uvm_pdpolicy.h>

/*
- * global vars... XXXCDC: move to uvm. structure.
- */
-
-/*
- * physical memory config is stored in vm_physmem.
- */
-
-struct vm_physseg vm_physmem[VM_PHYSSEG_MAX];  /* XXXCDC: uvm.physmem */
-int vm_nphysseg = 0;                           /* XXXCDC: uvm.nphysseg */
-#define        vm_nphysmem     vm_nphysseg
-
-/*
 * Some supported CPUs in a given architecture don't support all
 * of the things necessary to do idle page zero'ing efficiently.
 * We therefore provide a way to enable it from machdep code here.
@@@@ -146,6 +135,18 @@@@
#endif /* DEBUG */

/*
+ * These functions are reserved for uvm(9) internal use and are not
+ * exported in the header file uvm_physseg.h
+ *
+ * Thus they are redefined here.
+ */
+void uvm_physseg_init_seg(uvm_physseg_t, struct vm_page *);
+void uvm_physseg_seg_chomp_slab(uvm_physseg_t, struct vm_page *, size_t);
+
+/* returns a pgs array */
+struct vm_page *uvm_physseg_seg_alloc_from_slab(uvm_physseg_t, size_t);
+
+/*
 * local prototypes
 */

@@@@ -337,11 +338,9 @@@@
       static struct uvm_cpu boot_cpu;
       psize_t freepages, pagecount, bucketcount, n;
       struct pgflbucket *bucketarray, *cpuarray;
-       struct vm_physseg *seg;
       struct vm_page *pagearray;
+       uvm_physseg_t bank;
       int lcv;
-       u_int i;
-       paddr_t paddr;

       KASSERT(ncpu <= 1);
       CTASSERT(sizeof(pagearray->offset) >= sizeof(struct uvm_cpu *));
@@@@ -369,7 +368,7 @@@@
        * now is to allocate vm_page structures for this memory.
        */

-       if (vm_nphysmem == 0)
+       if (uvm_physseg_get_last() == UVM_PHYSSEG_TYPE_INVALID)
               panic("uvm_page_bootstrap: no memory pre-allocated");

       /*
@@@@ -381,9 +380,11 @@@@
        */

       freepages = 0;
-       for (lcv = 0 ; lcv < vm_nphysmem ; lcv++) {
-               seg = VM_PHYSMEM_PTR(lcv);
-               freepages += (seg->end - seg->start);
+
+       for (bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank) ;
+            bank = uvm_physseg_get_next(bank)) {
+               freepages += (uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank));
       }

       /*
@@@@ -428,31 +429,20 @@@@
       /*
        * init the vm_page structures and put them in the correct place.
        */
+       /* First init the extent */

-       for (lcv = 0 ; lcv < vm_nphysmem ; lcv++) {
-               seg = VM_PHYSMEM_PTR(lcv);
-               n = seg->end - seg->start;
+       for (bank = uvm_physseg_get_first(),
+                uvm_physseg_seg_chomp_slab(bank, pagearray, pagecount);
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+
+               n = uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank);
+               uvm_physseg_seg_alloc_from_slab(bank, n);
+               uvm_physseg_init_seg(bank, pagearray);

               /* set up page array pointers */
-               seg->pgs = pagearray;
               pagearray += n;
               pagecount -= n;
-               seg->lastpg = seg->pgs + n;
-
-               /* init and free vm_pages (we've already zeroed them) */
-               paddr = ctob(seg->start);
-               for (i = 0 ; i < n ; i++, paddr += PAGE_SIZE) {
-                       seg->pgs[i].phys_addr = paddr;
-#ifdef __HAVE_VM_PAGE_MD
-                       VM_MDPAGE_INIT(&seg->pgs[i]);
-#endif
-                       if (atop(paddr) >= seg->avail_start &&
-                           atop(paddr) < seg->avail_end) {
-                               uvmexp.npages++;
-                               /* add page to free pool */
-                               uvm_pagefree(&seg->pgs[i]);
-                       }
-               }
       }

       /*
@@@@ -625,92 +615,42 @@@@
static bool
uvm_page_physget_freelist(paddr_t *paddrp, int freelist)
{
-       struct vm_physseg *seg;
-       int lcv, x;
+       uvm_physseg_t lcv;

       /* pass 1: try allocating from a matching end */
#if (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST)
-       for (lcv = vm_nphysmem - 1 ; lcv >= 0 ; lcv--)
+       for (lcv = uvm_physseg_get_last() ; uvm_physseg_valid_p(lcv) ; lcv = uvm_physseg_get_prev(lcv))
#else
-       for (lcv = 0 ; lcv < vm_nphysmem ; lcv++)
+               for (lcv = uvm_physseg_get_first() ; uvm_physseg_valid_p(lcv) ; lcv = uvm_physseg_get_next(lcv))
#endif
       {
-               seg = VM_PHYSMEM_PTR(lcv);
-
               if (uvm.page_init_done == true)
                       panic("uvm_page_physget: called _after_ bootstrap");

-               if (seg->free_list != freelist)
-                       continue;
+               /* Try to match at front or back on unused segment */
+               if (uvm_page_physunload(lcv, freelist, paddrp) == false) {
+                       if (paddrp == NULL) /* freelist fail, try next */
+                               continue;
+               } else
+                       return true;

-               /* try from front */
-               if (seg->avail_start == seg->start &&
-                   seg->avail_start < seg->avail_end) {
-                       *paddrp = ctob(seg->avail_start);
-                       seg->avail_start++;
-                       seg->start++;
-                       /* nothing left?   nuke it */
-                       if (seg->avail_start == seg->end) {
-                               if (vm_nphysmem == 1)
-                                   panic("uvm_page_physget: out of memory!");
-                               vm_nphysmem--;
-                               for (x = lcv ; x < vm_nphysmem ; x++)
-                                       /* structure copy */
-                                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
-                       }
-                       return (true);
-               }
-
-               /* try from rear */
-               if (seg->avail_end == seg->end &&
-                   seg->avail_start < seg->avail_end) {
-                       *paddrp = ctob(seg->avail_end - 1);
-                       seg->avail_end--;
-                       seg->end--;
-                       /* nothing left?   nuke it */
-                       if (seg->avail_end == seg->start) {
-                               if (vm_nphysmem == 1)
-                                   panic("uvm_page_physget: out of memory!");
-                               vm_nphysmem--;
-                               for (x = lcv ; x < vm_nphysmem ; x++)
-                                       /* structure copy */
-                                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
-                       }
-                       return (true);
-               }
-       }

       /* pass2: forget about matching ends, just allocate something */
#if (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST)
-       for (lcv = vm_nphysmem - 1 ; lcv >= 0 ; lcv--)
+               for (lcv = uvm_physseg_get_last() ; uvm_physseg_valid_p(lcv); lcv = uvm_physseg_get_prev(lcv))
#else
-       for (lcv = 0 ; lcv < vm_nphysmem ; lcv++)
+               for (lcv = uvm_physseg_get_first() ; uvm_physseg_valid_p(lcv) ; lcv = uvm_physseg_get_next(lcv))
#endif
       {
-               seg = VM_PHYSMEM_PTR(lcv);
-
-               /* any room in this bank? */
-               if (seg->avail_start >= seg->avail_end)
-                       continue;  /* nope */
-
-               *paddrp = ctob(seg->avail_start);
-               seg->avail_start++;
-               /* truncate! */
-               seg->start = seg->avail_start;
-
-               /* nothing left?   nuke it */
-               if (seg->avail_start == seg->end) {
-                       if (vm_nphysmem == 1)
-                               panic("uvm_page_physget: out of memory!");
-                       vm_nphysmem--;
-                       for (x = lcv ; x < vm_nphysmem ; x++)
-                               /* structure copy */
-                               VM_PHYSMEM_PTR_SWAP(x, x + 1);
-               }
-               return (true);
+               /* Try the front regardless. */
+               if (uvm_page_physunload_force(lcv, freelist, paddrp) == false) {
+                       if (paddrp == NULL) /* freelist fail, try next */
+                               continue;
+               } else
+                       return true;
       }
-
-       return (false);        /* whoops! */
+       }
+       return false;
}

bool
@@@@ -727,230 +667,6 @@@@
#endif /* PMAP_STEAL_MEMORY */

/*
- * uvm_page_physload: load physical memory into VM system
- *
- * => all args are PFs
- * => all pages in start/end get vm_page structures
- * => areas marked by avail_start/avail_end get added to the free page pool
- * => we are limited to VM_PHYSSEG_MAX physical memory segments
- */
-
-uvm_physseg_t
-uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start,
-    paddr_t avail_end, int free_list)
-{
-       int preload, lcv;
-       psize_t npages;
-       struct vm_page *pgs;
-       struct vm_physseg *ps;
-
-       if (uvmexp.pagesize == 0)
-               panic("uvm_page_physload: page size not set!");
-       if (free_list >= VM_NFREELIST || free_list < VM_FREELIST_DEFAULT)
-               panic("uvm_page_physload: bad free list %d", free_list);
-       if (start >= end)
-               panic("uvm_page_physload: start >= end");
-
-       /*
-        * do we have room?
-        */
-
-       if (vm_nphysmem == VM_PHYSSEG_MAX) {
-               printf("uvm_page_physload: unable to load physical memory "
-                   "segment\n");
-               printf("\t%d segments allocated, ignoring 0x%llx -> 0x%llx\n",
-                   VM_PHYSSEG_MAX, (long long)start, (long long)end);
-               printf("\tincrease VM_PHYSSEG_MAX\n");
-               return 0;
-       }
-
-       /*
-        * check to see if this is a "preload" (i.e. uvm_page_init hasn't been
-        * called yet, so kmem is not available).
-        */
-
-       for (lcv = 0 ; lcv < vm_nphysmem ; lcv++) {
-               if (VM_PHYSMEM_PTR(lcv)->pgs)
-                       break;
-       }
-       preload = (lcv == vm_nphysmem);
-
-       /*
-        * if VM is already running, attempt to kmem_alloc vm_page structures
-        */
-
-       if (!preload) {
-               panic("uvm_page_physload: tried to add RAM after vm_mem_init");
-       } else {
-               pgs = NULL;
-               npages = 0;
-       }
-
-       /*
-        * now insert us in the proper place in vm_physmem[]
-        */
-
-#if (VM_PHYSSEG_STRAT == VM_PSTRAT_RANDOM)
-       /* random: put it at the end (easy!) */
-       ps = VM_PHYSMEM_PTR(vm_nphysmem);
-#elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH)
-       {
-               int x;
-               /* sort by address for binary search */
-               for (lcv = 0 ; lcv < vm_nphysmem ; lcv++)
-                       if (start < VM_PHYSMEM_PTR(lcv)->start)
-                               break;
-               ps = VM_PHYSMEM_PTR(lcv);
-               /* move back other entries, if necessary ... */
-               for (x = vm_nphysmem ; x > lcv ; x--)
-                       /* structure copy */
-                       VM_PHYSMEM_PTR_SWAP(x, x - 1);
-       }
-#elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST)
-       {
-               int x;
-               /* sort by largest segment first */
-               for (lcv = 0 ; lcv < vm_nphysmem ; lcv++)
-                       if ((end - start) >
-                           (VM_PHYSMEM_PTR(lcv)->end - VM_PHYSMEM_PTR(lcv)->start))
-                               break;
-               ps = VM_PHYSMEM_PTR(lcv);
-               /* move back other entries, if necessary ... */
-               for (x = vm_nphysmem ; x > lcv ; x--)
-                       /* structure copy */
-                       VM_PHYSMEM_PTR_SWAP(x, x - 1);
-       }
-#else
-       panic("uvm_page_physload: unknown physseg strategy selected!");
-#endif
-
-       ps->start = start;
-       ps->end = end;
-       ps->avail_start = avail_start;
-       ps->avail_end = avail_end;
-       if (preload) {
-               ps->pgs = NULL;
-       } else {
-               ps->pgs = pgs;
-               ps->lastpg = pgs + npages;
-       }
-       ps->free_list = free_list;
-       vm_nphysmem++;
-
-       if (!preload) {
-               uvmpdpol_reinit();
-       }
-
-       return 0;
-}
-
-/*
- * when VM_PHYSSEG_MAX is 1, we can simplify these functions
- */
-
-#if VM_PHYSSEG_MAX == 1
-static inline int vm_physseg_find_contig(struct vm_physseg *, int, paddr_t, int *);
-#elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH)
-static inline int vm_physseg_find_bsearch(struct vm_physseg *, int, paddr_t, int *);
-#else
-static inline int vm_physseg_find_linear(struct vm_physseg *, int, paddr_t, int *);
-#endif
-
-/*
- * vm_physseg_find: find vm_physseg structure that belongs to a PA
- */
-int
-vm_physseg_find(paddr_t pframe, int *offp)
-{
-
-#if VM_PHYSSEG_MAX == 1
-       return vm_physseg_find_contig(vm_physmem, vm_nphysseg, pframe, offp);
-#elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH)
-       return vm_physseg_find_bsearch(vm_physmem, vm_nphysseg, pframe, offp);
-#else
-       return vm_physseg_find_linear(vm_physmem, vm_nphysseg, pframe, offp);
-#endif
-}
-
-#if VM_PHYSSEG_MAX == 1
-static inline int
-vm_physseg_find_contig(struct vm_physseg *segs, int nsegs, paddr_t pframe, int *offp)
-{
-
-       /* 'contig' case */
-       if (pframe >= segs[0].start && pframe < segs[0].end) {
-               if (offp)
-                       *offp = pframe - segs[0].start;
-               return(0);
-       }
-       return(-1);
-}
-
-#elif (VM_PHYSSEG_STRAT == VM_PSTRAT_BSEARCH)
-
-static inline int
-vm_physseg_find_bsearch(struct vm_physseg *segs, int nsegs, paddr_t pframe, int *offp)
-{
-       /* binary search for it */
-       u_int   start, len, guess;
-
-       /*
-        * if try is too large (thus target is less than try) we reduce
-        * the length to trunc(len/2) [i.e. everything smaller than "try"]
-        *
-        * if the try is too small (thus target is greater than try) then
-        * we set the new start to be (try + 1).   this means we need to
-        * reduce the length to (round(len/2) - 1).
-        *
-        * note "adjust" below which takes advantage of the fact that
-        *  (round(len/2) - 1) == trunc((len - 1) / 2)
-        * for any value of len we may have
-        */
-
-       for (start = 0, len = nsegs ; len != 0 ; len = len / 2) {
-               guess = start + (len / 2);      /* try in the middle */
-
-               /* start past our try? */
-               if (pframe >= segs[guess].start) {
-                       /* was try correct? */
-                       if (pframe < segs[guess].end) {
-                               if (offp)
-                                       *offp = pframe - segs[guess].start;
-                               return guess;            /* got it */
-                       }
-                       start = guess + 1;      /* next time, start here */
-                       len--;                  /* "adjust" */
-               } else {
-                       /*
-                        * pframe before try, just reduce length of
-                        * region, done in "for" loop
-                        */
-               }
-       }
-       return(-1);
-}
-
-#else
-
-static inline int
-vm_physseg_find_linear(struct vm_physseg *segs, int nsegs, paddr_t pframe, int *offp)
-{
-       /* linear search for it */
-       int     lcv;
-
-       for (lcv = 0; lcv < nsegs; lcv++) {
-               if (pframe >= segs[lcv].start &&
-                   pframe < segs[lcv].end) {
-                       if (offp)
-                               *offp = pframe - segs[lcv].start;
-                       return(lcv);               /* got it */
-               }
-       }
-       return(-1);
-}
-#endif
-
-/*
 * PHYS_TO_VM_PAGE: find vm_page for a PA.   used by MI code to get vm_pages
 * back from an I/O mapping (ugh!).   used in some MD code as well.
 */
@@@@ -958,12 +674,12 @@@@
uvm_phys_to_vm_page(paddr_t pa)
{
       paddr_t pf = atop(pa);
-       int     off;
-       int     psi;
+       paddr_t off;
+       uvm_physseg_t   upm;

-       psi = vm_physseg_find(pf, &off);
-       if (psi != -1)
-               return(&VM_PHYSMEM_PTR(psi)->pgs[off]);
+       upm = uvm_physseg_find(pf, &off);
+       if (upm != UVM_PHYSSEG_TYPE_INVALID)
+               return uvm_physseg_get_pg(upm, off);
       return(NULL);
}

@@@@ -987,7 +703,8 @@@@
       struct vm_page *pg;
       vsize_t bucketcount;
       size_t bucketmemsize, oldbucketmemsize;
-       int lcv, color, i, ocolors;
+       int color, i, ocolors;
+       int lcv;
       struct uvm_cpu *ucpu;

       KASSERT(((newncolors - 1) & newncolors) == 0);
@@@@ -1221,7 +938,8 @@@@
uvm_pagealloc_strat(struct uvm_object *obj, voff_t off, struct vm_anon *anon,
    int flags, int strat, int free_list)
{
-       int lcv, try1, try2, zeroit = 0, color;
+       int try1, try2, zeroit = 0, color;
+       int lcv;
       struct uvm_cpu *ucpu;
       struct vm_page *pg;
       lwp_t *l;
@@@@ -2007,7 +1725,7 @@@@
uvm_pageismanaged(paddr_t pa)
{

-       return (vm_physseg_find(atop(pa), NULL) != -1);
+       return (uvm_physseg_find(atop(pa), NULL) != UVM_PHYSSEG_TYPE_INVALID);
}

/*
@@@@ -2017,11 +1735,11 @@@@
int
uvm_page_lookup_freelist(struct vm_page *pg)
{
-       int lcv;
+       uvm_physseg_t upm;

-       lcv = vm_physseg_find(atop(VM_PAGE_TO_PHYS(pg)), NULL);
-       KASSERT(lcv != -1);
-       return (VM_PHYSMEM_PTR(lcv)->free_list);
+       upm = uvm_physseg_find(atop(VM_PAGE_TO_PHYS(pg)), NULL);
+       KASSERT(upm != UVM_PHYSSEG_TYPE_INVALID);
+       return uvm_physseg_get_free_list(upm);
}

/*
@@@@ -2137,7 +1855,8 @@@@
void
uvm_page_printall(void (*pr)(const char *, ...))
{
-       unsigned i;
+       uvm_physseg_t i;
+       paddr_t pfn;
       struct vm_page *pg;

       (*pr)("%18s %4s %4s %18s %18s"
@@@@ -2145,8 +1864,14 @@@@
           " OWNER"
#endif
           "\n", "PAGE", "FLAG", "PQ", "UOBJECT", "UANON");
-       for (i = 0; i < vm_nphysmem; i++) {
-               for (pg = VM_PHYSMEM_PTR(i)->pgs; pg < VM_PHYSMEM_PTR(i)->lastpg; pg++) {
+       for (i = uvm_physseg_get_first();
+            uvm_physseg_valid_p(i);
+            i = uvm_physseg_get_next(i)) {
+               for (pfn = uvm_physseg_get_start(i);
+                    pfn <= uvm_physseg_get_end(i);
+                    pfn++) {
+                       pg = PHYS_TO_VM_PAGE(ptoa(pfn));
+
                       (*pr)("%18p %04x %04x %18p %18p",
                           pg, pg->flags, pg->pqflags, pg->uobject,
                           pg->uanon);
Index: uvm/uvm_page.h
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_page.h,v
retrieving revision 1.80
diff -u -r1.80 uvm_page.h
--- uvm/uvm_page.h      23 Mar 2015 07:59:12 -0000      1.80
+++ uvm/uvm_page.h      22 Dec 2016 16:13:39 -0000
@@@@ -294,24 +294,6 @@@@
#define VM_PSTRAT_BSEARCH      2
#define VM_PSTRAT_BIGFIRST     3

-/*
- * vm_physseg: describes one segment of physical memory
- */
-struct vm_physseg {
-       paddr_t start;                  /* PF# of first page in segment */
-       paddr_t end;                    /* (PF# of last page in segment) + 1 */
-       paddr_t avail_start;            /* PF# of first free page in segment */
-       paddr_t avail_end;              /* (PF# of last free page in segment) +1  */
-       struct  vm_page *pgs;           /* vm_page structures (from start) */
-       struct  vm_page *lastpg;        /* vm_page structure for end */
-       int     free_list;              /* which free list they belong on */
-       u_int   start_hint;             /* start looking for free pages here */
-                                       /* protected by uvm_fpageqlock */
-#ifdef __HAVE_PMAP_PHYSSEG
-       struct  pmap_physseg pmseg;     /* pmap specific (MD) data */
-#endif
-};
-
#ifdef _KERNEL

/*
@@@@ -321,21 +303,6 @@@@
extern bool vm_page_zero_enable;

/*
- * physical memory config is stored in vm_physmem.
- */
-
-#define        VM_PHYSMEM_PTR(i)       (&vm_physmem[i])
-#if VM_PHYSSEG_MAX == 1
-#define VM_PHYSMEM_PTR_SWAP(i, j) /* impossible */
-#else
-#define VM_PHYSMEM_PTR_SWAP(i, j) \
-       do { vm_physmem[(i)] = vm_physmem[(j)]; } while (0)
-#endif
-
-extern struct vm_physseg vm_physmem[VM_PHYSSEG_MAX];
-extern int vm_nphysseg;
-
-/*
 * prototypes: the following prototypes define the interface to pages
 */

@@@@ -366,10 +333,13 @@@@

int uvm_page_lookup_freelist(struct vm_page *);

-int vm_physseg_find(paddr_t, int *);
struct vm_page *uvm_phys_to_vm_page(paddr_t);
paddr_t uvm_vm_page_to_phys(const struct vm_page *);

+#if !defined(PMAP_STEAL_MEMORY)
+bool uvm_page_physget(paddr_t *);
+#endif
+
/*
 * macros
 */
Index: uvm/uvm_pglist.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_pglist.c,v
retrieving revision 1.67
diff -u -r1.67 uvm_pglist.c
--- uvm/uvm_pglist.c    26 Oct 2014 01:42:07 -0000      1.67
+++ uvm/uvm_pglist.c    22 Dec 2016 16:13:39 -0000
@@@@ -116,16 +116,15 @@@@
}

static int
-uvm_pglistalloc_c_ps(struct vm_physseg *ps, int num, paddr_t low, paddr_t high,
+uvm_pglistalloc_c_ps(uvm_physseg_t psi, int num, paddr_t low, paddr_t high,
    paddr_t alignment, paddr_t boundary, struct pglist *rlist)
{
       signed int candidate, limit, candidateidx, end, idx, skip;
-       struct vm_page *pgs;
       int pagemask;
       bool second_pass;
#ifdef DEBUG
       paddr_t idxpa, lastidxpa;
-       int cidx = 0;   /* XXX: GCC */
+       paddr_t cidx = 0;       /* XXX: GCC */
#endif
#ifdef PGALLOC_VERBOSE
       printf("pgalloc: contig %d pgs from psi %zd\n", num, ps - vm_physmem);
@@@@ -140,26 +139,26 @@@@
       /*
        * Make sure that physseg falls within with range to be allocated from.
        */
-       if (high <= ps->avail_start || low >= ps->avail_end)
+       if (high <= uvm_physseg_get_avail_start(psi) || low >= uvm_physseg_get_avail_end(psi))
               return 0;

       /*
        * We start our search at the just after where the last allocation
        * succeeded.
        */
-       candidate = roundup2(max(low, ps->avail_start + ps->start_hint), alignment);
-       limit = min(high, ps->avail_end);
+       candidate = roundup2(max(low, uvm_physseg_get_avail_start(psi) +
+               uvm_physseg_get_start_hint(psi)), alignment);
+       limit = min(high, uvm_physseg_get_avail_end(psi));
       pagemask = ~((boundary >> PAGE_SHIFT) - 1);
       skip = 0;
       second_pass = false;
-       pgs = ps->pgs;

       for (;;) {
               bool ok = true;
               signed int cnt;

               if (candidate + num > limit) {
-                       if (ps->start_hint == 0 || second_pass) {
+                       if (uvm_physseg_get_start_hint(psi) == 0 || second_pass) {
                               /*
                                * We've run past the allowable range.
                                */
@@@@ -171,8 +170,9 @@@@
                        * is were we started.
                        */
                       second_pass = true;
-                       candidate = roundup2(max(low, ps->avail_start), alignment);
-                       limit = min(limit, ps->avail_start + ps->start_hint);
+                       candidate = roundup2(max(low, uvm_physseg_get_avail_start(psi)), alignment);
+                       limit = min(limit, uvm_physseg_get_avail_start(psi) +
+                           uvm_physseg_get_start_hint(psi));
                       skip = 0;
                       continue;
               }
@@@@ -192,16 +192,16 @@@@
                * Make sure this is a managed physical page.
                */

-               if (vm_physseg_find(candidate, &cidx) != ps - vm_physmem)
+               if (uvm_physseg_find(candidate, &cidx) != psi)
                       panic("pgalloc contig: botch1");
-               if (cidx != candidate - ps->start)
+               if (cidx != candidate - uvm_physseg_get_start(psi))
                       panic("pgalloc contig: botch2");
-               if (vm_physseg_find(candidate + num - 1, &cidx) != ps - vm_physmem)
+               if (uvm_physseg_find(candidate + num - 1, &cidx) != psi)
                       panic("pgalloc contig: botch3");
-               if (cidx != candidate - ps->start + num - 1)
+               if (cidx != candidate - uvm_physseg_get_start(psi) + num - 1)
                       panic("pgalloc contig: botch4");
#endif
-               candidateidx = candidate - ps->start;
+               candidateidx = candidate - uvm_physseg_get_start(psi);
               end = candidateidx + num;

               /*
@@@@ -220,15 +220,15 @@@@
                * testing most of those pages again in the next pass.
                */
               for (idx = end - 1; idx >= candidateidx + skip; idx--) {
-                       if (VM_PAGE_IS_FREE(&pgs[idx]) == 0) {
+                       if (VM_PAGE_IS_FREE(uvm_physseg_get_pg(psi, idx)) == 0) {
                               ok = false;
                               break;
                       }

#ifdef DEBUG
                       if (idx > candidateidx) {
-                               idxpa = VM_PAGE_TO_PHYS(&pgs[idx]);
-                               lastidxpa = VM_PAGE_TO_PHYS(&pgs[idx - 1]);
+                               idxpa = VM_PAGE_TO_PHYS(uvm_physseg_get_pg(psi, idx));
+                               lastidxpa = VM_PAGE_TO_PHYS(uvm_physseg_get_pg(psi, idx - 1));
                               if ((lastidxpa + PAGE_SIZE) != idxpa) {
                                       /*
                                        * Region not contiguous.
@@@@ -249,7 +249,7 @@@@

               if (ok) {
                       while (skip-- > 0) {
-                               KDASSERT(VM_PAGE_IS_FREE(&pgs[candidateidx + skip]));
+                               KDASSERT(VM_PAGE_IS_FREE(uvm_physseg_get_pg(psi, candidateidx + skip)));
                       }
#ifdef PGALLOC_VERBOSE
                       printf(": ok\n");
@@@@ -280,19 +280,22 @@@@
       /*
        * we have a chunk of memory that conforms to the requested constraints.
        */
-       for (idx = candidateidx, pgs += idx; idx < end; idx++, pgs++)
-               uvm_pglist_add(pgs, rlist);
+       for (idx = candidateidx; idx < end; idx++)
+               uvm_pglist_add(uvm_physseg_get_pg(psi, idx), rlist);

       /*
        * the next time we need to search this segment, start after this
        * chunk of pages we just allocated.
        */
-       ps->start_hint = candidate + num - ps->avail_start;
-       KASSERTMSG(ps->start_hint <= ps->avail_end - ps->avail_start,
+       uvm_physseg_set_start_hint(psi, candidate + num -
+           uvm_physseg_get_avail_start(psi));
+       KASSERTMSG(uvm_physseg_get_start_hint(psi) <=
+           uvm_physseg_get_avail_end(psi) - uvm_physseg_get_avail_start(psi),
           "%x %u (%#x) <= %#"PRIxPADDR" - %#"PRIxPADDR" (%#"PRIxPADDR")",
           candidate + num,
-           ps->start_hint, ps->start_hint, ps->avail_end, ps->avail_start,
-           ps->avail_end - ps->avail_start);
+           uvm_physseg_get_start_hint(psi), uvm_physseg_get_start_hint(psi),
+           uvm_physseg_get_avail_end(psi), uvm_physseg_get_avail_start(psi),
+           uvm_physseg_get_avail_end(psi) - uvm_physseg_get_avail_start(psi));

#ifdef PGALLOC_VERBOSE
       printf("got %d pgs\n", num);
@@@@ -304,10 +307,10 @@@@
uvm_pglistalloc_contig(int num, paddr_t low, paddr_t high, paddr_t alignment,
    paddr_t boundary, struct pglist *rlist)
{
-       int fl, psi;
-       struct vm_physseg *ps;
+       int fl;
       int error;

+       uvm_physseg_t psi;
       /* Default to "lose". */
       error = ENOMEM;

@@@@ -322,17 +325,16 @@@@

       for (fl = 0; fl < VM_NFREELIST; fl++) {
#if (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST)
-               for (psi = vm_nphysseg - 1 ; psi >= 0 ; psi--)
+               for (psi = uvm_physseg_get_last(); uvm_physseg_valid_p(psi); psi = uvm_physseg_get_prev(psi))
+
#else
-               for (psi = 0 ; psi < vm_nphysseg ; psi++)
+               for (psi = uvm_physseg_get_first(); uvm_physseg_valid_p(psi); psi = uvm_physseg_get_next(psi))
#endif
               {
-                       ps = &vm_physmem[psi];
-
-                       if (ps->free_list != fl)
+                       if (uvm_physseg_get_free_list(psi) != fl)
                               continue;

-                       num -= uvm_pglistalloc_c_ps(ps, num, low, high,
+                       num -= uvm_pglistalloc_c_ps(psi, num, low, high,
                                                   alignment, boundary, rlist);
                       if (num == 0) {
#ifdef PGALLOC_VERBOSE
@@@@ -358,59 +360,62 @@@@
}

static int
-uvm_pglistalloc_s_ps(struct vm_physseg *ps, int num, paddr_t low, paddr_t high,
+uvm_pglistalloc_s_ps(uvm_physseg_t psi, int num, paddr_t low, paddr_t high,
    struct pglist *rlist)
{
       int todo, limit, candidate;
       struct vm_page *pg;
       bool second_pass;
#ifdef PGALLOC_VERBOSE
-       printf("pgalloc: simple %d pgs from psi %zd\n", num, ps - vm_physmem);
+       printf("pgalloc: simple %d pgs from psi %zd\n", num, psi);
#endif

       KASSERT(mutex_owned(&uvm_fpageqlock));
-       KASSERT(ps->start <= ps->avail_start);
-       KASSERT(ps->start <= ps->avail_end);
-       KASSERT(ps->avail_start <= ps->end);
-       KASSERT(ps->avail_end <= ps->end);
+       KASSERT(uvm_physseg_get_start(psi) <= uvm_physseg_get_avail_start(psi));
+       KASSERT(uvm_physseg_get_start(psi) <= uvm_physseg_get_avail_end(psi));
+       KASSERT(uvm_physseg_get_avail_start(psi) <= uvm_physseg_get_end(psi));
+       KASSERT(uvm_physseg_get_avail_end(psi) <= uvm_physseg_get_end(psi));

       low = atop(low);
       high = atop(high);
       todo = num;
-       candidate = max(low, ps->avail_start + ps->start_hint);
-       limit = min(high, ps->avail_end);
-       pg = &ps->pgs[candidate - ps->start];
+       candidate = max(low, uvm_physseg_get_avail_start(psi) +
+           uvm_physseg_get_start_hint(psi));
+       limit = min(high, uvm_physseg_get_avail_end(psi));
+       pg = uvm_physseg_get_pg(psi, candidate - uvm_physseg_get_start(psi));
       second_pass = false;

       /*
        * Make sure that physseg falls within with range to be allocated from.
        */
-       if (high <= ps->avail_start || low >= ps->avail_end)
+       if (high <= uvm_physseg_get_avail_start(psi) ||
+           low >= uvm_physseg_get_avail_end(psi))
               return 0;

again:
       for (;; candidate++, pg++) {
               if (candidate >= limit) {
-                       if (ps->start_hint == 0 || second_pass) {
+                       if (uvm_physseg_get_start_hint(psi) == 0 || second_pass) {
                               candidate = limit - 1;
                               break;
                       }
                       second_pass = true;
-                       candidate = max(low, ps->avail_start);
-                       limit = min(limit, ps->avail_start + ps->start_hint);
-                       pg = &ps->pgs[candidate - ps->start];
+                       candidate = max(low, uvm_physseg_get_avail_start(psi));
+                       limit = min(limit, uvm_physseg_get_avail_start(psi) +
+                           uvm_physseg_get_start_hint(psi));
+                       pg = uvm_physseg_get_pg(psi, candidate - uvm_physseg_get_start(psi));
                       goto again;
               }
#if defined(DEBUG)
               {
-                       int cidx = 0;
-                       const int bank = vm_physseg_find(candidate, &cidx);
-                       KDASSERTMSG(bank == ps - vm_physmem,
-                           "vm_physseg_find(%#x) (%d) != ps %zd",
-                            candidate, bank, ps - vm_physmem);
-                       KDASSERTMSG(cidx == candidate - ps->start,
-                           "vm_physseg_find(%#x): %#x != off %"PRIxPADDR,
-                            candidate, cidx, candidate - ps->start);
+                       paddr_t cidx = 0;
+                       const uvm_physseg_t bank = uvm_physseg_find(candidate, &cidx);
+                       KDASSERTMSG(bank == psi,
+                           "uvm_physseg_find(%#x) (%"PRIxPHYSMEM ") != psi %"PRIxPHYSMEM,
+                            candidate, bank, psi);
+                       KDASSERTMSG(cidx == candidate - uvm_physseg_get_start(psi),
+                           "uvm_physseg_find(%#x): %#"PRIxPADDR" != off %"PRIxPADDR,
+                            candidate, cidx, candidate - uvm_physseg_get_start(psi));
               }
#endif
               if (VM_PAGE_IS_FREE(pg) == 0)
@@@@ -426,12 +431,16 @@@@
        * The next time we need to search this segment,
        * start just after the pages we just allocated.
        */
-       ps->start_hint = candidate + 1 - ps->avail_start;
-       KASSERTMSG(ps->start_hint <= ps->avail_end - ps->avail_start,
+       uvm_physseg_set_start_hint(psi, candidate + 1 - uvm_physseg_get_avail_start(psi));
+       KASSERTMSG(uvm_physseg_get_start_hint(psi) <= uvm_physseg_get_avail_end(psi) -
+           uvm_physseg_get_avail_start(psi),
           "%#x %u (%#x) <= %#"PRIxPADDR" - %#"PRIxPADDR" (%#"PRIxPADDR")",
           candidate + 1,
-           ps->start_hint, ps->start_hint, ps->avail_end, ps->avail_start,
-           ps->avail_end - ps->avail_start);
+           uvm_physseg_get_start_hint(psi),
+           uvm_physseg_get_start_hint(psi),
+           uvm_physseg_get_avail_end(psi),
+           uvm_physseg_get_avail_start(psi),
+           uvm_physseg_get_avail_end(psi) - uvm_physseg_get_avail_start(psi));

#ifdef PGALLOC_VERBOSE
       printf("got %d pgs\n", num - todo);
@@@@ -443,9 +452,10 @@@@
uvm_pglistalloc_simple(int num, paddr_t low, paddr_t high,
    struct pglist *rlist, int waitok)
{
-       int fl, psi, error;
-       struct vm_physseg *ps;
+       int fl, error;

+       uvm_physseg_t psi;
+
       /* Default to "lose". */
       error = ENOMEM;

@@@@ -461,17 +471,16 @@@@

       for (fl = 0; fl < VM_NFREELIST; fl++) {
#if (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST)
-               for (psi = vm_nphysseg - 1 ; psi >= 0 ; psi--)
+               for (psi = uvm_physseg_get_last(); uvm_physseg_valid_p(psi); psi = uvm_physseg_get_prev(psi))
+
#else
-               for (psi = 0 ; psi < vm_nphysseg ; psi++)
+               for (psi = uvm_physseg_get_first(); uvm_physseg_valid_p(psi); psi = uvm_physseg_get_next(psi))
#endif
               {
-                       ps = &vm_physmem[psi];
-
-                       if (ps->free_list != fl)
+                       if (uvm_physseg_get_free_list(psi) != fl)
                               continue;

-                       num -= uvm_pglistalloc_s_ps(ps, num, low, high, rlist);
+                       num -= uvm_pglistalloc_s_ps(psi, num, low, high, rlist);
                       if (num == 0) {
                               error = 0;
                               goto out;
Index: uvm/uvm_physseg.h
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_physseg.h,v
retrieving revision 1.3
diff -u -r1.3 uvm_physseg.h
--- uvm/uvm_physseg.h   22 Dec 2016 15:54:35 -0000      1.3
+++ uvm/uvm_physseg.h   22 Dec 2016 16:13:39 -0000
@@@@ -1,4 +1,4 @@@@
-/* $NetBSD: uvm_physseg.h,v 1.3 2016/12/22 15:54:35 cherry Exp $ */
+/* $NetBSD: uvm_physseg.h,v 1.2 2016/12/22 08:15:20 cherry Exp $ */

/*
 * Consolidated API from uvm_page.c and others.
@@@@ -9,10 +9,8 @@@@
#define _UVM_UVM_PHYSSEG_H_

#if defined(_KERNEL_OPT)
-#if notyet
#include "opt_uvm_hotplug.h"
#endif
-#endif

#include <sys/cdefs.h>
#include <sys/param.h>
Index: uvm/pmap/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/pmap/pmap.c,v
retrieving revision 1.25
diff -u -r1.25 pmap.c
--- uvm/pmap/pmap.c     1 Dec 2016 02:15:08 -0000       1.25
+++ uvm/pmap/pmap.c     22 Dec 2016 16:13:39 -0000
@@@@ -112,6 +112,7 @@@@
#include <sys/atomic.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#if defined(MULTIPROCESSOR) && defined(PMAP_VIRTUAL_CACHE_ALIASES) \
    && !defined(PMAP_NO_PV_UNCACHED)
@@@@ -452,37 +453,39 @@@@
       size_t npgs;
       paddr_t pa;
       vaddr_t va;
-       struct vm_physseg *maybe_seg = NULL;
-       u_int maybe_bank = vm_nphysseg;
+
+       uvm_physseg_t maybe_bank = UVM_PHYSMEM_TYPE_INVALID;

       size = round_page(size);
       npgs = atop(size);

       aprint_debug("%s: need %zu pages\n", __func__, npgs);

-       for (u_int bank = 0; bank < vm_nphysseg; bank++) {
-               struct vm_physseg * const seg = VM_PHYSMEM_PTR(bank);
+       for (uvm_physseg_t bank = uvm_physseg_get_first();
+            uvm_physseg_valid_p(bank);
+            bank = uvm_physseg_get_next(bank)) {
+
               if (uvm.page_init_done == true)
                       panic("pmap_steal_memory: called _after_ bootstrap");

-               aprint_debug("%s: seg %u: %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR"\n",
+               aprint_debug("%s: seg %"PRIxPHYSMEM": %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR"\n",
                   __func__, bank,
-                   seg->avail_start, seg->start,
-                   seg->avail_end, seg->end);
+                   uvm_physseg_get_avail_start(bank), uvm_physseg_get_start(bank),
+                   uvm_physseg_get_avail_end(bank), uvm_physseg_get_end(bank));

-               if (seg->avail_start != seg->start
-                   || seg->avail_start >= seg->avail_end) {
-                       aprint_debug("%s: seg %u: bad start\n", __func__, bank);
+               if (uvm_physseg_get_avail_start(bank) != uvm_physseg_get_start(bank)
+                   || uvm_physseg_get_avail_start(bank) >= uvm_physseg_get_avail_end(bank)) {
+                       aprint_debug("%s: seg %"PRIxPHYSMEM": bad start\n", __func__, bank);
                       continue;
               }

-               if (seg->avail_end - seg->avail_start < npgs) {
-                       aprint_debug("%s: seg %u: too small for %zu pages\n",
+               if (uvm_physseg_get_avail_end(bank) - uvm_physseg_get_avail_start(bank) < npgs) {
+                       aprint_debug("%s: seg %"PRIxPHYSMEM": too small for %zu pages\n",
                           __func__, bank, npgs);
                       continue;
               }

-               if (!pmap_md_ok_to_steal_p(seg, npgs)) {
+               if (!pmap_md_ok_to_steal_p(bank, npgs)) {
                       continue;
               }

@@@@ -490,44 +493,24 @@@@
                * Always try to allocate from the segment with the least
                * amount of space left.
                */
-#define VM_PHYSMEM_SPACE(s)    ((s)->avail_end - (s)->avail_start)
-               if (maybe_seg == NULL
-                   || VM_PHYSMEM_SPACE(seg) < VM_PHYSMEM_SPACE(maybe_seg)) {
-                       maybe_seg = seg;
+#define VM_PHYSMEM_SPACE(b)    ((uvm_physseg_get_avail_end(b)) - (uvm_physseg_get_avail_start(b)))
+               if (uvm_physseg_valid_p(maybe_bank) == false
+                   || VM_PHYSMEM_SPACE(bank) < VM_PHYSMEM_SPACE(maybe_bank)) {
                       maybe_bank = bank;
               }
       }

-       if (maybe_seg) {
-               struct vm_physseg * const seg = maybe_seg;
-               u_int bank = maybe_bank;
-
+       if (uvm_physseg_valid_p(maybe_bank)) {
+               const uvm_physseg_t bank = maybe_bank;
+
               /*
                * There are enough pages here; steal them!
                */
-               pa = ptoa(seg->avail_start);
-               seg->avail_start += npgs;
-               seg->start += npgs;
-
-               /*
-                * Have we used up this segment?
-                */
-               if (seg->avail_start == seg->end) {
-                       if (vm_nphysseg == 1)
-                               panic("pmap_steal_memory: out of memory!");
+               pa = ptoa(uvm_physseg_get_start(bank));
+               uvm_physseg_unplug(atop(pa), npgs);

-                       aprint_debug("%s: seg %u: %zu pages stolen (removed)\n",
-                           __func__, bank, npgs);
-                       /* Remove this segment from the list. */
-                       vm_nphysseg--;
-                       for (u_int x = bank; x < vm_nphysseg; x++) {
-                               /* structure copy */
-                               VM_PHYSMEM_PTR_SWAP(x, x + 1);
-                       }
-               } else {
-                       aprint_debug("%s: seg %u: %zu pages stolen (%#"PRIxPADDR" left)\n",
-                           __func__, bank, npgs, VM_PHYSMEM_SPACE(seg));
-               }
+               aprint_debug("%s: seg %"PRIxPHYSMEM": %zu pages stolen (%#"PRIxPADDR" left)\n",
+                   __func__, bank, npgs, VM_PHYSMEM_SPACE(bank));

               va = pmap_md_map_poolpage(pa, size);
               memset((void *)va, 0, size);
@


1.3
log
@remove spurious newlines
remove spurious uvm_physseg_init() et. al.
remove conf/ for only i386 and amd64
@
text
@d1 1
a1 19
Index: share/man/man9/Makefile
===================================================================
RCS file: /cvsroot/src/share/man/man9/Makefile,v
retrieving revision 1.398
diff -u -r1.398 Makefile
--- share/man/man9/Makefile     28 Nov 2016 11:00:24 -0000      1.398
+++ share/man/man9/Makefile     22 Dec 2016 10:32:25 -0000
@@@@ -59,8 +59,8 @@@@
       vattr.9 veriexec.9 vcons.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 \
       video.9 vme.9 \
       vnfileops.9 vnode.9 vnodeops.9 vnsubr.9 \
-       ubc.9 usbd_status.9 usbdi.9 uvm.9 uvm_km.9 uvm_map.9 vmem.9 \
-       wapbl.9 wdc.9 workqueue.9 \
+       ubc.9 usbd_status.9 usbdi.9 uvm.9 uvm_hotplug.9 uvm_km.9 uvm_map.9 \
+       vmem.9 wapbl.9 wdc.9 workqueue.9 \
       wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 \
       xcall.9

Index: sys/arch/acorn26/acorn26/pmap.c
d6 2
a7 2
--- sys/arch/acorn26/acorn26/pmap.c     11 May 2012 15:39:17 -0000      1.36
+++ sys/arch/acorn26/acorn26/pmap.c     22 Dec 2016 10:32:27 -0000
d40 1
a40 67
Index: sys/arch/acorn26/acorn26/start.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn26/acorn26/start.c,v
retrieving revision 1.20
diff -u -r1.20 start.c
--- sys/arch/acorn26/acorn26/start.c    18 Aug 2013 16:08:42 -0000      1.20
+++ sys/arch/acorn26/acorn26/start.c    22 Dec 2016 10:32:27 -0000
@@@@ -125,7 +125,7 @@@@
       boothowto = bootconfig.boothowto;
       physmem = bootconfig.npages;
       uvmexp.pagesize = bootconfig.nbpp;
-       uvm_setpagesize();
+       uvm_md_init();

       /* Any others? */

Index: sys/arch/acorn32/acorn32/rpc_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn32/acorn32/rpc_machdep.c,v
retrieving revision 1.90
diff -u -r1.90 rpc_machdep.c
--- sys/arch/acorn32/acorn32/rpc_machdep.c      25 Oct 2014 10:58:12 -0000      1.90
+++ sys/arch/acorn32/acorn32/rpc_machdep.c      22 Dec 2016 10:32:28 -0000
@@@@ -924,7 +924,8 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
+
       for (loop = 0; loop < bootconfig.dramblocks; loop++) {
               paddr_t start = (paddr_t)bootconfig.dram[loop].address;
               paddr_t end = start + (bootconfig.dram[loop].pages * PAGE_SIZE);
Index: sys/arch/acorn32/eb7500atx/eb7500atx_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/acorn32/eb7500atx/eb7500atx_machdep.c,v
retrieving revision 1.28
diff -u -r1.28 eb7500atx_machdep.c
--- sys/arch/acorn32/eb7500atx/eb7500atx_machdep.c      25 Oct 2014 10:58:12 -0000      1.28
+++ sys/arch/acorn32/eb7500atx/eb7500atx_machdep.c      22 Dec 2016 10:32:28 -0000
@@@@ -862,7 +862,8 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
+
       for (loop = 0; loop < bootconfig.dramblocks; loop++) {
               paddr_t start = (paddr_t)bootconfig.dram[loop].address;
               paddr_t end = start + (bootconfig.dram[loop].pages * PAGE_SIZE);
Index: sys/arch/algor/algor/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/algor/algor/machdep.c,v
retrieving revision 1.54
diff -u -r1.54 machdep.c
--- sys/arch/algor/algor/machdep.c      30 Jun 2015 02:39:03 -0000      1.54
+++ sys/arch/algor/algor/machdep.c      22 Dec 2016 10:32:30 -0000
@@@@ -198,7 +198,7 @@@@
        * Initialize PAGE_SIZE-dependent variables.
        */
       led_display('p', 'g', 's', 'z');
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Initialize bus space tags and bring up the console.
Index: sys/arch/alpha/alpha/machdep.c
d43 4
a46 4
retrieving revision 1.347
diff -u -r1.347 machdep.c
--- sys/arch/alpha/alpha/machdep.c      13 Oct 2016 16:18:20 -0000      1.347
+++ sys/arch/alpha/alpha/machdep.c      22 Dec 2016 10:32:30 -0000
a54 11
@@@@ -372,8 +371,8 @@@@
               panic("page size %lu != %d?!", hwrpb->rpb_page_size,
                   ALPHA_PGBYTES);
       uvmexp.pagesize = hwrpb->rpb_page_size;
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /*
        * Find out what hardware we're on, and do basic initialization.
        */
d79 3
a85 3
+               uvm_physseg_unplug(end, atop(sz));
+               msgbufaddr = (void *) ALPHA_PHYS_TO_K0SEG(ptoa(end));
+
d90 1
a90 1
Index: sys/arch/alpha/alpha/pmap.c
d95 2
a96 2
--- sys/arch/alpha/alpha/pmap.c 5 Nov 2015 06:26:15 -0000       1.260
+++ sys/arch/alpha/alpha/pmap.c 22 Dec 2016 10:32:30 -0000
d185 1
a185 1
Index: sys/arch/amd64/amd64/machdep.c
d188 4
a191 4
retrieving revision 1.240
diff -u -r1.240 machdep.c
--- sys/arch/amd64/amd64/machdep.c      20 Dec 2016 14:03:15 -0000      1.240
+++ sys/arch/amd64/amd64/machdep.c      22 Dec 2016 10:32:33 -0000
d306 1
a306 90
@@@@ -1578,11 +1567,7 @@@@

       consinit();     /* XXX SHOULD NOT BE DONE HERE */

-       /*
-        * Initialize PAGE_SIZE-dependent variables.
-        */
-       uvm_setpagesize();
-
+       uvm_md_init();
       uvmexp.ncolors = 2;

       avail_start = first_avail;
Index: sys/arch/amiga/amiga/pmap_bootstrap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amiga/amiga/pmap_bootstrap.c,v
retrieving revision 1.9
diff -u -r1.9 pmap_bootstrap.c
--- sys/arch/amiga/amiga/pmap_bootstrap.c       6 Dec 2009 06:41:29 -0000       1.9
+++ sys/arch/amiga/amiga/pmap_bootstrap.c       22 Dec 2016 10:32:35 -0000
@@@@ -125,8 +125,8 @@@@
        */

       uvmexp.pagesize = NBPG;
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /*
        * May want to check if first segment is Zorro-II?
        */
Index: sys/arch/amigappc/amigappc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amigappc/amigappc/machdep.c,v
retrieving revision 1.51
diff -u -r1.51 machdep.c
--- sys/arch/amigappc/amigappc/machdep.c        15 Feb 2012 12:11:42 -0000      1.51
+++ sys/arch/amigappc/amigappc/machdep.c        22 Dec 2016 10:32:40 -0000
@@@@ -560,10 +560,7 @@@@

       /* XXX bus_space_init() not needed here */

-       /*
-        * Set the page size
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Initialize pmap module
Index: sys/arch/arc/arc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/arc/machdep.c,v
retrieving revision 1.129
diff -u -r1.129 machdep.c
--- sys/arch/arc/arc/machdep.c  30 Jun 2015 02:39:03 -0000      1.129
+++ sys/arch/arc/arc/machdep.c  22 Dec 2016 10:32:41 -0000
@@@@ -306,11 +306,8 @@@@
               }
       }

-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /* make sure that we don't call BIOS console from now on */
       cn_tab = NULL;

Index: sys/arch/arm/arm32/arm32_boot.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/arm32_boot.c,v
retrieving revision 1.17
diff -u -r1.17 arm32_boot.c
--- sys/arch/arm/arm32/arm32_boot.c     8 Mar 2016 08:01:23 -0000       1.17
+++ sys/arch/arm/arm32/arm32_boot.c     22 Dec 2016 10:32:44 -0000
@@@@ -231,8 +231,8 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
-
+       uvm_md_init();
+
#ifdef VERBOSE_INIT_ARM
       printf("pmap_physload ");
#endif
Index: sys/arch/arm/arm32/bus_dma.c
d311 2
a312 2
--- sys/arch/arm/arm32/bus_dma.c        5 Nov 2016 14:26:23 -0000       1.96
+++ sys/arch/arm/arm32/bus_dma.c        22 Dec 2016 10:32:45 -0000
d328 1
a328 1
Index: sys/arch/arm/arm32/pmap.c
d333 2
a334 2
--- sys/arch/arm/arm32/pmap.c   17 Dec 2016 14:36:29 -0000      1.341
+++ sys/arch/arm/arm32/pmap.c   22 Dec 2016 10:32:45 -0000
d346 1
a346 777
Index: sys/arch/arm/at91/at91bus.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/at91/at91bus.c,v
retrieving revision 1.18
diff -u -r1.18 at91bus.c
--- sys/arch/arm/at91/at91bus.c 13 Sep 2014 18:08:38 -0000      1.18
+++ sys/arch/arm/at91/at91bus.c 22 Dec 2016 10:32:45 -0000
@@@@ -511,7 +511,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/atari/atari/pmap_bootstrap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/atari/atari/pmap_bootstrap.c,v
retrieving revision 1.7
diff -u -r1.7 pmap_bootstrap.c
--- sys/arch/atari/atari/pmap_bootstrap.c       13 Apr 2010 09:49:54 -0000      1.7
+++ sys/arch/atari/atari/pmap_bootstrap.c       22 Dec 2016 10:32:59 -0000
@@@@ -108,8 +108,8 @@@@
        * Announce page-size to the VM-system
        */
       uvmexp.pagesize = NBPG;
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /*
        * Setup physical address ranges
        */
Index: sys/arch/cesfic/cesfic/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cesfic/cesfic/machdep.c,v
retrieving revision 1.66
diff -u -r1.66 machdep.c
--- sys/arch/cesfic/cesfic/machdep.c    5 Nov 2015 03:48:51 -0000       1.66
+++ sys/arch/cesfic/cesfic/machdep.c    22 Dec 2016 10:33:03 -0000
@@@@ -111,7 +111,7 @@@@
 * Declare these as initialized data so we can patch them.
 */
/*int  maxmem;*/                       /* max memory per process */
-extern int physmem;                    /* max supported memory, changes to actual */
+extern psize_t physmem;                        /* max supported memory, changes to actual */

extern u_int lowram;

Index: sys/arch/cobalt/cobalt/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/machdep.c,v
retrieving revision 1.118
diff -u -r1.118 machdep.c
--- sys/arch/cobalt/cobalt/machdep.c    27 Jul 2016 11:13:14 -0000      1.118
+++ sys/arch/cobalt/cobalt/machdep.c    22 Dec 2016 10:33:04 -0000
@@@@ -252,8 +252,8 @@@@
       if (bi_msg != NULL)
               printf("%s: magic=%#x bip=%p\n", bi_msg, bim, bip);

-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /*
        * The boot command is passed in the top 512 bytes,
        * so don't clobber that.
Index: sys/arch/dreamcast/dreamcast/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/dreamcast/dreamcast/machdep.c,v
retrieving revision 1.45
diff -u -r1.45 machdep.c
--- sys/arch/dreamcast/dreamcast/machdep.c      24 Mar 2014 20:06:31 -0000      1.45
+++ sys/arch/dreamcast/dreamcast/machdep.c      22 Dec 2016 10:33:05 -0000
@@@@ -103,6 +103,7 @@@@

#include <dev/cons.h>

+
#include "ksyms.h"

/* the following is used externally (sysctl_hw) */
@@@@ -130,6 +131,7 @@@@
       /* Load memory to UVM */
       physmem = atop(IOM_RAM_SIZE);
       kernend = atop(round_page(SH3_P1SEG_TO_PHYS(end)));
+
       uvm_page_physload(
               kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
               kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
Index: sys/arch/emips/emips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/emips/emips/machdep.c,v
retrieving revision 1.11
diff -u -r1.11 machdep.c
--- sys/arch/emips/emips/machdep.c      11 Jun 2015 08:22:08 -0000      1.11
+++ sys/arch/emips/emips/machdep.c      22 Dec 2016 10:33:05 -0000
@@@@ -59,6 +59,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -225,10 +226,7 @@@@
       if (bootinfo_msg != NULL)
               printf(bootinfo_msg);
#endif
-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Copy exception-dispatch code down to exception vector.
Index: sys/arch/epoc32/epoc32/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/epoc32/epoc32/machdep.c,v
retrieving revision 1.4
diff -u -r1.4 machdep.c
--- sys/arch/epoc32/epoc32/machdep.c    13 Sep 2014 18:08:40 -0000      1.4
+++ sys/arch/epoc32/epoc32/machdep.c    22 Dec 2016 10:33:06 -0000
@@@@ -440,7 +440,7 @@@@
       undefined_init();

        /* Load memory into UVM. */
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(
           atop(_end_physical), atop(physical_end),
           atop(_end_physical), atop(physical_end),
Index: sys/arch/evbarm/adi_brh/brh_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/adi_brh/brh_machdep.c,v
retrieving revision 1.43
diff -u -r1.43 brh_machdep.c
--- sys/arch/evbarm/adi_brh/brh_machdep.c       13 Sep 2014 18:08:38 -0000      1.43
+++ sys/arch/evbarm/adi_brh/brh_machdep.c       22 Dec 2016 10:33:06 -0000
@@@@ -757,7 +757,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/armadillo/armadillo9_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/armadillo/armadillo9_machdep.c,v
retrieving revision 1.28
diff -u -r1.28 armadillo9_machdep.c
--- sys/arch/evbarm/armadillo/armadillo9_machdep.c      13 Sep 2014 18:08:38 -0000      1.28
+++ sys/arch/evbarm/armadillo/armadillo9_machdep.c      22 Dec 2016 10:33:06 -0000
@@@@ -813,7 +813,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c,v
retrieving revision 1.29
diff -u -r1.29 g42xxeb_machdep.c
--- sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c   13 Sep 2014 18:08:38 -0000      1.29
+++ sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c   22 Dec 2016 10:33:07 -0000
@@@@ -828,7 +828,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/gemini/gemini_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/gemini/gemini_machdep.c,v
retrieving revision 1.22
diff -u -r1.22 gemini_machdep.c
--- sys/arch/evbarm/gemini/gemini_machdep.c     18 Aug 2013 15:58:20 -0000      1.22
+++ sys/arch/evbarm/gemini/gemini_machdep.c     22 Dec 2016 10:33:07 -0000
@@@@ -707,8 +707,8 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
-
+       uvm_md_init();
+
#if (GEMINI_RAM_RESV_PBASE != 0)
       uvm_page_physload(atop(physical_freestart), atop(GEMINI_RAM_RESV_PBASE),
           atop(physical_freestart), atop(GEMINI_RAM_RESV_PBASE),
Index: sys/arch/evbarm/hdl_g/hdlg_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/hdl_g/hdlg_machdep.c,v
retrieving revision 1.22
diff -u -r1.22 hdlg_machdep.c
--- sys/arch/evbarm/hdl_g/hdlg_machdep.c        13 Sep 2014 18:08:39 -0000      1.22
+++ sys/arch/evbarm/hdl_g/hdlg_machdep.c        22 Dec 2016 10:33:07 -0000
@@@@ -595,7 +595,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/imx31/imx31lk_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/imx31/imx31lk_machdep.c,v
retrieving revision 1.18
diff -u -r1.18 imx31lk_machdep.c
--- sys/arch/evbarm/imx31/imx31lk_machdep.c     13 Sep 2014 18:08:39 -0000      1.18
+++ sys/arch/evbarm/imx31/imx31lk_machdep.c     22 Dec 2016 10:33:07 -0000
@@@@ -692,7 +692,7 @@@@

       /* Load memory into UVM. */
       printf("page ");
-       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/iq80310/iq80310_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/iq80310/iq80310_machdep.c,v
retrieving revision 1.85
diff -u -r1.85 iq80310_machdep.c
--- sys/arch/evbarm/iq80310/iq80310_machdep.c   13 Sep 2014 18:08:39 -0000      1.85
+++ sys/arch/evbarm/iq80310/iq80310_machdep.c   22 Dec 2016 10:33:08 -0000
@@@@ -717,7 +717,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/iq80321/iq80321_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/iq80321/iq80321_machdep.c,v
retrieving revision 1.55
diff -u -r1.55 iq80321_machdep.c
--- sys/arch/evbarm/iq80321/iq80321_machdep.c   13 Sep 2014 18:08:39 -0000      1.55
+++ sys/arch/evbarm/iq80321/iq80321_machdep.c   22 Dec 2016 10:33:08 -0000
@@@@ -742,7 +742,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/ixdp425/ixdp425_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ixdp425/ixdp425_machdep.c,v
retrieving revision 1.36
diff -u -r1.36 ixdp425_machdep.c
--- sys/arch/evbarm/ixdp425/ixdp425_machdep.c   5 Mar 2015 08:09:44 -0000       1.36
+++ sys/arch/evbarm/ixdp425/ixdp425_machdep.c   22 Dec 2016 10:33:08 -0000
@@@@ -709,7 +709,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/ixm1200/ixm1200_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ixm1200/ixm1200_machdep.c,v
retrieving revision 1.56
diff -u -r1.56 ixm1200_machdep.c
--- sys/arch/evbarm/ixm1200/ixm1200_machdep.c   13 Sep 2014 18:08:39 -0000      1.56
+++ sys/arch/evbarm/ixm1200/ixm1200_machdep.c   22 Dec 2016 10:33:08 -0000
@@@@ -676,7 +676,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/lubbock/lubbock_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/lubbock/lubbock_machdep.c,v
retrieving revision 1.33
diff -u -r1.33 lubbock_machdep.c
--- sys/arch/evbarm/lubbock/lubbock_machdep.c   13 Sep 2014 18:08:39 -0000      1.33
+++ sys/arch/evbarm/lubbock/lubbock_machdep.c   22 Dec 2016 10:33:08 -0000
@@@@ -899,7 +899,7 @@@@

       /* Load memory into UVM. */
       printf("page ");
-       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/mini2440/mini2440_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/mini2440/mini2440_machdep.c,v
retrieving revision 1.9
diff -u -r1.9 mini2440_machdep.c
--- sys/arch/evbarm/mini2440/mini2440_machdep.c 13 Sep 2014 18:08:39 -0000      1.9
+++ sys/arch/evbarm/mini2440/mini2440_machdep.c 22 Dec 2016 10:33:08 -0000
@@@@ -886,7 +886,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/npwr_fc/npwr_fc_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/npwr_fc/npwr_fc_machdep.c,v
retrieving revision 1.20
diff -u -r1.20 npwr_fc_machdep.c
--- sys/arch/evbarm/npwr_fc/npwr_fc_machdep.c   13 Sep 2014 18:08:39 -0000      1.20
+++ sys/arch/evbarm/npwr_fc/npwr_fc_machdep.c   22 Dec 2016 10:33:08 -0000
@@@@ -712,7 +712,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/nslu2/nslu2_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/nslu2/nslu2_machdep.c,v
retrieving revision 1.26
diff -u -r1.26 nslu2_machdep.c
--- sys/arch/evbarm/nslu2/nslu2_machdep.c       5 Mar 2015 08:09:44 -0000       1.26
+++ sys/arch/evbarm/nslu2/nslu2_machdep.c       22 Dec 2016 10:33:08 -0000
@@@@ -777,7 +777,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/osk5912/osk5912_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/osk5912/osk5912_machdep.c,v
retrieving revision 1.15
diff -u -r1.15 osk5912_machdep.c
--- sys/arch/evbarm/osk5912/osk5912_machdep.c   18 Aug 2013 15:58:21 -0000      1.15
+++ sys/arch/evbarm/osk5912/osk5912_machdep.c   22 Dec 2016 10:33:08 -0000
@@@@ -447,7 +447,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/smdk2xx0/smdk2410_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/smdk2xx0/smdk2410_machdep.c,v
retrieving revision 1.35
diff -u -r1.35 smdk2410_machdep.c
--- sys/arch/evbarm/smdk2xx0/smdk2410_machdep.c 13 Sep 2014 18:08:39 -0000      1.35
+++ sys/arch/evbarm/smdk2xx0/smdk2410_machdep.c 22 Dec 2016 10:33:09 -0000
@@@@ -844,7 +844,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/smdk2xx0/smdk2800_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/smdk2xx0/smdk2800_machdep.c,v
retrieving revision 1.42
diff -u -r1.42 smdk2800_machdep.c
--- sys/arch/evbarm/smdk2xx0/smdk2800_machdep.c 13 Sep 2014 18:08:39 -0000      1.42
+++ sys/arch/evbarm/smdk2xx0/smdk2800_machdep.c 22 Dec 2016 10:33:09 -0000
@@@@ -761,7 +761,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/tisdp24xx/sdp24xx_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/tisdp24xx/sdp24xx_machdep.c,v
retrieving revision 1.16
diff -u -r1.16 sdp24xx_machdep.c
--- sys/arch/evbarm/tisdp24xx/sdp24xx_machdep.c 18 Aug 2013 15:58:21 -0000      1.16
+++ sys/arch/evbarm/tisdp24xx/sdp24xx_machdep.c 22 Dec 2016 10:33:09 -0000
@@@@ -541,7 +541,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/tsarm/tsarm_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/tsarm/tsarm_machdep.c,v
retrieving revision 1.23
diff -u -r1.23 tsarm_machdep.c
--- sys/arch/evbarm/tsarm/tsarm_machdep.c       13 Sep 2014 18:08:39 -0000      1.23
+++ sys/arch/evbarm/tsarm/tsarm_machdep.c       22 Dec 2016 10:33:09 -0000
@@@@ -726,7 +726,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbarm/viper/viper_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/viper/viper_machdep.c,v
retrieving revision 1.24
diff -u -r1.24 viper_machdep.c
--- sys/arch/evbarm/viper/viper_machdep.c       13 Sep 2014 18:08:39 -0000      1.24
+++ sys/arch/evbarm/viper/viper_machdep.c       22 Dec 2016 10:33:09 -0000
@@@@ -746,7 +746,7 @@@@

       /* Load memory into UVM. */
       printf("page ");
-       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/evbmips/adm5120/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/adm5120/machdep.c,v
retrieving revision 1.24
diff -u -r1.24 machdep.c
--- sys/arch/evbmips/adm5120/machdep.c  26 Jun 2015 22:12:21 -0000      1.24
+++ sys/arch/evbmips/adm5120/machdep.c  22 Dec 2016 10:33:10 -0000
@@@@ -292,10 +292,7 @@@@
        */
       mips_vector_init(NULL, false);

-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       adm5120_setcpufreq();

Index: sys/arch/evbmips/alchemy/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/alchemy/machdep.c,v
retrieving revision 1.55
diff -u -r1.55 machdep.c
--- sys/arch/evbmips/alchemy/machdep.c  26 Jun 2015 22:11:10 -0000      1.55
+++ sys/arch/evbmips/alchemy/machdep.c  22 Dec 2016 10:33:10 -0000
@@@@ -179,10 +179,7 @@@@
        */
       mips_vector_init(NULL, false);

-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Use YAMON's CPU frequency if available.
Index: sys/arch/evbmips/atheros/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/atheros/machdep.c,v
retrieving revision 1.30
diff -u -r1.30 machdep.c
--- sys/arch/evbmips/atheros/machdep.c  26 Jun 2015 22:11:10 -0000      1.30
+++ sys/arch/evbmips/atheros/machdep.c  22 Dec 2016 10:33:10 -0000
@@@@ -207,10 +207,7 @@@@
        */
       cal_timer();

-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Look at arguments passed to us and compute boothowto.
Index: sys/arch/evbmips/cavium/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/cavium/machdep.c,v
retrieving revision 1.8
diff -u -r1.8 machdep.c
--- sys/arch/evbmips/cavium/machdep.c   20 Oct 2016 07:26:03 -0000      1.8
+++ sys/arch/evbmips/cavium/machdep.c   22 Dec 2016 10:33:10 -0000
@@@@ -220,8 +220,7 @@@@

       mach_init_vector();

-       /* set the VM page size */
-       uvm_setpagesize();
+       uvm_md_init();

       mach_init_bus_space();

Index: sys/arch/evbmips/gdium/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/gdium/machdep.c,v
retrieving revision 1.19
diff -u -r1.19 machdep.c
--- sys/arch/evbmips/gdium/machdep.c    11 Jul 2016 16:18:56 -0000      1.19
+++ sys/arch/evbmips/gdium/machdep.c    22 Dec 2016 10:33:10 -0000
@@@@ -235,8 +235,7 @@@@
        */
       mips_vector_init(NULL, false);

-       /* set the VM page size */
-       uvm_setpagesize();
+       uvm_md_init();

       memsize = 256*1024*1024;
       physmem = btoc(memsize);
Index: sys/arch/evbmips/ingenic/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/ingenic/machdep.c,v
retrieving revision 1.11
diff -u -r1.11 machdep.c
--- sys/arch/evbmips/ingenic/machdep.c  26 Aug 2016 13:53:36 -0000      1.11
+++ sys/arch/evbmips/ingenic/machdep.c  22 Dec 2016 10:33:10 -0000
@@@@ -176,7 +176,7 @@@@
       cpu_setmodel("Ingenic XBurst");
       mips_vector_init(NULL, false);
       cal_timer();
-       uvm_setpagesize();
+       uvm_md_init();
       /*
        * Look at arguments passed to us and compute boothowto.
        */
Index: sys/arch/evbmips/loongson/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/loongson/machdep.c,v
retrieving revision 1.6
diff -u -r1.6 machdep.c
--- sys/arch/evbmips/loongson/machdep.c 24 Mar 2014 20:06:31 -0000      1.6
+++ sys/arch/evbmips/loongson/machdep.c 22 Dec 2016 10:33:10 -0000
@@@@ -316,9 +316,8 @@@@
       DPRINTF(("mips_vector_init "));
       mips_vector_init(NULL, false);

-       DPRINTF(("uvm_setpagesize\n"));
-       /* set the VM page size */
-       uvm_setpagesize();
+       DPRINTF(("uvm_md_init\n"));
+       uvm_md_init();
#if NKSYMS || defined(DDB) || defined(MODULAR)
       //ksyms_addsyms_elf((vaddr_t)esym - (vaddr_t)ssym, ssym, esym);
#endif
Index: sys/arch/evbmips/malta/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/malta/machdep.c,v
retrieving revision 1.45
diff -u -r1.45 machdep.c
--- sys/arch/evbmips/malta/machdep.c    11 Jul 2016 16:18:56 -0000      1.45
+++ sys/arch/evbmips/malta/machdep.c    22 Dec 2016 10:33:10 -0000
@@@@ -181,8 +181,7 @@@@
        */
       mips_vector_init(NULL, false);

-       /* set the VM page size */
-       uvm_setpagesize();
+       uvm_md_init();

       physmem = btoc(memsize);

Index: sys/arch/evbmips/rasoc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/rasoc/machdep.c,v
retrieving revision 1.12
diff -u -r1.12 machdep.c
--- sys/arch/evbmips/rasoc/machdep.c    5 Oct 2016 15:54:58 -0000       1.12
+++ sys/arch/evbmips/rasoc/machdep.c    22 Dec 2016 10:33:11 -0000
@@@@ -146,10 +146,7 @@@@
        */
       cal_timer();

-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Look at arguments passed to us and compute boothowto.
Index: sys/arch/evbmips/rmixl/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/rmixl/machdep.c,v
retrieving revision 1.17
diff -u -r1.17 machdep.c
--- sys/arch/evbmips/rmixl/machdep.c    30 Jun 2015 02:39:03 -0000      1.17
+++ sys/arch/evbmips/rmixl/machdep.c    22 Dec 2016 10:33:11 -0000
@@@@ -265,8 +265,7 @@@@
       /* get system info from firmware */
       memsize = rmixlfw_init(infop);

-       /* set the VM page size */
-       uvm_setpagesize();
+       uvm_md_init();

       physmem = btoc(memsize);

Index: sys/arch/evbppc/ev64260/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/ev64260/machdep.c,v
retrieving revision 1.31
diff -u -r1.31 machdep.c
--- sys/arch/evbppc/ev64260/machdep.c   25 Feb 2014 14:33:32 -0000      1.31
+++ sys/arch/evbppc/ev64260/machdep.c   22 Dec 2016 10:33:11 -0000
@@@@ -224,10 +224,7 @@@@

       consinit();

-       /*
-        * Set the page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Initialize pmap module.
Index: sys/arch/evbppc/mpc85xx/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/mpc85xx/machdep.c,v
retrieving revision 1.41
diff -u -r1.41 machdep.c
--- sys/arch/evbppc/mpc85xx/machdep.c   30 Jan 2015 15:04:35 -0000      1.41
+++ sys/arch/evbppc/mpc85xx/machdep.c   22 Dec 2016 10:33:11 -0000
@@@@ -1267,10 +1267,7 @@@@

       mtspr(SPR_TCR, TCR_WIE | mfspr(SPR_TCR));

-       /*
-        * Set the page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Initialize the pmap.
Index: sys/arch/evbppc/pmppc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/pmppc/machdep.c,v
retrieving revision 1.12
diff -u -r1.12 machdep.c
--- sys/arch/evbppc/pmppc/machdep.c     1 Mar 2013 18:25:39 -0000       1.12
+++ sys/arch/evbppc/pmppc/machdep.c     22 Dec 2016 10:33:11 -0000
@@@@ -218,10 +218,7 @@@@

       printf("console set up\n");

-        /*
-        * Set the page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Initialize pmap module.
Index: sys/arch/ews4800mips/ews4800mips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/ews4800mips/ews4800mips/machdep.c,v
retrieving revision 1.26
diff -u -r1.26 machdep.c
--- sys/arch/ews4800mips/ews4800mips/machdep.c  24 Mar 2014 20:06:32 -0000      1.26
+++ sys/arch/ews4800mips/ews4800mips/machdep.c  22 Dec 2016 10:33:12 -0000
@@@@ -110,8 +110,8 @@@@

       option(argc, argv, bi);

-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /* Fill mem_clusters and mem_cluster_cnt */
       (*platform.mem_init)(kernel_text,
           (bi && bi->bi_nsym) ? (void *)bi->bi_esym : end);
Index: sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c,v
retrieving revision 1.22
diff -u -r1.22 pxa2x0_hpc_machdep.c
--- sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c 13 Sep 2014 18:09:50 -0000      1.22
+++ sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c 22 Dec 2016 10:33:16 -0000
@@@@ -608,7 +608,7 @@@@
#endif

       /* Load memory into UVM. */
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       for (loop = 0; loop < bootconfig.dramblocks; loop++) {
               paddr_t dblk_start = (paddr_t)bootconfig.dram[loop].address;
               paddr_t dblk_end = dblk_start
Index: sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c,v
retrieving revision 1.10
diff -u -r1.10 sa11x0_hpc_machdep.c
--- sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c 13 Sep 2014 18:09:50 -0000      1.10
+++ sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c 22 Dec 2016 10:33:16 -0000
@@@@ -537,7 +537,7 @@@@
#endif

       /* Load memory into UVM. */
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       for (loop = 0; loop < bootconfig.dramblocks; loop++) {
               paddr_t dblk_start = (paddr_t)bootconfig.dram[loop].address;
               paddr_t dblk_end = dblk_start
Index: sys/arch/hpcmips/hpcmips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hpcmips/hpcmips/machdep.c,v
retrieving revision 1.120
diff -u -r1.120 machdep.c
--- sys/arch/hpcmips/hpcmips/machdep.c  30 Jun 2015 02:39:03 -0000      1.120
+++ sys/arch/hpcmips/hpcmips/machdep.c  22 Dec 2016 10:33:17 -0000
@@@@ -310,7 +310,7 @@@@
        * Set the VM page size.
        */
       uvmexp.pagesize = NBPG; /* Notify the VM system of our page size. */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Copy exception-dispatch code down to exception vector.
Index: sys/arch/hppa/hppa/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hppa/hppa/pmap.c,v
retrieving revision 1.99
diff -u -r1.99 pmap.c
--- sys/arch/hppa/hppa/pmap.c   8 Aug 2014 07:30:51 -0000       1.99
+++ sys/arch/hppa/hppa/pmap.c   22 Dec 2016 10:33:20 -0000
@@@@ -675,8 +675,8 @@@@

       DPRINTF(PDB_FOLLOW|PDB_INIT, ("%s(0x%lx)\n", __func__, vstart));

-       uvm_setpagesize();
-
+       uvm_md_init();
+
       hppa_prot[UVM_PROT_NONE]  = TLB_AR_NA;
       hppa_prot[UVM_PROT_READ]  = TLB_AR_R;
       hppa_prot[UVM_PROT_WRITE] = TLB_AR_RW;
Index: sys/arch/i386/i386/machdep.c
d349 4
a352 4
retrieving revision 1.770
diff -u -r1.770 machdep.c
--- sys/arch/i386/i386/machdep.c        20 Dec 2016 14:03:15 -0000      1.770
+++ sys/arch/i386/i386/machdep.c        22 Dec 2016 10:33:23 -0000
d430 1
a430 15
@@@@ -1188,11 +1161,8 @@@@
       cpu_info_primary.ci_pae_l3_pdir = (pd_entry_t *)(rcr3() + KERNBASE);
#endif /* PAE && !XEN */

-       /*
-        * Initialize PAGE_SIZE-dependent variables.
-        */
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /*
        * Start with 2 color bins -- this is just a guess to get us
        * started.  We'll recolor when we determine the largest cache
Index: sys/arch/ia64/ia64/machdep.c
d433 4
a436 4
retrieving revision 1.35
diff -u -r1.35 machdep.c
--- sys/arch/ia64/ia64/machdep.c        14 Mar 2014 17:45:37 -0000      1.35
+++ sys/arch/ia64/ia64/machdep.c        22 Dec 2016 10:33:25 -0000
d466 3
a468 2
@@@@ -465,8 +466,7 @@@@
        */
a469 2
       uvmexp.pagesize = PAGE_SIZE;
-       uvm_setpagesize();
a470 2
+       uvm_md_init();

d473 2
a474 1
Index: sys/arch/ia64/ia64/pmap.c
d479 2
a480 2
--- sys/arch/ia64/ia64/pmap.c   10 Mar 2014 13:47:45 -0000      1.32
+++ sys/arch/ia64/ia64/pmap.c   22 Dec 2016 10:33:25 -0000
d617 1
a617 17
Index: sys/arch/iyonix/iyonix/iyonix_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/iyonix/iyonix/iyonix_machdep.c,v
retrieving revision 1.24
diff -u -r1.24 iyonix_machdep.c
--- sys/arch/iyonix/iyonix/iyonix_machdep.c     13 Sep 2014 18:08:39 -0000      1.24
+++ sys/arch/iyonix/iyonix/iyonix_machdep.c     22 Dec 2016 10:33:27 -0000
@@@@ -780,7 +780,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/arch/luna68k/luna68k/pmap_bootstrap.c
d620 7
a626 12
retrieving revision 1.36
diff -u -r1.36 pmap_bootstrap.c
--- sys/arch/luna68k/luna68k/pmap_bootstrap.c   26 Jan 2013 15:46:24 -0000      1.36
+++ sys/arch/luna68k/luna68k/pmap_bootstrap.c   22 Dec 2016 10:33:28 -0000
@@@@ -51,7 +51,8 @@@@

extern char *etext;

-extern int maxmem, physmem;
+extern int maxmem;
+extern psize_t physmem;
extern paddr_t avail_start, avail_end;
d629 11
a639 1
Index: sys/arch/m68k/m68k/pmap_motorola.c
d642 4
a645 4
retrieving revision 1.67
diff -u -r1.67 pmap_motorola.c
--- sys/arch/m68k/m68k/pmap_motorola.c  25 Oct 2013 20:51:14 -0000      1.67
+++ sys/arch/m68k/m68k/pmap_motorola.c  22 Dec 2016 10:33:29 -0000
a669 9
@@@@ -340,7 +342,7 @@@@
        * and they require this earlier.
        */
       uvmexp.pagesize = NBPG;
-       uvm_setpagesize();
+       uvm_md_init();
#endif

       /*
d733 1
a733 1
Index: sys/arch/mips/include/pmap.h
d738 2
a739 2
--- sys/arch/mips/include/pmap.h        11 Jul 2016 16:15:35 -0000      1.68
+++ sys/arch/mips/include/pmap.h        22 Dec 2016 10:33:37 -0000
d758 1
a758 1
Index: sys/arch/mips/mips/mips_machdep.c
d761 4
a764 4
retrieving revision 1.274
diff -u -r1.274 mips_machdep.c
--- sys/arch/mips/mips/mips_machdep.c   30 Jul 2016 05:55:34 -0000      1.274
+++ sys/arch/mips/mips/mips_machdep.c   22 Dec 2016 10:33:38 -0000
d825 1
a825 1
Index: sys/arch/mips/mips/pmap_machdep.c
d830 2
a831 2
--- sys/arch/mips/mips/pmap_machdep.c   5 Sep 2016 06:59:25 -0000       1.11
+++ sys/arch/mips/mips/pmap_machdep.c   22 Dec 2016 10:33:38 -0000
d868 1
a868 122
Index: sys/arch/mipsco/mipsco/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mipsco/mipsco/machdep.c,v
retrieving revision 1.79
diff -u -r1.79 machdep.c
--- sys/arch/mipsco/mipsco/machdep.c    26 Jun 2015 22:55:40 -0000      1.79
+++ sys/arch/mipsco/mipsco/machdep.c    22 Dec 2016 10:33:41 -0000
@@@@ -211,11 +211,8 @@@@
       if (bi_msg != NULL)
               printf(bi_msg);

-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /* Find out how much memory is available. */
       physmem = memsize_scan(kernend);

Index: sys/arch/netwinder/netwinder/netwinder_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/netwinder/netwinder/netwinder_machdep.c,v
retrieving revision 1.83
diff -u -r1.83 netwinder_machdep.c
--- sys/arch/netwinder/netwinder/netwinder_machdep.c    13 Sep 2014 18:08:39 -0000      1.83
+++ sys/arch/netwinder/netwinder/netwinder_machdep.c    22 Dec 2016 10:33:42 -0000
@@@@ -477,7 +477,7 @@@@
       physmem = (physical_end - physical_start) / PAGE_SIZE;

       /* Tell the user about the memory */
-       printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
+       printf("physmemory: %"PRIxPSIZE" pages at 0x%08lx -> 0x%08lx\n", physmem,
           physical_start, physical_end - 1);

       /*
@@@@ -738,8 +738,8 @@@@

       /* Load memory into UVM. */
       printf("page ");
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
-
+       uvm_md_init();
+
       /* XXX Always one RAM block -- nuke the loop. */
       for (loop = 0; loop < bootconfig.dramblocks; loop++) {
               paddr_t start = (paddr_t)bootconfig.dram[loop].address;
Index: sys/arch/newsmips/newsmips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/newsmips/newsmips/machdep.c,v
retrieving revision 1.118
diff -u -r1.118 machdep.c
--- sys/arch/newsmips/newsmips/machdep.c        21 Jul 2016 19:49:59 -0000      1.118
+++ sys/arch/newsmips/newsmips/machdep.c        22 Dec 2016 10:33:44 -0000
@@@@ -240,11 +240,8 @@@@
               kernend = (char *)mips_round_page(esym);
#endif

-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       boothowto = x_boothowto;
       bootdev = x_bootdev;
       physmem = btoc(x_maxmem);
Index: sys/arch/playstation2/playstation2/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/playstation2/playstation2/machdep.c,v
retrieving revision 1.31
diff -u -r1.31 machdep.c
--- sys/arch/playstation2/playstation2/machdep.c        30 Jun 2015 02:39:04 -0000      1.31
+++ sys/arch/playstation2/playstation2/machdep.c        22 Dec 2016 10:33:46 -0000
@@@@ -114,7 +114,8 @@@@
#ifdef DEBUG
       bootinfo_dump();
#endif
-       uvm_setpagesize();
+       uvm_md_init();
+
       physmem = atop(PS2_MEMORY_SIZE);

       /*
Index: sys/arch/pmax/pmax/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/pmax/machdep.c,v
retrieving revision 1.250
diff -u -r1.250 machdep.c
--- sys/arch/pmax/pmax/machdep.c        1 Feb 2016 17:39:41 -0000       1.250
+++ sys/arch/pmax/pmax/machdep.c        22 Dec 2016 10:33:46 -0000
@@@@ -220,10 +220,7 @@@@
#else
       __USE(bootinfo_msg);
#endif
-       /*
-        * Set the VM page size.
-        */
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Copy exception-dispatch code down to exception vector.
Index: sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c,v
retrieving revision 1.21
diff -u -r1.21 ibm4xx_machdep.c
--- sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c    16 Dec 2016 04:27:03 -0000      1.21
+++ sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c    22 Dec 2016 10:33:48 -0000
@@@@ -228,7 +228,7 @@@@
        */
       consinit();

-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Initialize pmap module.
Index: sys/arch/powerpc/ibm4xx/pmap.c
d871 4
a874 4
retrieving revision 1.72
diff -u -r1.72 pmap.c
--- sys/arch/powerpc/ibm4xx/pmap.c      27 Jan 2012 19:48:39 -0000      1.72
+++ sys/arch/powerpc/ibm4xx/pmap.c      22 Dec 2016 10:33:48 -0000
d893 1
a893 10
@@@@ -294,7 +294,7 @@@@
        * Announce page-size to the VM-system
        */
       uvmexp.pagesize = NBPG;
-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Get memory.
Index: sys/arch/powerpc/isa/isadma_machdep.c
d898 2
a899 2
--- sys/arch/powerpc/isa/isadma_machdep.c       26 Feb 2016 18:17:39 -0000      1.10
+++ sys/arch/powerpc/isa/isadma_machdep.c       22 Dec 2016 10:33:54 -0000
d930 1
a930 17
Index: sys/arch/powerpc/oea/ofwoea_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/ofwoea_machdep.c,v
retrieving revision 1.38
diff -u -r1.38 ofwoea_machdep.c
--- sys/arch/powerpc/oea/ofwoea_machdep.c       25 Mar 2014 16:41:37 -0000      1.38
+++ sys/arch/powerpc/oea/ofwoea_machdep.c       22 Dec 2016 10:33:55 -0000
@@@@ -232,7 +232,7 @@@@
               }
       }

-       uvm_setpagesize();
+       uvm_md_init();

       pmap_bootstrap(startkernel, endkernel);

Index: sys/arch/powerpc/oea/pmap.c
d935 2
a936 2
--- sys/arch/powerpc/oea/pmap.c 14 Feb 2016 18:07:49 -0000      1.93
+++ sys/arch/powerpc/oea/pmap.c 22 Dec 2016 10:33:55 -0000
d1048 1
a1048 17
Index: sys/arch/powerpc/oea/prep_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/prep_machdep.c,v
retrieving revision 1.10
diff -u -r1.10 prep_machdep.c
--- sys/arch/powerpc/oea/prep_machdep.c 11 Feb 2012 13:53:59 -0000      1.10
+++ sys/arch/powerpc/oea/prep_machdep.c 22 Dec 2016 10:33:55 -0000
@@@@ -163,7 +163,7 @@@@
       consinit();

       /* Set the page size */
-       uvm_setpagesize();
+       uvm_md_init();

       /* Initialize pmap module */
       pmap_bootstrap(startkernel, endkernel);
Index: sys/arch/powerpc/powerpc/bus_dma.c
d1053 2
a1054 2
--- sys/arch/powerpc/powerpc/bus_dma.c  1 Feb 2012 09:54:03 -0000       1.46
+++ sys/arch/powerpc/powerpc/bus_dma.c  22 Dec 2016 10:33:56 -0000
d1085 1
a1085 66
Index: sys/arch/rs6000/rs6000/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/rs6000/rs6000/machdep.c,v
retrieving revision 1.10
diff -u -r1.10 machdep.c
--- sys/arch/rs6000/rs6000/machdep.c    20 Jun 2011 07:18:07 -0000      1.10
+++ sys/arch/rs6000/rs6000/machdep.c    22 Dec 2016 10:33:59 -0000
@@@@ -335,7 +335,7 @@@@
       setled(0x40400000);

       /* Initialize pmap module. */
-       uvm_setpagesize();
+       uvm_md_init();
       pmap_bootstrap(startkernel, endkernel);
       setled(0x40500000);

Index: sys/arch/sandpoint/sandpoint/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sandpoint/sandpoint/machdep.c,v
retrieving revision 1.65
diff -u -r1.65 machdep.c
--- sys/arch/sandpoint/sandpoint/machdep.c      30 Sep 2015 14:18:54 -0000      1.65
+++ sys/arch/sandpoint/sandpoint/machdep.c      22 Dec 2016 10:33:59 -0000
@@@@ -198,8 +198,7 @@@@
       /* Initialize the console */
       consinit();

-       /* Set the page size */
-       uvm_setpagesize();
+       uvm_md_init();

       /* Initialize pmap module */
       pmap_bootstrap(startkernel, endkernel);
Index: sys/arch/sbmips/sbmips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sbmips/sbmips/machdep.c,v
retrieving revision 1.53
diff -u -r1.53 machdep.c
--- sys/arch/sbmips/sbmips/machdep.c    24 Mar 2014 19:13:48 -0000      1.53
+++ sys/arch/sbmips/sbmips/machdep.c    22 Dec 2016 10:34:00 -0000
@@@@ -190,7 +190,7 @@@@

       consinit();

-       uvm_setpagesize();
+       uvm_md_init();

       /*
        * Copy exception-dispatch code down to exception vector.
Index: sys/arch/sgimips/sgimips/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sgimips/sgimips/machdep.c,v
retrieving revision 1.142
diff -u -r1.142 machdep.c
--- sys/arch/sgimips/sgimips/machdep.c  3 Nov 2016 22:08:31 -0000       1.142
+++ sys/arch/sgimips/sgimips/machdep.c  22 Dec 2016 10:34:01 -0000
@@@@ -287,7 +287,7 @@@@

       cpu_setmodel("%s", arcbios_system_identifier);

-       uvm_setpagesize();
+       uvm_md_init();

       /* set up bootinfo structures */
       if (magic == BOOTINFO_MAGIC && bip != NULL) {
Index: sys/arch/sh3/sh3/pmap.c
d1090 2
a1091 2
--- sys/arch/sh3/sh3/pmap.c     3 Sep 2016 09:07:54 -0000       1.78
+++ sys/arch/sh3/sh3/pmap.c     22 Dec 2016 10:34:02 -0000
d1161 1
a1161 19
Index: sys/arch/sh3/sh3/sh3_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/sh3_machdep.c,v
retrieving revision 1.104
diff -u -r1.104 sh3_machdep.c
--- sys/arch/sh3/sh3/sh3_machdep.c      2 Nov 2016 00:11:59 -0000       1.104
+++ sys/arch/sh3/sh3/sh3_machdep.c      22 Dec 2016 10:34:02 -0000
@@@@ -190,9 +190,7 @@@@
       /* kernel stack setup */
       __sh_switch_resume = CPU_IS_SH3 ? sh3_switch_resume : sh4_switch_resume;

-       /* Set page size (4KB) */
-       uvm_setpagesize();
-
+       uvm_md_init();
       /* setup UBC channel A for single-stepping */
#if defined(PTRACE_HOOKS) || defined(DDB)
       _reg_write_2(SH_(BBRA), 0); /* disable channel A */
Index: sys/arch/sh3/sh3/vm_machdep.c
d1166 2
a1167 2
--- sys/arch/sh3/sh3/vm_machdep.c       7 Nov 2013 21:45:04 -0000       1.76
+++ sys/arch/sh3/sh3/vm_machdep.c       22 Dec 2016 10:34:02 -0000
d1185 1
a1185 118
Index: sys/arch/shark/ofw/ofw.c
===================================================================
RCS file: /cvsroot/src/sys/arch/shark/ofw/ofw.c,v
retrieving revision 1.65
diff -u -r1.65 ofw.c
--- sys/arch/shark/ofw/ofw.c    7 Jul 2016 06:55:38 -0000       1.65
+++ sys/arch/shark/ofw/ofw.c    22 Dec 2016 10:34:03 -0000
@@@@ -871,8 +871,7 @@@@
               bootconfig.dramblocks = availcnt;
       }

-       /* Load memory into UVM. */
-       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();

       /* XXX Please kill this code dead. */
       for (i = 0; i < bootconfig.dramblocks; i++) {
Index: sys/arch/sparc/sparc/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/pmap.c,v
retrieving revision 1.360
diff -u -r1.360 pmap.c
--- sys/arch/sparc/sparc/pmap.c 11 Dec 2015 19:47:52 -0000      1.360
+++ sys/arch/sparc/sparc/pmap.c 22 Dec 2016 10:34:07 -0000
@@@@ -3035,7 +3035,7 @@@@
       extern char *kernel_top;

       uvmexp.pagesize = NBPG;
-       uvm_setpagesize();
+       uvm_md_init();

#if defined(SUN4) && (defined(SUN4C) || defined(SUN4M) || defined(SUN4D))
       /* In this case NPTESG is a variable */
Index: sys/arch/sparc64/sparc64/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/pmap.c,v
retrieving revision 1.304
diff -u -r1.304 pmap.c
--- sys/arch/sparc64/sparc64/pmap.c     4 Nov 2016 05:41:01 -0000       1.304
+++ sys/arch/sparc64/sparc64/pmap.c     22 Dec 2016 10:34:11 -0000
@@@@ -778,8 +778,8 @@@@
        */
       uvmexp.pagesize = NBPG;
       uvmexp.ncolors = pmap_calculate_colors();
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       /*
        * Get hold or the message buffer.
        */
Index: sys/arch/sun2/sun2/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun2/sun2/pmap.c,v
retrieving revision 1.47
diff -u -r1.47 pmap.c
--- sys/arch/sun2/sun2/pmap.c   24 Mar 2014 18:50:31 -0000      1.47
+++ sys/arch/sun2/sun2/pmap.c   22 Dec 2016 10:34:12 -0000
@@@@ -1700,7 +1700,7 @@@@
       avail_next = avail_start;

       uvmexp.pagesize = NBPG;
-       uvm_setpagesize();
+       uvm_md_init();

       /* after setting up some structures */

Index: sys/arch/sun3/sun3/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3/pmap.c,v
retrieving revision 1.170
diff -u -r1.170 pmap.c
--- sys/arch/sun3/sun3/pmap.c   7 Nov 2013 17:50:18 -0000       1.170
+++ sys/arch/sun3/sun3/pmap.c   22 Dec 2016 10:34:14 -0000
@@@@ -1730,7 +1730,7 @@@@
       avail_next = avail_start;

       uvmexp.pagesize = PAGE_SIZE;
-       uvm_setpagesize();
+       uvm_md_init();

       /* after setting up some structures */

Index: sys/arch/sun3/sun3x/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3x/pmap.c,v
retrieving revision 1.113
diff -u -r1.113 pmap.c
--- sys/arch/sun3/sun3x/pmap.c  6 Sep 2013 17:43:19 -0000       1.113
+++ sys/arch/sun3/sun3x/pmap.c  22 Dec 2016 10:34:15 -0000
@@@@ -893,8 +893,8 @@@@

       /* Notify the VM system of our page size. */
       uvmexp.pagesize = PAGE_SIZE;
-       uvm_setpagesize();
-
+       uvm_md_init();
+
       pmap_page_upload();
}

Index: sys/arch/usermode/usermode/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/usermode/usermode/machdep.c,v
retrieving revision 1.53
diff -u -r1.53 machdep.c
--- sys/arch/usermode/usermode/machdep.c        8 Feb 2012 17:55:21 -0000       1.53
+++ sys/arch/usermode/usermode/machdep.c        22 Dec 2016 10:34:16 -0000
@@@@ -213,7 +213,7 @@@@
       }
       boothowto = tmpopt;

-       uvm_setpagesize();
+       uvm_md_init();
       uvmexp.ncolors = 2;

       pmap_bootstrap();
Index: sys/arch/vax/vax/ka650.c
d1190 2
a1191 2
--- sys/arch/vax/vax/ka650.c    14 Dec 2010 23:44:49 -0000      1.36
+++ sys/arch/vax/vax/ka650.c    22 Dec 2016 10:34:18 -0000
d1201 1
a1201 1
Index: sys/arch/vax/vax/pmap.c
d1204 4
a1207 4
retrieving revision 1.182
diff -u -r1.182 pmap.c
--- sys/arch/vax/vax/pmap.c     2 Feb 2012 18:59:44 -0000       1.182
+++ sys/arch/vax/vax/pmap.c     22 Dec 2016 10:34:19 -0000
a1215 9
@@@@ -302,7 +303,7 @@@@

       /* Set logical page size */
       uvmexp.pagesize = NBPG;
-       uvm_setpagesize();
+       uvm_md_init();

       physmem = btoc(avail_end);

d1240 1
a1240 1
Index: sys/arch/x68k/x68k/machdep.c
d1245 2
a1246 2
--- sys/arch/x68k/x68k/machdep.c        2 Dec 2016 12:43:07 -0000       1.194
+++ sys/arch/x68k/x68k/machdep.c        22 Dec 2016 10:34:22 -0000
d1325 1
a1325 82
Index: sys/arch/x68k/x68k/pmap_bootstrap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x68k/x68k/pmap_bootstrap.c,v
retrieving revision 1.60
diff -u -r1.60 pmap_bootstrap.c
--- sys/arch/x68k/x68k/pmap_bootstrap.c 27 Oct 2013 02:06:06 -0000      1.60
+++ sys/arch/x68k/x68k/pmap_bootstrap.c 22 Dec 2016 10:34:22 -0000
@@@@ -52,7 +52,8 @@@@

extern char *etext;

-extern int maxmem, physmem;
+extern int maxmem;
+extern psize_t physmem;
extern paddr_t avail_start, avail_end;

/*
Index: sys/arch/zaurus/zaurus/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/zaurus/machdep.c,v
retrieving revision 1.37
diff -u -r1.37 machdep.c
--- sys/arch/zaurus/zaurus/machdep.c    7 Jul 2016 06:55:40 -0000       1.37
+++ sys/arch/zaurus/zaurus/machdep.c    22 Dec 2016 10:34:30 -0000
@@@@ -1090,7 +1090,7 @@@@
#ifdef VERBOSE_INIT_ARM
       printf("page ");
#endif
-       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_md_init();
       uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
           atop(physical_freestart), atop(physical_freeend),
           VM_FREELIST_DEFAULT);
Index: sys/rump/librump/rumpkern/emul.c
===================================================================
RCS file: /cvsroot/src/sys/rump/librump/rumpkern/emul.c,v
retrieving revision 1.179
diff -u -r1.179 emul.c
--- sys/rump/librump/rumpkern/emul.c    26 Jan 2016 23:12:17 -0000      1.179
+++ sys/rump/librump/rumpkern/emul.c    22 Dec 2016 10:38:34 -0000
@@@@ -54,7 +54,7 @@@@
 * calling rump_init()
 */
#define PHYSMEM 512*256
-int physmem = PHYSMEM;
+psize_t physmem = PHYSMEM;
int nkmempages = PHYSMEM/2; /* from le chapeau */
#undef PHYSMEM

Index: sys/sys/systm.h
===================================================================
RCS file: /cvsroot/src/sys/sys/systm.h,v
retrieving revision 1.271
diff -u -r1.271 systm.h
--- sys/sys/systm.h     6 Jul 2016 05:20:48 -0000       1.271
+++ sys/sys/systm.h     22 Dec 2016 10:38:38 -0000
@@@@ -82,7 +82,7 @@@@
extern int selwait;            /* select timeout address */

extern int maxmem;             /* max memory per process */
-extern int physmem;            /* physical memory */
+extern psize_t physmem;                /* physical memory */

extern dev_t dumpdev;          /* dump device */
extern dev_t dumpcdev;         /* dump device (character equivalent) */
Index: sys/uvm/Makefile
===================================================================
RCS file: /cvsroot/src/sys/uvm/Makefile,v
retrieving revision 1.9
diff -u -r1.9 Makefile
--- sys/uvm/Makefile    11 Feb 2006 12:45:07 -0000      1.9
+++ sys/uvm/Makefile    22 Dec 2016 10:38:43 -0000
@@@@ -5,7 +5,7 @@@@
INCS=  uvm.h uvm_amap.h uvm_anon.h uvm_aobj.h uvm_device.h \
       uvm_extern.h uvm_fault.h uvm_fault_i.h uvm_glue.h \
       uvm_km.h uvm_loan.h \
-       uvm_map.h uvm_object.h uvm_page.h \
+       uvm_map.h uvm_object.h uvm_page.h uvm_physseg.h \
       uvm_pager.h uvm_param.h uvm_pdaemon.h uvm_pglist.h \
       uvm_pmap.h uvm_prot.h uvm_stat.h \
       uvm_swap.h
Index: sys/uvm/files.uvm
d1330 2
a1331 2
--- sys/uvm/files.uvm   1 Dec 2016 02:09:03 -0000       1.27
+++ sys/uvm/files.uvm   22 Dec 2016 10:38:43 -0000
d1348 1
a1348 56
Index: sys/uvm/uvm.h
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm.h,v
retrieving revision 1.66
diff -u -r1.66 uvm.h
--- sys/uvm/uvm.h       13 Apr 2015 22:04:44 -0000      1.66
+++ sys/uvm/uvm.h       22 Dec 2016 10:38:43 -0000
@@@@ -57,6 +57,7 @@@@
#include <uvm/uvm_object.h>
#include <uvm/uvm_page.h>
#include <uvm/uvm_pager.h>
+#include <uvm/uvm_physseg.h>
#include <uvm/uvm_pdaemon.h>
#include <uvm/uvm_swap.h>

Index: sys/uvm/uvm_extern.h
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_extern.h,v
retrieving revision 1.198
diff -u -r1.198 uvm_extern.h
--- sys/uvm/uvm_extern.h        20 Jul 2016 12:38:43 -0000      1.198
+++ sys/uvm/uvm_extern.h        22 Dec 2016 10:38:44 -0000
@@@@ -475,6 +475,14 @@@@
#endif

/*
+ * Include the uvm_hotplug(9) API unconditionally until
+ * uvm_page_physload() et. al. are obsoleted
+ *
+ * After this, MD code will have to explicitly include it if needed.
+ */
+#include <uvm/uvm_physseg.h>
+
+/*
 * helpers for calling ubc_release()
 */
#ifdef PMAP_CACHE_VIVT
@@@@ -619,6 +627,7 @@@@


/* uvm_init.c */
+void                   uvm_md_init(void);
void                   uvm_init(void);

/* uvm_io.c */
@@@@ -708,9 +717,6 @@@@
                           struct vm_page *);
void                   uvm_pagerealloc(struct vm_page *,
                           struct uvm_object *, voff_t);
-/* Actually, uvm_page_physload takes PF#s which need their own type */
-void                   uvm_page_physload(paddr_t, paddr_t, paddr_t,
-                           paddr_t, int);
void                   uvm_setpagesize(void);

/* uvm_pager.c */
Index: sys/uvm/uvm_init.c
d1351 4
a1354 4
retrieving revision 1.46
diff -u -r1.46 uvm_init.c
--- sys/uvm/uvm_init.c  3 Apr 2015 01:03:42 -0000       1.46
+++ sys/uvm/uvm_init.c  22 Dec 2016 10:38:44 -0000
d1363 6
a1368 2
@@@@ -69,6 +70,20 @@@@
kmutex_t uvm_swap_data_lock;
d1371 14
a1384 15
+ * uvm_md_init: Init dependant on the MD boot context.
+ *             called from MD code.
+ */
+
+void
+uvm_md_init(void)
+{
+       uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
+#ifdef UVM_HOTPLUG /* XXX: Notyet */
+       uvm_physseg_init();
+#endif
+}
+
+/*
 * uvm_init: init the VM system.   called from kern/init_main.c.
d1387 6
a1392 7
Index: sys/uvm/uvm_page.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_page.c,v
retrieving revision 1.187
diff -u -r1.187 uvm_page.c
--- sys/uvm/uvm_page.c  11 Apr 2015 19:24:13 -0000      1.187
+++ sys/uvm/uvm_page.c  22 Dec 2016 10:38:44 -0000
a1418 9
@@@@ -116,7 +105,7 @@@@
/*
 * physical memory size;
 */
-int physmem;
+psize_t physmem;

/*
 * local variables
d1628 1
a1628 1
@@@@ -727,228 +667,6 @@@@
d1640 1
a1640 1
-void
d1666 1
a1666 1
-               return;
d1745 2
d1859 1
a1859 1
@@@@ -956,12 +674,12 @@@@
d1877 1
a1877 1
@@@@ -985,7 +703,8 @@@@
d1887 1
a1887 9
@@@@ -1094,6 +813,7 @@@@
       uvm.cpus[cpu_index(ci)] = ucpu;
       ci->ci_data.cpu_uvm = ucpu;
       for (lcv = 0; lcv < VM_NFREELIST; lcv++) {
+
               pgfl.pgfl_buckets = (bucketarray + (lcv * uvmexp.ncolors));
               uvm_page_init_buckets(&pgfl);
               ucpu->page_free[lcv].pgfl_buckets = pgfl.pgfl_buckets;
@@@@ -1219,7 +939,8 @@@@
d1897 1
a1897 1
@@@@ -2005,7 +1726,7 @@@@
d1906 1
a1906 1
@@@@ -2015,11 +1736,11 @@@@
d1922 1
a1922 1
@@@@ -2135,7 +1856,8 @@@@
d1932 1
a1932 1
@@@@ -2143,8 +1865,14 @@@@
d1949 1
a1949 1
Index: sys/uvm/uvm_page.h
d1954 2
a1955 2
--- sys/uvm/uvm_page.h  23 Mar 2015 07:59:12 -0000      1.80
+++ sys/uvm/uvm_page.h  22 Dec 2016 10:38:44 -0000
d2018 1
a2018 1
Index: sys/uvm/uvm_pglist.c
d2023 2
a2024 2
--- sys/uvm/uvm_pglist.c        26 Oct 2014 01:42:07 -0000      1.67
+++ sys/uvm/uvm_pglist.c        22 Dec 2016 10:38:45 -0000
d2345 25
a2369 1
Index: sys/uvm/pmap/pmap.c
d2374 2
a2375 2
--- sys/uvm/pmap/pmap.c 1 Dec 2016 02:15:08 -0000       1.25
+++ sys/uvm/pmap/pmap.c 22 Dec 2016 10:38:45 -0000
@


1.2
log
@Implement gimpy's suggestion of using uvm_md_init()
@
text
@d7 1
a7 1
+++ share/man/man9/Makefile     22 Dec 2016 09:18:20 -0000
d25 1
a25 1
+++ sys/arch/acorn26/acorn26/pmap.c     22 Dec 2016 09:18:27 -0000
d64 1
a64 1
+++ sys/arch/acorn26/acorn26/start.c    22 Dec 2016 09:18:28 -0000
d80 1
a80 1
+++ sys/arch/acorn32/acorn32/rpc_machdep.c      22 Dec 2016 09:18:33 -0000
d97 1
a97 1
+++ sys/arch/acorn32/eb7500atx/eb7500atx_machdep.c      22 Dec 2016 09:18:33 -0000
d114 1
a114 1
+++ sys/arch/algor/algor/machdep.c      22 Dec 2016 09:18:39 -0000
d130 1
a130 1
+++ sys/arch/alpha/alpha/machdep.c      22 Dec 2016 09:18:42 -0000
d191 1
a191 1
+++ sys/arch/alpha/alpha/pmap.c 22 Dec 2016 09:18:42 -0000
d286 1
a286 1
+++ sys/arch/amd64/amd64/machdep.c      22 Dec 2016 09:18:46 -0000
a413 15
Index: sys/arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.448
diff -u -r1.448 GENERIC
--- sys/arch/amd64/conf/GENERIC 18 Dec 2016 04:35:26 -0000      1.448
+++ sys/arch/amd64/conf/GENERIC 22 Dec 2016 09:18:46 -0000
@@@@ -50,6 +50,7 @@@@
# and can deal with holes in the memory layout.
#options       PHYSMEM_MAX_SIZE=64     # max size of physical memory (in MB)
#options       PHYSMEM_MAX_ADDR=2048   # don't use memory above this (in MB)
+#options       UVM_HOTPLUG     # Experimental uvm_hotplug(9) api.

# Standard system options

d420 1
a420 1
+++ sys/arch/amiga/amiga/pmap_bootstrap.c       22 Dec 2016 09:18:47 -0000
d438 1
a438 1
+++ sys/arch/amigappc/amigappc/machdep.c        22 Dec 2016 09:18:51 -0000
d457 1
a457 1
+++ sys/arch/arc/arc/machdep.c  22 Dec 2016 09:18:53 -0000
d478 1
a478 1
+++ sys/arch/arm/arm32/arm32_boot.c     22 Dec 2016 09:18:55 -0000
d496 1
a496 1
+++ sys/arch/arm/arm32/bus_dma.c        22 Dec 2016 09:18:55 -0000
d518 1
a518 1
+++ sys/arch/arm/arm32/pmap.c   22 Dec 2016 09:18:56 -0000
d536 1
a536 1
+++ sys/arch/arm/at91/at91bus.c 22 Dec 2016 09:18:56 -0000
a545 14
Index: sys/arch/arm/omap/omap3_sdmavar.h
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/omap/omap3_sdmavar.h,v
retrieving revision 1.1
diff -u -r1.1 omap3_sdmavar.h
--- sys/arch/arm/omap/omap3_sdmavar.h   9 Jan 2013 03:35:11 -0000       1.1
+++ sys/arch/arm/omap/omap3_sdmavar.h   22 Dec 2016 09:19:05 -0000
@@@@ -38,4 +38,4 @@@@
uint32_t omapdma_read_ch_reg(int, int);


-#endif /* OMAPDMA_VAR_H */
\ No newline at end of file
+#endif /* OMAPDMA_VAR_H */
d552 1
a552 1
+++ sys/arch/atari/atari/pmap_bootstrap.c       22 Dec 2016 09:19:11 -0000
d570 2
a571 10
+++ sys/arch/cesfic/cesfic/machdep.c    22 Dec 2016 09:19:16 -0000
@@@@ -88,6 +88,7 @@@@
#define        MAXMEM  64*1024 /* XXX - from cmap.h */

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/sysctl.h>
#include <sys/device.h>
@@@@ -111,7 +112,7 @@@@
a579 8
@@@@ -146,6 +147,7 @@@@
        * Tell the VM system about available physical memory.  The
        * fic uses one segment.
        */
+       uvm_physseg_init();
       uvm_page_physload(atop(avail_start), atop(avail_end),
           atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT);

d586 1
a586 1
+++ sys/arch/cobalt/cobalt/machdep.c    22 Dec 2016 09:19:16 -0000
d604 1
a604 1
+++ sys/arch/dreamcast/dreamcast/machdep.c      22 Dec 2016 09:19:17 -0000
d627 1
a627 1
+++ sys/arch/emips/emips/machdep.c      22 Dec 2016 09:19:18 -0000
d654 1
a654 1
+++ sys/arch/epoc32/epoc32/machdep.c    22 Dec 2016 09:19:19 -0000
d670 1
a670 1
+++ sys/arch/evbarm/adi_brh/brh_machdep.c       22 Dec 2016 09:19:19 -0000
d686 1
a686 1
+++ sys/arch/evbarm/armadillo/armadillo9_machdep.c      22 Dec 2016 09:19:19 -0000
d702 1
a702 1
+++ sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c   22 Dec 2016 09:19:20 -0000
d718 1
a718 1
+++ sys/arch/evbarm/gemini/gemini_machdep.c     22 Dec 2016 09:19:20 -0000
d736 1
a736 1
+++ sys/arch/evbarm/hdl_g/hdlg_machdep.c        22 Dec 2016 09:19:20 -0000
d752 1
a752 1
+++ sys/arch/evbarm/imx31/imx31lk_machdep.c     22 Dec 2016 09:19:20 -0000
d768 1
a768 1
+++ sys/arch/evbarm/iq80310/iq80310_machdep.c   22 Dec 2016 09:19:21 -0000
d784 1
a784 1
+++ sys/arch/evbarm/iq80321/iq80321_machdep.c   22 Dec 2016 09:19:21 -0000
d800 1
a800 1
+++ sys/arch/evbarm/ixdp425/ixdp425_machdep.c   22 Dec 2016 09:19:21 -0000
d816 1
a816 1
+++ sys/arch/evbarm/ixm1200/ixm1200_machdep.c   22 Dec 2016 09:19:21 -0000
d832 1
a832 1
+++ sys/arch/evbarm/lubbock/lubbock_machdep.c   22 Dec 2016 09:19:21 -0000
d848 1
a848 1
+++ sys/arch/evbarm/mini2440/mini2440_machdep.c 22 Dec 2016 09:19:21 -0000
d864 1
a864 1
+++ sys/arch/evbarm/npwr_fc/npwr_fc_machdep.c   22 Dec 2016 09:19:21 -0000
d880 1
a880 1
+++ sys/arch/evbarm/nslu2/nslu2_machdep.c       22 Dec 2016 09:19:21 -0000
d896 1
a896 1
+++ sys/arch/evbarm/osk5912/osk5912_machdep.c   22 Dec 2016 09:19:22 -0000
d912 1
a912 1
+++ sys/arch/evbarm/smdk2xx0/smdk2410_machdep.c 22 Dec 2016 09:19:22 -0000
d928 1
a928 1
+++ sys/arch/evbarm/smdk2xx0/smdk2800_machdep.c 22 Dec 2016 09:19:22 -0000
d944 1
a944 1
+++ sys/arch/evbarm/tisdp24xx/sdp24xx_machdep.c 22 Dec 2016 09:19:22 -0000
d960 1
a960 1
+++ sys/arch/evbarm/tsarm/tsarm_machdep.c       22 Dec 2016 09:19:22 -0000
d976 1
a976 1
+++ sys/arch/evbarm/viper/viper_machdep.c       22 Dec 2016 09:19:22 -0000
d992 1
a992 1
+++ sys/arch/evbmips/adm5120/machdep.c  22 Dec 2016 09:19:23 -0000
d1011 1
a1011 1
+++ sys/arch/evbmips/alchemy/machdep.c  22 Dec 2016 09:19:23 -0000
d1030 1
a1030 1
+++ sys/arch/evbmips/atheros/machdep.c  22 Dec 2016 09:19:23 -0000
d1049 1
a1049 1
+++ sys/arch/evbmips/cavium/machdep.c   22 Dec 2016 09:19:23 -0000
d1066 1
a1066 1
+++ sys/arch/evbmips/gdium/machdep.c    22 Dec 2016 09:19:23 -0000
d1083 1
a1083 1
+++ sys/arch/evbmips/ingenic/machdep.c  22 Dec 2016 09:19:23 -0000
a1092 14
Index: sys/arch/evbmips/loongson/loongson_clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/loongson/loongson_clock.c,v
retrieving revision 1.1
diff -u -r1.1 loongson_clock.c
--- sys/arch/evbmips/loongson/loongson_clock.c  24 Jun 2016 21:41:37 -0000      1.1
+++ sys/arch/evbmips/loongson/loongson_clock.c  22 Dec 2016 09:19:23 -0000
@@@@ -388,4 +388,4 @@@@

__weak_alias(setstatclockrate, loongson_setstatclockrate);
__weak_alias(cpu_initclocks, loongson_initclocks);
-__weak_alias(delay, loongson_delay);
\ No newline at end of file
+__weak_alias(delay, loongson_delay);
d1099 1
a1099 1
+++ sys/arch/evbmips/loongson/machdep.c 22 Dec 2016 09:19:23 -0000
d1118 1
a1118 1
+++ sys/arch/evbmips/malta/machdep.c    22 Dec 2016 09:19:24 -0000
d1135 1
a1135 1
+++ sys/arch/evbmips/rasoc/machdep.c    22 Dec 2016 09:19:24 -0000
d1154 1
a1154 1
+++ sys/arch/evbmips/rmixl/machdep.c    22 Dec 2016 09:19:24 -0000
d1171 1
a1171 1
+++ sys/arch/evbppc/ev64260/machdep.c   22 Dec 2016 09:19:24 -0000
d1190 1
a1190 1
+++ sys/arch/evbppc/mpc85xx/machdep.c   22 Dec 2016 09:19:24 -0000
d1209 1
a1209 1
+++ sys/arch/evbppc/pmppc/machdep.c     22 Dec 2016 09:19:24 -0000
a1221 23
Index: sys/arch/evbsh3/evbsh3/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbsh3/evbsh3/machdep.c,v
retrieving revision 1.75
diff -u -r1.75 machdep.c
--- sys/arch/evbsh3/evbsh3/machdep.c    19 Jun 2014 13:20:13 -0000      1.75
+++ sys/arch/evbsh3/evbsh3/machdep.c    22 Dec 2016 09:19:25 -0000
@@@@ -85,6 +85,7 @@@@
#include <sys/bus.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -303,6 +304,7 @@@@
       /* Load memory to UVM */
       kernend = atop(round_page(SH3_P1SEG_TO_PHYS(end)));
       physmem = atop(IOM_RAM_SIZE);
+       uvm_physseg_init();
       uvm_page_physload(
               kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
               kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
d1228 1
a1228 1
+++ sys/arch/ews4800mips/ews4800mips/machdep.c  22 Dec 2016 09:19:25 -0000
a1239 23
Index: sys/arch/hp300/hp300/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/machdep.c,v
retrieving revision 1.229
diff -u -r1.229 machdep.c
--- sys/arch/hp300/hp300/machdep.c      20 Apr 2014 04:12:54 -0000      1.229
+++ sys/arch/hp300/hp300/machdep.c      22 Dec 2016 09:19:27 -0000
@@@@ -100,6 +100,7 @@@@

#define        MAXMEM  64*1024 /* XXX - from cmap.h */
#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/sysctl.h>

@@@@ -197,6 +198,7 @@@@
        * Tell the VM system about available physical memory.  The
        * hp300 only has one segment.
        */
+       uvm_physseg_init();
       uvm_page_physload(atop(avail_start), atop(avail_end),
           atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT);

d1246 1
a1246 1
+++ sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c 22 Dec 2016 09:19:29 -0000
d1262 1
a1262 1
+++ sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c 22 Dec 2016 09:19:29 -0000
d1278 1
a1278 1
+++ sys/arch/hpcmips/hpcmips/machdep.c  22 Dec 2016 09:19:31 -0000
a1287 23
Index: sys/arch/hpcsh/hpcsh/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hpcsh/hpcsh/machdep.c,v
retrieving revision 1.77
diff -u -r1.77 machdep.c
--- sys/arch/hpcsh/hpcsh/machdep.c      24 Mar 2014 20:06:32 -0000      1.77
+++ sys/arch/hpcsh/hpcsh/machdep.c      22 Dec 2016 09:19:33 -0000
@@@@ -56,6 +56,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <ufs/mfs/mfs_extern.h>                /* mfs_initminiroot() */

@@@@ -281,6 +282,7 @@@@
#endif

       /* Find memory cluster. and load to UVM */
+       uvm_physseg_init();
       physmem = mem_cluster_init(SH3_P1SEG_TO_PHYS(kernend));
       _DPRINTF("total memory = %dMbyte\n", (int)(sh3_ptob(physmem) >> 20));
       mem_cluster_load();
d1294 1
a1294 1
+++ sys/arch/hppa/hppa/pmap.c   22 Dec 2016 09:19:34 -0000
a1305 15
Index: sys/arch/i386/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.1145
diff -u -r1.1145 GENERIC
--- sys/arch/i386/conf/GENERIC  13 Dec 2016 20:42:18 -0000      1.1145
+++ sys/arch/i386/conf/GENERIC  22 Dec 2016 09:19:36 -0000
@@@@ -71,6 +71,7 @@@@
# and can deal with holes in the memory layout.
#options       PHYSMEM_MAX_SIZE=64     # max size of physical memory (in MB)
#options       PHYSMEM_MAX_ADDR=2048   # don't use memory above this (in MB)
+#options       UVM_HOTPLUG             # Experimental uvm_hotplug(9) api.

# Standard system options

d1312 1
a1312 1
+++ sys/arch/i386/i386/machdep.c        22 Dec 2016 09:19:36 -0000
d1410 1
a1410 1
+++ sys/arch/ia64/ia64/machdep.c        22 Dec 2016 09:19:39 -0000
d1456 1
a1456 1
+++ sys/arch/ia64/ia64/pmap.c   22 Dec 2016 09:19:39 -0000
d1599 1
a1599 1
+++ sys/arch/iyonix/iyonix/iyonix_machdep.c     22 Dec 2016 09:19:40 -0000
a1608 46
Index: sys/arch/landisk/landisk/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/landisk/landisk/machdep.c,v
retrieving revision 1.20
diff -u -r1.20 machdep.c
--- sys/arch/landisk/landisk/machdep.c  17 Dec 2016 01:32:22 -0000      1.20
+++ sys/arch/landisk/landisk/machdep.c  22 Dec 2016 09:19:41 -0000
@@@@ -89,6 +89,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>
#include <ufs/mfs/mfs_extern.h>                /* mfs_initminiroot() */

#include <dev/cons.h>
@@@@ -218,6 +219,7 @@@@
       /* Load memory to UVM */
       physmem = atop(IOM_RAM_SIZE);
       kernend = atop(round_page(SH3_P1SEG_TO_PHYS(kernend)));
+       uvm_physseg_init();
       uvm_page_physload(
               physmem, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
               kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
Index: sys/arch/luna68k/luna68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/luna68k/machdep.c,v
retrieving revision 1.99
diff -u -r1.99 machdep.c
--- sys/arch/luna68k/luna68k/machdep.c  21 Aug 2015 10:48:06 -0000      1.99
+++ sys/arch/luna68k/luna68k/machdep.c  22 Dec 2016 09:19:41 -0000
@@@@ -73,6 +73,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/sysctl.h>

@@@@ -175,6 +176,7 @@@@
        * Tell the VM system about available physical memory.  The
        * luna68k only has one segment.
        */
+       uvm_physseg_init();
       uvm_page_physload(atop(avail_start), atop(avail_end),
           atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT);

d1615 1
a1615 1
+++ sys/arch/luna68k/luna68k/pmap_bootstrap.c   22 Dec 2016 09:19:41 -0000
d1632 1
a1632 1
+++ sys/arch/m68k/m68k/pmap_motorola.c  22 Dec 2016 09:19:43 -0000
a1728 23
Index: sys/arch/mac68k/mac68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/machdep.c,v
retrieving revision 1.349
diff -u -r1.349 machdep.c
--- sys/arch/mac68k/mac68k/machdep.c    30 Aug 2015 01:46:03 -0000      1.349
+++ sys/arch/mac68k/mac68k/machdep.c    22 Dec 2016 09:19:45 -0000
@@@@ -136,6 +136,7 @@@@

#define        MAXMEM  64*1024 /* XXX - from cmap.h */
#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/sysctl.h>

@@@@ -253,6 +254,7 @@@@
        * Notice that we don't need to worry about avail_end here
        * since it's equal to high[numranges-1].
        */
+       uvm_physseg_init();
       for (i = 0; i < numranges; i++) {
               if (low[i] <= avail_start && avail_start < high[i])
                       uvm_page_physload(atop(avail_start), atop(high[i]),
d1735 1
a1735 1
+++ sys/arch/mips/include/pmap.h        22 Dec 2016 09:19:51 -0000
a1753 14
Index: sys/arch/mips/ingenic/jzfb_regs.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/ingenic/jzfb_regs.h,v
retrieving revision 1.1
diff -u -r1.1 jzfb_regs.h
--- sys/arch/mips/ingenic/jzfb_regs.h   7 Apr 2016 01:00:05 -0000       1.1
+++ sys/arch/mips/ingenic/jzfb_regs.h   22 Dec 2016 09:19:51 -0000
@@@@ -86,4 +86,4 @@@@
#define JZ_LCDENH_GAMMA                0x0800
#define JZ_LCDENH_VEE          0x1000

-#endif /* JZFB_REGS_H */
\ No newline at end of file
+#endif /* JZFB_REGS_H */
d1760 1
a1760 1
+++ sys/arch/mips/mips/mips_machdep.c   22 Dec 2016 09:19:52 -0000
d1827 1
a1827 1
+++ sys/arch/mips/mips/pmap_machdep.c   22 Dec 2016 09:19:52 -0000
d1870 1
a1870 1
+++ sys/arch/mipsco/mipsco/machdep.c    22 Dec 2016 09:19:54 -0000
a1884 46
Index: sys/arch/mmeye/mmeye/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mmeye/mmeye/machdep.c,v
retrieving revision 1.57
diff -u -r1.57 machdep.c
--- sys/arch/mmeye/mmeye/machdep.c      8 Nov 2013 02:24:53 -0000       1.57
+++ sys/arch/mmeye/mmeye/machdep.c      22 Dec 2016 09:19:55 -0000
@@@@ -85,6 +85,7 @@@@
#include <sys/systm.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sh3/bscreg.h>
#include <sh3/cpgreg.h>
@@@@ -304,6 +305,7 @@@@
       /* Load memory to UVM */
       physmem = atop(IOM_RAM_SIZE);
       kernend = atop(round_page(SH3_P1SEG_TO_PHYS(kernend)));
+       uvm_physseg_init();
       uvm_page_physload(
               kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
               kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
Index: sys/arch/mvme68k/mvme68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/mvme68k/machdep.c,v
retrieving revision 1.154
diff -u -r1.154 machdep.c
--- sys/arch/mvme68k/mvme68k/machdep.c  31 May 2016 03:25:46 -0000      1.154
+++ sys/arch/mvme68k/mvme68k/machdep.c  22 Dec 2016 09:19:56 -0000
@@@@ -80,6 +80,7 @@@@
#endif

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/sysctl.h>

@@@@ -218,6 +219,7 @@@@
       /*
        * Tell the VM system about available physical memory.
        */
+       uvm_physseg_init();
       for (i = 0; i < mem_cluster_cnt; i++) {
               if (phys_seg_list[i].ps_start == phys_seg_list[i].ps_end) {
                       /*
d1891 1
a1891 1
+++ sys/arch/netwinder/netwinder/netwinder_machdep.c    22 Dec 2016 09:19:56 -0000
a1911 23
Index: sys/arch/news68k/news68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/news68k/news68k/machdep.c,v
retrieving revision 1.101
diff -u -r1.101 machdep.c
--- sys/arch/news68k/news68k/machdep.c  24 Mar 2014 19:54:28 -0000      1.101
+++ sys/arch/news68k/news68k/machdep.c  22 Dec 2016 09:19:57 -0000
@@@@ -89,6 +89,7 @@@@

#define MAXMEM 64*1024         /* XXX - from cmap.h */
#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/sysctl.h>

@@@@ -164,6 +165,7 @@@@
        * Tell the VM system about available physical memory.  The
        * news68k only has one segment.
        */
+       uvm_physseg_init();
       uvm_page_physload(atop(avail_start), atop(avail_end),
           atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT);

d1918 1
a1918 1
+++ sys/arch/newsmips/newsmips/machdep.c        22 Dec 2016 09:19:57 -0000
a1932 23
Index: sys/arch/next68k/next68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/next68k/next68k/machdep.c,v
retrieving revision 1.111
diff -u -r1.111 machdep.c
--- sys/arch/next68k/next68k/machdep.c  24 Mar 2014 20:01:03 -0000      1.111
+++ sys/arch/next68k/next68k/machdep.c  22 Dec 2016 09:19:58 -0000
@@@@ -77,6 +77,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#ifdef DDB
#include <machine/db_machdep.h>
@@@@ -181,6 +182,7 @@@@
       /*
        * Tell the VM system about available physical memory.
        */
+       uvm_physseg_init();
       for (i = 0; i < mem_cluster_cnt; i++) {
               if (phys_seg_list[i].ps_start == phys_seg_list[i].ps_end) {
                       /*
d1939 1
a1939 1
+++ sys/arch/playstation2/playstation2/machdep.c        22 Dec 2016 09:19:59 -0000
d1956 1
a1956 1
+++ sys/arch/pmax/pmax/machdep.c        22 Dec 2016 09:20:00 -0000
d1975 1
a1975 1
+++ sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c    22 Dec 2016 09:20:01 -0000
d1991 1
a1991 1
+++ sys/arch/powerpc/ibm4xx/pmap.c      22 Dec 2016 09:20:01 -0000
d2025 1
a2025 1
+++ sys/arch/powerpc/isa/isadma_machdep.c       22 Dec 2016 09:20:03 -0000
d2062 1
a2062 1
+++ sys/arch/powerpc/oea/ofwoea_machdep.c       22 Dec 2016 09:20:04 -0000
d2078 1
a2078 1
+++ sys/arch/powerpc/oea/pmap.c 22 Dec 2016 09:20:04 -0000
d2196 1
a2196 1
+++ sys/arch/powerpc/oea/prep_machdep.c 22 Dec 2016 09:20:04 -0000
d2212 1
a2212 1
+++ sys/arch/powerpc/powerpc/bus_dma.c  22 Dec 2016 09:20:04 -0000
d2249 1
a2249 1
+++ sys/arch/rs6000/rs6000/machdep.c    22 Dec 2016 09:20:07 -0000
d2265 1
a2265 1
+++ sys/arch/sandpoint/sandpoint/machdep.c      22 Dec 2016 09:20:07 -0000
d2282 1
a2282 1
+++ sys/arch/sbmips/sbmips/machdep.c    22 Dec 2016 09:20:08 -0000
d2298 1
a2298 1
+++ sys/arch/sgimips/sgimips/machdep.c  22 Dec 2016 09:20:10 -0000
d2314 1
a2314 1
+++ sys/arch/sh3/sh3/pmap.c     22 Dec 2016 09:20:11 -0000
d2390 1
a2390 1
+++ sys/arch/sh3/sh3/sh3_machdep.c      22 Dec 2016 09:20:11 -0000
d2408 1
a2408 1
+++ sys/arch/sh3/sh3/vm_machdep.c       22 Dec 2016 09:20:11 -0000
d2432 1
a2432 1
+++ sys/arch/shark/ofw/ofw.c    22 Dec 2016 09:20:11 -0000
d2449 1
a2449 1
+++ sys/arch/sparc/sparc/pmap.c 22 Dec 2016 09:20:17 -0000
d2465 1
a2465 1
+++ sys/arch/sparc64/sparc64/pmap.c     22 Dec 2016 09:20:20 -0000
d2483 1
a2483 1
+++ sys/arch/sun2/sun2/pmap.c   22 Dec 2016 09:20:22 -0000
d2499 1
a2499 1
+++ sys/arch/sun3/sun3/pmap.c   22 Dec 2016 09:20:24 -0000
d2515 1
a2515 1
+++ sys/arch/sun3/sun3x/pmap.c  22 Dec 2016 09:20:24 -0000
d2533 1
a2533 1
+++ sys/arch/usermode/usermode/machdep.c        22 Dec 2016 09:20:27 -0000
a2542 24
Index: sys/arch/usermode/usermode/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/usermode/usermode/pmap.c,v
retrieving revision 1.106
diff -u -r1.106 pmap.c
--- sys/arch/usermode/usermode/pmap.c   7 Jul 2016 06:55:39 -0000       1.106
+++ sys/arch/usermode/usermode/pmap.c   22 Dec 2016 09:20:27 -0000
@@@@ -45,6 +45,7 @@@@
#include <machine/pcb.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

struct pv_entry {
       struct          pv_entry *pv_next;
@@@@ -409,6 +410,8 @@@@
       }
       thunk_printf_debug("kernel pmap entries mem added to the kernel pmap\n");

+       uvm_physseg_init();
+
       /* add file space to uvm's FREELIST */
       uvm_page_physload(atop(0),
           atop(free_end),
d2549 1
a2549 1
+++ sys/arch/vax/vax/ka650.c    22 Dec 2016 09:20:28 -0000
d2565 1
a2565 1
+++ sys/arch/vax/vax/pmap.c     22 Dec 2016 09:20:28 -0000
d2583 1
a2583 9
@@@@ -446,6 +447,7 @@@@
       /*
        * Now everything should be complete, start virtual memory.
        */
+       uvm_physseg_init();
       uvm_page_physload(avail_start >> PGSHIFT, avail_end >> PGSHIFT,
           avail_start >> PGSHIFT, avail_end >> PGSHIFT,
           VM_FREELIST_DEFAULT);
@@@@ -475,7 +477,8 @@@@
d2593 1
a2593 1
@@@@ -490,10 +493,10 @@@@
d2613 1
a2613 1
+++ sys/arch/x68k/x68k/machdep.c        22 Dec 2016 09:20:32 -0000
d2622 1
a2622 10
@@@@ -184,6 +185,8 @@@@
       paddr_t msgbuf_pa;
       paddr_t s, e;

+       uvm_physseg_init();
+
       /*
        * Most m68k ports allocate msgbuf at the end of available memory
        * (i.e. just after avail_end), but on x68k we allocate msgbuf
@@@@ -553,10 +556,7 @@@@
d2634 1
a2634 1
@@@@ -605,20 +605,25 @@@@
d2673 1
a2673 1
@@@@ -1249,11 +1254,14 @@@@
d2698 1
a2698 1
+++ sys/arch/x68k/x68k/pmap_bootstrap.c 22 Dec 2016 09:20:32 -0000
a2708 99
Index: sys/arch/x86/x86/x86_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/x86_machdep.c,v
retrieving revision 1.79
diff -u -r1.79 x86_machdep.c
--- sys/arch/x86/x86/x86_machdep.c      20 Dec 2016 14:03:15 -0000      1.79
+++ sys/arch/x86/x86/x86_machdep.c      22 Dec 2016 09:20:37 -0000
@@@@ -67,6 +67,7 @@@@
#include <machine/vmparam.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include "acpica.h"
#if NACPICA > 0
Index: sys/arch/xen/xen/balloon.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/xen/balloon.c,v
retrieving revision 1.17
diff -u -r1.17 balloon.c
--- sys/arch/xen/xen/balloon.c  7 Jul 2016 06:55:40 -0000       1.17
+++ sys/arch/xen/xen/balloon.c  22 Dec 2016 09:20:39 -0000
@@@@ -70,6 +70,10 @@@@

#define BALLOONDEBUG 0

+#if defined(_KERNEL_OPT)
+#include "opt_uvm_hotplug.h"
+#endif
+
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.17 2016/07/07 06:55:40 msaitoh Exp $");

@@@@ -93,6 +97,7 @@@@

#include <uvm/uvm.h>
#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>
#include <xen/xenpmap.h>

#include "locators.h"
@@@@ -454,6 +459,7 @@@@

       memset(mfn_list, 0, BALLOON_DELTA * sizeof(*mfn_list));

+#ifndef UVM_HOTPLUG
       /*
        * If the list is empty, we are deflating balloon beyond empty. This
        * is currently unsupported as this would require to dynamically add
@@@@ -469,6 +475,7 @@@@
                   tpages, sc->balloon_num_page_entries);
               tpages = sc->balloon_num_page_entries;
       }
+#endif

       /* reclaim pages from balloon */
       set_xen_guest_handle(reservation.extent_start, mfn_list);
@@@@ -491,8 +498,31 @@@@

       /* plug pages back into memory through bpge entries */
       for (rpages = 0; rpages < ret; rpages++) {
-
-#ifdef noyet
+#ifdef UVM_HOTPLUG
+               extern paddr_t pmap_pa_end;
+               if (sc->balloon_num_page_entries == 0) { /*XXX: consolidate */
+                       /* "hot-plug": Stick it at the end of memory */
+                       pa = pmap_pa_end;
+
+                       /* P2M update */
+                       s = splvm();
+                       pmap_pa_end += PAGE_SIZE; /* XXX: TLB flush ?*/
+                       xpmap_ptom_map(pa, ptoa(mfn_list[rpages]));
+                       xpq_queue_machphys_update(ptoa(mfn_list[rpages]), pa);
+                       splx(s);
+
+                       if (uvm_physseg_plug(atop(pa), 1, NULL) == false) {
+                               /* Undo P2M */
+                               s = splvm();
+                               xpmap_ptom_unmap(pa);
+                               xpq_queue_machphys_update(ptoa(mfn_list[rpages]), 0);
+                               pmap_pa_end -= PAGE_SIZE; /* XXX: TLB flush ?*/
+                               splx(s);
+                               break;
+                       }
+                       continue;
+               }
+#else
               if (sc->balloon_num_page_entries == 0) {
                       /*
                        * XXX This is the case where extra "hot-plug"
@@@@ -503,7 +533,6 @@@@
                       break;
               }
#endif
-
               bpg_entry = SLIST_FIRST(&balloon_sc->balloon_page_entries);
               SLIST_REMOVE_HEAD(&balloon_sc->balloon_page_entries, entry);
               balloon_sc->balloon_num_page_entries--;
d2715 1
a2715 1
+++ sys/arch/zaurus/zaurus/machdep.c    22 Dec 2016 09:20:41 -0000
a2724 42
Index: sys/dev/pci/voyagervar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/voyagervar.h,v
retrieving revision 1.4
diff -u -r1.4 voyagervar.h
--- sys/dev/pci/voyagervar.h    7 Dec 2011 09:08:00 -0000       1.4
+++ sys/dev/pci/voyagervar.h    22 Dec 2016 09:22:23 -0000
@@@@ -65,4 +65,4 @@@@
/* frequency in Hz, duty cycle in 1000ths */
uint32_t voyager_set_pwm(int, int);

-#endif
\ No newline at end of file
+#endif
Index: sys/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c
===================================================================
RCS file: /cvsroot/src/sys/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 fixtfdi_test.c
--- sys/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c      4 Jul 2013 22:09:51 -0000       1.1.1.1
+++ sys/external/bsd/compiler_rt/dist/test/Unit/ppc/fixtfdi_test.c      22 Dec 2016 09:23:28 -0000
@@@@ -474,4 +474,4 @@@@
       }

       return 0;
-}
\ No newline at end of file
+}
Index: sys/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c
===================================================================
RCS file: /cvsroot/src/sys/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 fixtfdi_test.c
--- sys/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c     26 Feb 2014 22:31:34 -0000      1.1.1.1
+++ sys/external/bsd/compiler_rt/dist/test/builtins/Unit/ppc/fixtfdi_test.c     22 Dec 2016 09:23:45 -0000
@@@@ -474,4 +474,4 @@@@
       }

       return 0;
-}
\ No newline at end of file
+}
d2731 1
a2731 1
+++ sys/rump/librump/rumpkern/emul.c    22 Dec 2016 09:25:17 -0000
d2747 1
a2747 1
+++ sys/sys/systm.h     22 Dec 2016 09:25:21 -0000
d2763 1
a2763 1
+++ sys/uvm/Makefile    22 Dec 2016 09:25:28 -0000
d2779 1
a2779 1
+++ sys/uvm/files.uvm   22 Dec 2016 09:25:28 -0000
d2802 1
a2802 1
+++ sys/uvm/uvm.h       22 Dec 2016 09:25:28 -0000
d2817 1
a2817 1
+++ sys/uvm/uvm_extern.h        22 Dec 2016 09:25:28 -0000
d2857 1
a2857 1
+++ sys/uvm/uvm_init.c  22 Dec 2016 09:25:28 -0000
d2893 1
a2893 1
+++ sys/uvm/uvm_page.c  22 Dec 2016 09:25:29 -0000
d3471 1
a3471 1
+++ sys/uvm/uvm_page.h  22 Dec 2016 09:25:29 -0000
d3540 1
a3540 1
+++ sys/uvm/uvm_pglist.c        22 Dec 2016 09:25:29 -0000
d3867 1
a3867 1
+++ sys/uvm/pmap/pmap.c 22 Dec 2016 09:25:29 -0000
@


1.1
log
@Initial revision
@
text
@d7 1
a7 1
+++ share/man/man9/Makefile     19 Dec 2016 13:12:06 -0000
d25 1
a25 1
+++ sys/arch/acorn26/acorn26/pmap.c     19 Dec 2016 13:12:06 -0000
d42 1
a42 1
+            uvm_physseg_valid(bank);
d64 3
a66 10
+++ sys/arch/acorn26/acorn26/start.c    19 Dec 2016 13:12:06 -0000
@@@@ -53,6 +53,7 @@@@
#include <dev/cons.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include "arcvideo.h"
#include "ioc.h"
@@@@ -126,6 +127,7 @@@@
d69 2
a70 2
       uvm_setpagesize();
+       uvm_physseg_init();
d80 3
a82 2
+++ sys/arch/acorn32/acorn32/rpc_machdep.c      19 Dec 2016 13:12:06 -0000
@@@@ -925,6 +925,8 @@@@
d85 2
a86 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d97 3
a99 10
+++ sys/arch/acorn32/eb7500atx/eb7500atx_machdep.c      19 Dec 2016 13:12:06 -0000
@@@@ -82,6 +82,7 @@@@
#include <ddb/db_extern.h>

#include <uvm/uvm.h>
+#include <uvm_physseg.h>

#include <arm/locore.h>
#include <arm/undefined.h>
@@@@ -863,6 +864,8 @@@@
d102 2
a103 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d108 16
d130 2
a131 10
+++ sys/arch/alpha/alpha/machdep.c      19 Dec 2016 13:12:06 -0000
@@@@ -104,6 +104,7 @@@@
#include <sys/syscallargs.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>
#include <sys/sysctl.h>

#include <dev/cons.h>
@@@@ -227,7 +228,6 @@@@
d139 2
a140 1
@@@@ -373,7 +373,8 @@@@
d143 1
a143 1
       uvm_setpagesize();
d145 1
a145 1
+       uvm_physseg_init();
d150 1
a150 1
@@@@ -611,23 +612,24 @@@@
d191 1
a191 1
+++ sys/arch/alpha/alpha/pmap.c 19 Dec 2016 13:12:06 -0000
d224 1
a224 1
+            uvm_physseg_valid(bank);
d283 5
a287 5
retrieving revision 1.239
diff -u -r1.239 machdep.c
--- sys/arch/amd64/amd64/machdep.c      16 Dec 2016 20:16:50 -0000      1.239
+++ sys/arch/amd64/amd64/machdep.c      19 Dec 2016 13:12:08 -0000
@@@@ -788,6 +788,7 @@@@
d295 1
a295 1
@@@@ -804,10 +805,25 @@@@
d302 1
a302 1
+            uvm_physseg_valid(upm);
d307 1
a307 1
+               if (uvm_physseg_valid(upm) == false)
d324 1
a324 1
@@@@ -1451,57 +1467,30 @@@@
d401 8
a408 4
@@@@ -1581,7 +1570,8 @@@@
        * Initialize PAGE_SIZE-dependent variables.
        */
       uvm_setpagesize();
d410 1
a410 2
+       uvm_physseg_init();
+
d413 16
a428 1
#ifndef XEN
d435 3
a437 10
+++ sys/arch/amiga/amiga/pmap_bootstrap.c       19 Dec 2016 13:12:09 -0000
@@@@ -73,6 +73,7 @@@@
#include <sys/malloc.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/pte.h>
#include <machine/cpu.h>
@@@@ -126,7 +127,8 @@@@
d440 1
a440 1
       uvm_setpagesize();
d442 1
a442 1
+       uvm_physseg_init();
d447 19
d472 9
a480 13
+++ sys/arch/arc/arc/machdep.c  19 Dec 2016 13:12:11 -0000
@@@@ -63,6 +63,7 @@@@
#include <sys/tty.h>
#include <sys/exec.h>
#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>
#include <sys/mount.h>
#include <sys/device.h>
#include <sys/syscallargs.h>
@@@@ -310,7 +311,8 @@@@
        * Set the VM page size.
        */
       uvm_setpagesize();
d482 1
a482 1
+       uvm_physseg_init();
d493 3
a495 10
+++ sys/arch/arm/arm32/arm32_boot.c     19 Dec 2016 13:12:12 -0000
@@@@ -137,6 +137,7 @@@@
#include <sys/device.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <arm/locore.h>
#include <arm/undefined.h>
@@@@ -232,7 +233,8 @@@@
d498 1
a498 1
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
d500 1
a500 1
+       uvm_physseg_init();
d511 1
a511 1
+++ sys/arch/arm/arm32/bus_dma.c        19 Dec 2016 13:12:12 -0000
d519 1
a519 1
+               KASSERT(uvm_physseg_valid(upm));
d533 1
a533 1
+++ sys/arch/arm/arm32/pmap.c   19 Dec 2016 13:12:14 -0000
d551 3
a553 10
+++ sys/arch/arm/at91/at91bus.c 19 Dec 2016 13:12:14 -0000
@@@@ -58,6 +58,7 @@@@
#include <sys/termios.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -512,6 +513,7 @@@@
d556 2
a557 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d561 14
d581 3
a583 10
+++ sys/arch/atari/atari/pmap_bootstrap.c       19 Dec 2016 13:12:14 -0000
@@@@ -71,6 +71,7 @@@@
#include <sys/malloc.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/pte.h>
#include <machine/cpu.h>
@@@@ -109,7 +110,8 @@@@
d586 1
a586 1
       uvm_setpagesize();
d588 1
a588 1
+       uvm_physseg_init();
d599 1
a599 1
+++ sys/arch/cesfic/cesfic/machdep.c    19 Dec 2016 13:12:15 -0000
d631 3
a633 10
+++ sys/arch/cobalt/cobalt/machdep.c    19 Dec 2016 13:12:15 -0000
@@@@ -70,6 +70,7 @@@@
#include <sys/device.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <machine/bootinfo.h>

@@@@ -253,7 +254,8 @@@@
d636 1
a636 1
       uvm_setpagesize();
d638 1
a638 1
+       uvm_physseg_init();
d649 2
a650 2
+++ sys/arch/dreamcast/dreamcast/machdep.c      19 Dec 2016 13:12:15 -0000
@@@@ -103,6 +103,8 @@@@
a653 1
+#include <uvm/uvm_physseg.h>
d658 1
a658 1
@@@@ -130,6 +132,7 @@@@
d662 1
a662 1
+       uvm_physseg_init();
d672 1
a672 1
+++ sys/arch/emips/emips/machdep.c      19 Dec 2016 13:12:15 -0000
d681 12
d699 3
a701 10
+++ sys/arch/epoc32/epoc32/machdep.c    19 Dec 2016 13:12:15 -0000
@@@@ -49,6 +49,7 @@@@
#include <sys/termios.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/md.h>
@@@@ -441,6 +442,7 @@@@
d704 2
a705 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d715 3
a717 10
+++ sys/arch/evbarm/adi_brh/brh_machdep.c       19 Dec 2016 13:12:15 -0000
@@@@ -92,6 +92,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -758,6 +759,7 @@@@
d720 2
a721 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d731 3
a733 10
+++ sys/arch/evbarm/armadillo/armadillo9_machdep.c      19 Dec 2016 13:12:15 -0000
@@@@ -133,6 +133,7 @@@@
#include <net/if_ether.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -814,6 +815,7 @@@@
d736 2
a737 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d747 3
a749 10
+++ sys/arch/evbarm/g42xxeb/g42xxeb_machdep.c   19 Dec 2016 13:12:15 -0000
@@@@ -128,6 +128,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/conf.h>
#include <dev/cons.h>
@@@@ -829,6 +830,7 @@@@
d752 2
a753 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d763 3
a765 10
+++ sys/arch/evbarm/gemini/gemini_machdep.c     19 Dec 2016 13:12:15 -0000
@@@@ -156,6 +156,7 @@@@
#include <sys/conf.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/md.h>
@@@@ -708,7 +709,8 @@@@
d768 1
a768 1
       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
d770 1
a770 1
+       uvm_physseg_init();
d781 3
a783 10
+++ sys/arch/evbarm/hdl_g/hdlg_machdep.c        19 Dec 2016 13:12:15 -0000
@@@@ -93,6 +93,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -596,6 +597,7 @@@@
d786 2
a787 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d797 2
a798 6
+++ sys/arch/evbarm/imx31/imx31lk_machdep.c     19 Dec 2016 13:12:15 -0000
@@@@ -133,6 +133,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>
a799 3
#include <sys/conf.h>
#include <dev/cons.h>
@@@@ -693,6 +694,7 @@@@
d802 2
a803 2
       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d813 3
a815 10
+++ sys/arch/evbarm/iq80310/iq80310_machdep.c   19 Dec 2016 13:12:15 -0000
@@@@ -92,6 +92,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -718,6 +719,7 @@@@
d818 2
a819 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d829 3
a831 10
+++ sys/arch/evbarm/iq80321/iq80321_machdep.c   19 Dec 2016 13:12:15 -0000
@@@@ -93,6 +93,7 @@@@
#include <sys/bus.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -743,6 +744,7 @@@@
d834 2
a835 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d845 3
a847 10
+++ sys/arch/evbarm/ixdp425/ixdp425_machdep.c   19 Dec 2016 13:12:15 -0000
@@@@ -84,6 +84,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -710,6 +711,7 @@@@
d850 2
a851 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d861 3
a863 10
+++ sys/arch/evbarm/ixm1200/ixm1200_machdep.c   19 Dec 2016 13:12:15 -0000
@@@@ -81,6 +81,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -677,6 +678,7 @@@@
d866 2
a867 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d877 3
a879 2
+++ sys/arch/evbarm/lubbock/lubbock_machdep.c   19 Dec 2016 13:12:16 -0000
@@@@ -900,6 +900,7 @@@@
d882 2
a883 2
       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d893 3
a895 10
+++ sys/arch/evbarm/mini2440/mini2440_machdep.c 19 Dec 2016 13:12:16 -0000
@@@@ -155,6 +155,7 @@@@
#include <net/if_media.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/md.h>
@@@@ -887,6 +888,7 @@@@
d898 2
a899 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d909 3
a911 10
+++ sys/arch/evbarm/npwr_fc/npwr_fc_machdep.c   19 Dec 2016 13:12:16 -0000
@@@@ -91,6 +91,7 @@@@
#include <sys/ksyms.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -713,6 +714,7 @@@@
d914 2
a915 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d925 3
a927 10
+++ sys/arch/evbarm/nslu2/nslu2_machdep.c       19 Dec 2016 13:12:16 -0000
@@@@ -114,6 +114,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -778,6 +779,7 @@@@
d930 2
a931 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d941 3
a943 10
+++ sys/arch/evbarm/osk5912/osk5912_machdep.c   19 Dec 2016 13:12:16 -0000
@@@@ -122,6 +122,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/md.h>
@@@@ -448,6 +449,7 @@@@
d946 2
a947 2
       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d957 3
a959 10
+++ sys/arch/evbarm/smdk2xx0/smdk2410_machdep.c 19 Dec 2016 13:12:16 -0000
@@@@ -127,6 +127,7 @@@@
#include <sys/intr.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/md.h>
@@@@ -845,6 +846,7 @@@@
d962 2
a963 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d973 3
a975 10
+++ sys/arch/evbarm/smdk2xx0/smdk2800_machdep.c 19 Dec 2016 13:12:16 -0000
@@@@ -129,6 +129,7 @@@@
#include <sys/intr.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/md.h>
@@@@ -762,6 +763,7 @@@@
d978 2
a979 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d989 3
a991 10
+++ sys/arch/evbarm/tisdp24xx/sdp24xx_machdep.c 19 Dec 2016 13:12:16 -0000
@@@@ -149,6 +149,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <sys/conf.h>
#include <dev/cons.h>
@@@@ -542,6 +543,7 @@@@
d994 2
a995 2
       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d1005 3
a1007 10
+++ sys/arch/evbarm/tsarm/tsarm_machdep.c       19 Dec 2016 13:12:16 -0000
@@@@ -93,6 +93,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -727,6 +728,7 @@@@
d1010 2
a1011 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d1021 2
a1022 6
+++ sys/arch/evbarm/viper/viper_machdep.c       19 Dec 2016 13:12:16 -0000
@@@@ -135,6 +135,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>
a1023 3
#include <sys/conf.h>
#include <dev/cons.h>
@@@@ -747,6 +748,7 @@@@
d1026 2
a1027 2
       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d1031 250
d1287 1
a1287 1
+++ sys/arch/evbsh3/evbsh3/machdep.c    19 Dec 2016 13:12:16 -0000
d1310 2
a1311 3
+++ sys/arch/ews4800mips/ews4800mips/machdep.c  19 Dec 2016 13:12:16 -0000
@@@@ -44,6 +44,7 @@@@
#include <sys/cpu.h>
a1312 6
#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <machine/bootinfo.h>
#include <machine/locore.h>
@@@@ -111,7 +112,8 @@@@
d1315 1
a1315 1
       uvm_setpagesize();
d1317 1
a1317 1
+       uvm_physseg_init();
d1328 1
a1328 1
+++ sys/arch/hp300/hp300/machdep.c      19 Dec 2016 13:12:16 -0000
d1351 2
a1352 2
+++ sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c 19 Dec 2016 13:12:16 -0000
@@@@ -72,6 +72,7 @@@@
a1354 7
#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <arm/xscale/pxa2x0cpu.h>
#include <arm/xscale/pxa2x0reg.h>
@@@@ -609,6 +610,7 @@@@

d1356 2
a1357 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d1367 2
a1368 2
+++ sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c 19 Dec 2016 13:12:16 -0000
@@@@ -75,6 +75,7 @@@@
a1370 7
#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <arm/arm32/machdep.h>
#include <arm/sa11x0/sa11x0_reg.h>
@@@@ -538,6 +539,7 @@@@

d1372 2
a1373 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d1377 16
d1399 1
a1399 1
+++ sys/arch/hpcsh/hpcsh/machdep.c      19 Dec 2016 13:12:16 -0000
d1422 2
a1423 6
+++ sys/arch/hppa/hppa/pmap.c   19 Dec 2016 13:12:16 -0000
@@@@ -76,6 +76,7 @@@@
#include <sys/mutex.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>
a1424 3
#include <machine/reg.h>
#include <machine/psl.h>
@@@@ -676,7 +677,8 @@@@
d1427 1
a1427 1
       uvm_setpagesize();
d1429 1
a1429 1
+       uvm_physseg_init();
d1434 15
d1452 5
a1456 5
retrieving revision 1.769
diff -u -r1.769 machdep.c
--- sys/arch/i386/i386/machdep.c        17 Dec 2016 14:27:53 -0000      1.769
+++ sys/arch/i386/i386/machdep.c        19 Dec 2016 13:12:16 -0000
@@@@ -1036,57 +1036,30 @@@@
d1533 8
a1540 4
@@@@ -1191,7 +1164,8 @@@@
        * Initialize PAGE_SIZE-dependent variables.
        */
       uvm_setpagesize();
d1542 1
a1542 1
+       uvm_physseg_init();
d1553 2
a1554 10
+++ sys/arch/ia64/ia64/machdep.c        19 Dec 2016 13:12:16 -0000
@@@@ -115,6 +115,7 @@@@
#include <machine/pcb.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
#include <dev/mm.h>
@@@@ -175,18 +176,19 @@@@
d1570 1
a1570 1
+                    uvm_physseg_valid(upm);
d1583 2
a1584 1
@@@@ -466,7 +468,8 @@@@
d1587 1
a1587 1
       uvm_setpagesize();
d1589 1
a1589 2
+       uvm_physseg_init();
+
d1599 1
a1599 1
+++ sys/arch/ia64/ia64/pmap.c   19 Dec 2016 13:12:16 -0000
d1623 1
a1623 1
+            uvm_physseg_valid(upm);
d1683 1
a1683 1
+            uvm_physseg_valid(upm);
d1742 3
a1744 10
+++ sys/arch/iyonix/iyonix/iyonix_machdep.c     19 Dec 2016 13:12:16 -0000
@@@@ -93,6 +93,7 @@@@
#include <sys/cpu.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -781,6 +782,7 @@@@
d1747 2
a1748 2
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d1758 1
a1758 1
+++ sys/arch/landisk/landisk/machdep.c  19 Dec 2016 13:12:16 -0000
d1781 1
a1781 1
+++ sys/arch/luna68k/luna68k/machdep.c  19 Dec 2016 13:12:16 -0000
d1804 1
a1804 1
+++ sys/arch/luna68k/luna68k/pmap_bootstrap.c   19 Dec 2016 13:12:16 -0000
d1821 1
a1821 1
+++ sys/arch/m68k/m68k/pmap_motorola.c  19 Dec 2016 13:12:17 -0000
d1846 9
d1871 1
a1871 1
+            uvm_physseg_valid(bank);
d1885 1
a1885 1
+            uvm_physseg_valid(bank);
d1911 1
a1911 1
+            uvm_physseg_valid(bank);
d1924 1
a1924 1
+++ sys/arch/mac68k/mac68k/machdep.c    19 Dec 2016 13:12:17 -0000
d1947 1
a1947 1
+++ sys/arch/mips/include/pmap.h        19 Dec 2016 13:12:17 -0000
d1966 14
d1986 1
a1986 1
+++ sys/arch/mips/mips/mips_machdep.c   19 Dec 2016 13:12:18 -0000
d2008 1
a2008 1
+       for (; uvm_physseg_valid(bank); bank = uvm_physseg_get_prev(bank)) {
d2053 1
a2053 1
+++ sys/arch/mips/mips/pmap_machdep.c   19 Dec 2016 13:12:19 -0000
d2096 4
a2099 3
+++ sys/arch/mipsco/mipsco/machdep.c    19 Dec 2016 13:12:19 -0000
@@@@ -65,6 +65,7 @@@@
#include <sys/systm.h>
d2101 4
a2104 9
#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <ufs/mfs/mfs_extern.h>                /* mfs_initminiroot() */

@@@@ -215,7 +216,8 @@@@
        * Set the VM page size.
        */
       uvm_setpagesize();
d2106 1
a2106 1
+       uvm_physseg_init();
d2117 1
a2117 1
+++ sys/arch/mmeye/mmeye/machdep.c      19 Dec 2016 13:12:19 -0000
d2140 1
a2140 1
+++ sys/arch/mvme68k/mvme68k/machdep.c  19 Dec 2016 13:12:20 -0000
d2163 2
a2164 10
+++ sys/arch/netwinder/netwinder/netwinder_machdep.c    19 Dec 2016 13:12:22 -0000
@@@@ -69,6 +69,7 @@@@
#include <sys/intr.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -477,7 +478,7 @@@@
d2173 2
a2174 1
@@@@ -739,7 +740,7 @@@@
d2177 1
a2177 1
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
d2179 2
a2180 1
+       uvm_physseg_init();
d2190 1
a2190 1
+++ sys/arch/news68k/news68k/machdep.c  19 Dec 2016 13:12:24 -0000
d2213 4
a2216 3
+++ sys/arch/newsmips/newsmips/machdep.c        19 Dec 2016 13:12:25 -0000
@@@@ -72,6 +72,7 @@@@
#include <sys/intr.h>
d2218 4
a2221 9
#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <ufs/mfs/mfs_extern.h>                /* mfs_initminiroot() */

@@@@ -244,7 +245,8 @@@@
        * Set the VM page size.
        */
       uvm_setpagesize();
d2223 1
a2223 1
+       uvm_physseg_init();
d2234 1
a2234 1
+++ sys/arch/next68k/next68k/machdep.c  19 Dec 2016 13:12:26 -0000
d2257 3
a2259 10
+++ sys/arch/playstation2/playstation2/machdep.c        19 Dec 2016 13:12:26 -0000
@@@@ -44,6 +44,7 @@@@
#include <sys/device.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#ifdef DDB
#include <machine/db_machdep.h>
@@@@ -115,6 +116,8 @@@@
d2262 3
a2264 3
       uvm_setpagesize();
+       uvm_physseg_init();
+
d2268 35
d2309 2
a2310 10
+++ sys/arch/powerpc/ibm4xx/pmap.c      19 Dec 2016 13:12:26 -0000
@@@@ -79,6 +79,7 @@@@
#include <sys/systm.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/powerpc.h>
#include <machine/tlb.h>
@@@@ -199,7 +200,7 @@@@
d2319 1
a2319 1
@@@@ -210,7 +211,7 @@@@
d2328 2
a2329 1
@@@@ -295,7 +296,8 @@@@
d2332 3
a2334 4
       uvm_setpagesize();
-
+       uvm_physseg_init();
+
a2336 1
        */
d2343 1
a2343 1
+++ sys/arch/powerpc/isa/isadma_machdep.c       19 Dec 2016 13:12:26 -0000
d2352 1
a2352 1
+            uvm_physseg_valid(bank);
d2367 1
a2367 1
+            uvm_physseg_valid(bank);
d2374 16
d2396 1
a2396 1
+++ sys/arch/powerpc/oea/pmap.c 19 Dec 2016 13:12:26 -0000
d2429 1
a2429 1
+            uvm_physseg_valid(bank);
d2477 1
a2477 1
+            uvm_physseg_valid(bank);
d2493 1
a2493 1
+                    uvm_physseg_valid(bank);
d2508 16
d2530 1
a2530 1
+++ sys/arch/powerpc/powerpc/bus_dma.c  19 Dec 2016 13:12:26 -0000
d2552 1
a2552 1
+            uvm_physseg_valid(bank);
d2561 65
d2632 1
a2632 1
+++ sys/arch/sh3/sh3/pmap.c     19 Dec 2016 13:12:26 -0000
d2673 1
a2673 1
+            uvm_physseg_valid(bank);
d2694 1
a2694 1
+       KDASSERT(uvm_physseg_valid(bank));
d2702 18
d2726 1
a2726 1
+++ sys/arch/sh3/sh3/vm_machdep.c       19 Dec 2016 13:12:26 -0000
d2750 4
a2753 8
+++ sys/arch/shark/ofw/ofw.c    19 Dec 2016 13:12:26 -0000
@@@@ -53,6 +53,7 @@@@
#include <sys/intr.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>
d2755 3
a2757 1
@@@@ -873,7 +874,8 @@@@
a2758 5
       /* Load memory into UVM. */
       uvm_setpagesize();      /* initialize PAGE_SIZE-dependent variables */
-
+       uvm_physseg_init();
+
a2760 1
               paddr_t start = (paddr_t)bootconfig.dram[i].address;
d2767 3
a2769 3
+++ sys/arch/sparc/sparc/pmap.c 19 Dec 2016 13:12:26 -0000
@@@@ -77,6 +77,7 @@@@
#include <sys/exec_aout.h>             /* for MID_* */
d2771 3
a2773 6
#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/autoconf.h>
#include <machine/bsd_openprom.h>
@@@@ -3036,7 +3037,8 @@@@
a2774 5
       uvmexp.pagesize = NBPG;
       uvm_setpagesize();
-
+       uvm_physseg_init();
+
a2776 1
       nptesg = (NBPSG >> pgshift);
d2783 3
a2785 10
+++ sys/arch/sparc64/sparc64/pmap.c     19 Dec 2016 13:12:26 -0000
@@@@ -52,6 +52,7 @@@@
#include <sys/reboot.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/pcb.h>
#include <machine/sparc64.h>
@@@@ -779,7 +780,8 @@@@
d2788 1
a2788 1
       uvm_setpagesize();
d2790 1
a2790 1
+       uvm_physseg_init();
d2801 3
a2803 3
+++ sys/arch/sun2/sun2/pmap.c   19 Dec 2016 13:12:26 -0000
@@@@ -97,6 +97,7 @@@@
#include <sys/atomic.h>
d2805 3
a2807 2
#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>
a2808 9
#include <machine/cpu.h>
#include <machine/dvma.h>
@@@@ -1701,7 +1702,8 @@@@

       uvmexp.pagesize = NBPG;
       uvm_setpagesize();
-
+       uvm_physseg_init();
+
a2810 1
       pmap_common_init(kernel_pmap);
d2817 3
a2819 3
+++ sys/arch/sun3/sun3/pmap.c   19 Dec 2016 13:12:27 -0000
@@@@ -95,6 +95,7 @@@@
#include <sys/atomic.h>
d2821 3
a2823 6
#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>

#include <machine/cpu.h>
#include <machine/dvma.h>
@@@@ -1731,7 +1732,8 @@@@
a2824 5
       uvmexp.pagesize = PAGE_SIZE;
       uvm_setpagesize();
-
+       uvm_physseg_init();
+
a2826 1
       pmap_common_init(kernel_pmap);
d2833 2
a2834 6
+++ sys/arch/sun3/sun3x/pmap.c  19 Dec 2016 13:12:27 -0000
@@@@ -120,6 +120,7 @@@@
#include <sys/atomic.h>

#include <uvm/uvm.h>
+#include <uvm/uvm_physseg.h>
a2835 3
#include <machine/cpu.h>
#include <machine/kcore.h>
@@@@ -894,7 +895,8 @@@@
d2838 1
a2838 1
       uvm_setpagesize();
d2840 1
a2840 1
+       uvm_physseg_init();
d2845 16
d2867 1
a2867 1
+++ sys/arch/usermode/usermode/pmap.c   19 Dec 2016 13:12:27 -0000
d2891 1
a2891 1
+++ sys/arch/vax/vax/ka650.c    19 Dec 2016 13:12:27 -0000
d2907 1
a2907 1
+++ sys/arch/vax/vax/pmap.c     19 Dec 2016 13:12:27 -0000
d2916 9
d2963 1
a2963 1
+++ sys/arch/x68k/x68k/machdep.c        19 Dec 2016 13:12:27 -0000
d3014 2
a3015 2
+        for (uvm_physseg_get_next(i); uvm_physseg_valid(i); i = uvm_physseg_get_next(i)) {
+               if (uvm_physseg_valid(i) == false)
d3039 2
a3040 2
+       for (i = uvm_physseg_get_first(); uvm_physseg_valid(i); i = uvm_physseg_get_next(i)) {
+               if (uvm_physseg_valid(i) == false)
d3057 1
a3057 1
+++ sys/arch/x68k/x68k/pmap_bootstrap.c 19 Dec 2016 13:12:27 -0000
d3071 4
a3074 4
retrieving revision 1.77
diff -u -r1.77 x86_machdep.c
--- sys/arch/x86/x86/x86_machdep.c      25 Nov 2016 11:57:36 -0000      1.77
+++ sys/arch/x86/x86/x86_machdep.c      19 Dec 2016 13:12:27 -0000
d3089 1
a3089 1
+++ sys/arch/xen/xen/balloon.c  19 Dec 2016 13:12:27 -0000
d3173 3
a3175 10
+++ sys/arch/zaurus/zaurus/machdep.c    19 Dec 2016 13:12:27 -0000
@@@@ -138,6 +138,7 @@@@
#include <sys/bus.h>

#include <uvm/uvm_extern.h>
+#include <uvm/uvm_physseg.h>

#include <dev/cons.h>

@@@@ -1091,6 +1092,7 @@@@
d3178 2
a3179 2
       uvm_setpagesize();        /* initialize PAGE_SIZE-dependent variables */
+       uvm_physseg_init();
d3183 42
d3231 1
a3231 1
+++ sys/rump/librump/rumpkern/emul.c    19 Dec 2016 13:12:28 -0000
d3247 1
a3247 1
+++ sys/sys/systm.h     19 Dec 2016 13:12:28 -0000
d3263 1
a3263 1
+++ sys/uvm/Makefile    19 Dec 2016 13:12:28 -0000
d3279 1
a3279 1
+++ sys/uvm/files.uvm   19 Dec 2016 13:12:28 -0000
d3302 1
a3302 1
+++ sys/uvm/uvm.h       19 Dec 2016 13:12:28 -0000
d3317 25
a3341 2
+++ sys/uvm/uvm_extern.h        19 Dec 2016 13:12:28 -0000
@@@@ -708,9 +708,6 @@@@
d3351 36
d3393 1
a3393 1
+++ sys/uvm/uvm_page.c  19 Dec 2016 13:12:28 -0000
d3479 1
a3479 1
+            uvm_physseg_valid(bank) ;
d3496 1
a3496 1
+            uvm_physseg_valid(bank);
d3537 1
a3537 1
+       for (lcv = uvm_physseg_get_last() ; uvm_physseg_valid(lcv) ; lcv = uvm_physseg_get_prev(lcv))
d3540 1
a3540 1
+               for (lcv = uvm_physseg_get_first() ; uvm_physseg_valid(lcv) ; lcv = uvm_physseg_get_next(lcv))
d3597 1
a3597 1
+               for (lcv = uvm_physseg_get_last() ; uvm_physseg_valid(lcv); lcv = uvm_physseg_get_prev(lcv))
d3600 1
a3600 1
+               for (lcv = uvm_physseg_get_first() ; uvm_physseg_valid(lcv) ; lcv = uvm_physseg_get_next(lcv))
d3955 1
a3955 1
+            uvm_physseg_valid(i);
d3971 1
a3971 1
+++ sys/uvm/uvm_page.h  19 Dec 2016 13:12:28 -0000
d4040 1
a4040 1
+++ sys/uvm/uvm_pglist.c        19 Dec 2016 13:12:28 -0000
d4201 1
a4201 1
+               for (psi = uvm_physseg_get_last(); uvm_physseg_valid(psi); psi = uvm_physseg_get_prev(psi))
d4205 1
a4205 1
+               for (psi = uvm_physseg_get_first(); uvm_physseg_valid(psi); psi = uvm_physseg_get_next(psi))
d4343 1
a4343 1
+               for (psi = uvm_physseg_get_last(); uvm_physseg_valid(psi); psi = uvm_physseg_get_prev(psi))
d4347 1
a4347 1
+               for (psi = uvm_physseg_get_first(); uvm_physseg_valid(psi); psi = uvm_physseg_get_next(psi))
d4367 1
a4367 1
+++ sys/uvm/pmap/pmap.c 19 Dec 2016 13:12:29 -0000
d4393 1
a4393 1
+            uvm_physseg_valid(bank);
d4438 1
a4438 1
+               if (uvm_physseg_valid(maybe_bank) == false
d4448 1
a4448 1
+       if (uvm_physseg_valid(maybe_bank)) {
@