Source-Changes-HG archive

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

[src/trunk]: src/sys Make a slight modification of pmap_growkernel() -- it no...



details:   https://anonhg.NetBSD.org/src/rev/e607dddbd9e2
branches:  trunk
changeset: 473121:e607dddbd9e2
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu May 20 23:03:23 1999 +0000

description:
Make a slight modification of pmap_growkernel() -- it now returns the
end of the mappable kernel virtual address space.  Previously, it would
get called more often than necessary, because the caller only new what
was requested.

Also, export uvm_maxkaddr so that uvm_pageboot_alloc() can grow the
kernel pmap if necessary, as well.  Note that pmap_growkernel() must
now be able to handle being called before pmap_init().

diffstat:

 sys/arch/i386/i386/pmap.new.c   |  24 +++++++++++++++++++++---
 sys/arch/pc532/pc532/pmap.new.c |  24 +++++++++++++++++++++---
 sys/uvm/uvm_map.c               |  27 +++++++++++++++++----------
 sys/uvm/uvm_map.h               |  10 +++++++++-
 sys/uvm/uvm_page.c              |  18 +++++++++++++++---
 5 files changed, 83 insertions(+), 20 deletions(-)

diffs (228 lines):

diff -r 5b1d0deca33c -r e607dddbd9e2 sys/arch/i386/i386/pmap.new.c
--- a/sys/arch/i386/i386/pmap.new.c     Thu May 20 23:00:58 1999 +0000
+++ b/sys/arch/i386/i386/pmap.new.c     Thu May 20 23:03:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.new.c,v 1.26 1999/05/12 19:28:29 thorpej Exp $    */
+/*     $NetBSD: pmap.new.c,v 1.27 1999/05/20 23:03:23 thorpej Exp $    */
 
 /*
  *
@@ -3630,7 +3630,7 @@
  *     the pmaps on the system.
  */
 
-void pmap_growkernel(maxkvaddr)
+vaddr_t pmap_growkernel(maxkvaddr)
 
 vaddr_t maxkvaddr;
 
@@ -3641,7 +3641,7 @@
 
   needed_kpde = (int)(maxkvaddr - VM_MIN_KERNEL_ADDRESS + (NBPD-1)) / NBPD;
   if (needed_kpde <= nkpde)
-    return;            /* we are OK */
+    goto out;          /* we are OK */
 
   /*
    * whoops!   we need to add kernel PTPs
@@ -3652,6 +3652,21 @@
 
   for (/*null*/ ; nkpde < needed_kpde ; nkpde++) {
 
+    if (pmap_initialized == FALSE) {
+      /*
+       * we're growing the kernel pmap early (from uvm_pageboot_alloc()).
+       * this case must be handled a little differently.
+       */
+      paddr_t ptaddr;
+
+      if (uvm_page_physget(&ptaddr) == FALSE)
+       panic("pmap_growkernel: out of memory");
+
+      kpm->pm_pdir[PDSLOT_KERN + nkpde] = ptaddr | PG_RW | PG_V;
+      kpm->pm_stats.resident_count++;  /* count PTP as resident */
+      continue;
+    }
+
     pmap_alloc_ptp(kpm, PDSLOT_KERN + nkpde, FALSE);
     kpm->pm_pdir[PDSLOT_KERN + nkpde] &= ~PG_u; /* PG_u not for kernel */
 
@@ -3665,6 +3680,9 @@
 
   simple_unlock(&kpm->pm_obj.vmobjlock);
   splx(s);
+
+ out:
+  return (VM_MIN_KERNEL_ADDRESS + (nkpde * NBPD));
 }
 
 #ifdef DEBUG
diff -r 5b1d0deca33c -r e607dddbd9e2 sys/arch/pc532/pc532/pmap.new.c
--- a/sys/arch/pc532/pc532/pmap.new.c   Thu May 20 23:00:58 1999 +0000
+++ b/sys/arch/pc532/pc532/pmap.new.c   Thu May 20 23:03:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.new.c,v 1.12 1999/04/17 20:03:39 chs Exp $        */
+/*     $NetBSD: pmap.new.c,v 1.13 1999/05/20 23:03:23 thorpej Exp $    */
 
 /*
  *
@@ -3368,7 +3368,7 @@
  *     the pmaps on the system.
  */
 
-void pmap_growkernel(maxkvaddr)
+vaddr_t pmap_growkernel(maxkvaddr)
 
 vaddr_t maxkvaddr;
 
@@ -3379,7 +3379,7 @@
 
   needed_kpde = (int)(maxkvaddr - VM_MIN_KERNEL_ADDRESS + (NBPD-1)) / NBPD;
   if (needed_kpde <= nkpde)
-    return;            /* we are OK */
+    goto out;          /* we are OK */
 
   /*
    * whoops!   we need to add kernel PTPs
@@ -3390,6 +3390,21 @@
 
   for (/*null*/ ; nkpde < needed_kpde ; nkpde++) {
 
+    if (pmap_initialized == FALSE) {
+      /*
+       * we're growing the kernel pmap early (from uvm_pageboot_alloc()).
+       * this case must be handled a little differently.
+       */
+      paddr_t ptaddr;
+
+      if (uvm_page_physget(&ptaddr) == FALSE)
+       panic("pmap_growkernel: out of memory");
+
+      kpm->pm_pdir[PDSLOT_KERN + nkpde] = ptaddr | PG_RW | PG_V;
+      kpm->pm_stats.resident_count++;  /* count PTP as resident */
+      continue;
+    }
+
     pmap_alloc_ptp(kpm, PDSLOT_KERN + nkpde, FALSE);
     kpm->pm_pdir[PDSLOT_KERN + nkpde] &= ~PG_u; /* PG_u not for kernel */
 
@@ -3403,6 +3418,9 @@
 
   simple_unlock(&kpm->pm_obj.vmobjlock);
   splx(s);
+
+ out:
+  return (VM_MIN_KERNEL_ADDRESS + (nkpde * NBPD));
 }
 
 #ifdef DEBUG
diff -r 5b1d0deca33c -r e607dddbd9e2 sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Thu May 20 23:00:58 1999 +0000
+++ b/sys/uvm/uvm_map.c Thu May 20 23:03:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.c,v 1.39 1999/05/12 19:11:23 thorpej Exp $     */
+/*     $NetBSD: uvm_map.c,v 1.40 1999/05/20 23:03:23 thorpej Exp $     */
 
 /* 
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -113,6 +113,17 @@
 
 struct pool uvm_map_entry_pool;
 
+#ifdef PMAP_GROWKERNEL
+/*
+ * This global represents the end of the kernel virtual address
+ * space.  If we want to exceed this, we must grow the kernel
+ * virtual address space dynamically.
+ *
+ * Note, this variable is locked by kernel_map's lock.
+ */
+vaddr_t uvm_maxkaddr;
+#endif
+
 /*
  * macros
  */
@@ -503,18 +514,14 @@
                return (KERN_NO_SPACE);
        }
 
-#if defined(PMAP_GROWKERNEL)   /* hack */
+#ifdef PMAP_GROWKERNEL
        {
-               /* locked by kernel_map lock */
-               static vaddr_t maxkaddr = 0;
-               
                /*
-                * hack: grow kernel PTPs in advance.
+                * If the kernel pmap can't map the requested space,
+                * then allocate more resources for it.
                 */
-               if (map == kernel_map && maxkaddr < (*startp + size)) {
-                       pmap_growkernel(*startp + size);
-                       maxkaddr = *startp + size;
-               }
+               if (map == kernel_map && uvm_maxkaddr < (*startp + size))
+                       uvm_maxkaddr = pmap_growkernel(*startp + size);
        }
 #endif
 
diff -r 5b1d0deca33c -r e607dddbd9e2 sys/uvm/uvm_map.h
--- a/sys/uvm/uvm_map.h Thu May 20 23:00:58 1999 +0000
+++ b/sys/uvm/uvm_map.h Thu May 20 23:03:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.h,v 1.11 1999/03/25 18:48:52 mrg Exp $ */
+/*     $NetBSD: uvm_map.h,v 1.12 1999/05/20 23:03:23 thorpej Exp $     */
 
 /* 
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -117,6 +117,14 @@
 #endif /* UVM_MAP_INLINE */
 
 /*
+ * globals:
+ */
+
+#ifdef PMAP_GROWKERNEL
+extern vaddr_t uvm_maxkaddr;
+#endif
+
+/*
  * protos: the following prototypes define the interface to vm_map
  */
 
diff -r 5b1d0deca33c -r e607dddbd9e2 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Thu May 20 23:00:58 1999 +0000
+++ b/sys/uvm/uvm_page.c        Thu May 20 23:03:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.19 1999/05/20 20:07:55 thorpej Exp $    */
+/*     $NetBSD: uvm_page.c,v 1.20 1999/05/20 23:03:23 thorpej Exp $    */
 
 /* 
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -409,11 +409,23 @@
         * allocate virtual memory for this request
         */
        if (virtual_space_start == virtual_space_end ||
-           (virtual_space_end - virtual_space_start) < size) {
+           (virtual_space_end - virtual_space_start) < size)
                panic("uvm_pageboot_alloc: out of virtual space");
-       }
 
        addr = virtual_space_start;
+
+#ifdef PMAP_GROWKERNEL
+       /*
+        * If the kernel pmap can't map the requested space,
+        * then allocate more resources for it.
+        */
+       if (uvm_maxkaddr < (addr + size)) {
+               uvm_maxkaddr = pmap_growkernel(addr + size);
+               if (uvm_maxkaddr < (addr + size))
+                       panic("uvm_pageboot_alloc: pmap_growkernel() failed");
+       }
+#endif
+
        virtual_space_start += size;
 
        /*



Home | Main Index | Thread Index | Old Index