Module Name:    src
Committed By:   riz
Date:           Fri Sep  7 22:17:35 UTC 2012

Modified Files:
        src/sys/uvm [netbsd-6]: uvm_km.c uvm_map.c

Log Message:
Pull up following revision(s) (requested by para in ticket #547):
        sys/uvm/uvm_map.c: revision 1.320
        sys/uvm/uvm_map.c: revision 1.321
        sys/uvm/uvm_map.c: revision 1.322
        sys/uvm/uvm_km.c: revision 1.130
        sys/uvm/uvm_km.c: revision 1.131
        sys/uvm/uvm_km.c: revision 1.132
        sys/uvm/uvm_km.c: revision 1.133
        sys/uvm/uvm_km.c: revision 1.134
        sys/uvm/uvm_km.c: revision 1.135
        sys/uvm/uvm_km.c: revision 1.129
Fix a bug where the kernel was never grown to accomodate the kmem VA space
since that happens before the kernel_map is set.
Don't try grow the entire kmem space but just do as needed in
uvm_km_kmem_alloc
Shut up gcc printf warning.
Cleanup comment.  Change panic to KASSERTMSG.
Use kernel_map->misc_lock to make sure we don't call pmap_growkernel
concurrently and possibly mess up uvm_maxkaddr.
Switch to a spin lock (uvm_kentry_lock) which, fortunately, was
sitting there
unused.
Remove locking since it isn't needed.  As soon as the 2nd
uvm_map_entry in kernel_map
is created, uvm_map_prepare will call pmap_growkernel and the
pmap_growkernel call in
uvm_km_mem_alloc will never be called again.
call pmap_growkernel once after the kmem_arena is created
to make the pmap cover it's address space
assert on the growth in uvm_km_kmem_alloc
for the 3rd uvm_map_entry uvm_map_prepare will grow the kernel,
but we might call into uvm_km_kmem_alloc through imports to
the kmem_meta_arena earlier
while here guard uvm_km_va_starved_p from kmem_arena not yet created
thanks for tracking this down to everyone involved


To generate a diff of this commit:
cvs rdiff -u -r1.120.2.2 -r1.120.2.3 src/sys/uvm/uvm_km.c
cvs rdiff -u -r1.313.2.3 -r1.313.2.4 src/sys/uvm/uvm_map.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/uvm_km.c
diff -u src/sys/uvm/uvm_km.c:1.120.2.2 src/sys/uvm/uvm_km.c:1.120.2.3
--- src/sys/uvm/uvm_km.c:1.120.2.2	Sat Mar 17 17:29:34 2012
+++ src/sys/uvm/uvm_km.c	Fri Sep  7 22:17:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.120.2.2 2012/03/17 17:29:34 bouyer Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.120.2.3 2012/09/07 22:17:34 riz Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -120,7 +120,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.120.2.2 2012/03/17 17:29:34 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.120.2.3 2012/09/07 22:17:34 riz Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -170,7 +170,7 @@ int nkmempages = 0;
 vaddr_t kmembase;
 vsize_t kmemsize;
 
-vmem_t *kmem_arena;
+vmem_t *kmem_arena = NULL;
 vmem_t *kmem_va_arena;
 
 /*
@@ -297,6 +297,18 @@ uvm_km_bootstrap(vaddr_t start, vaddr_t 
 	kmem_arena = vmem_create("kmem", kmembase, kmemsize, PAGE_SIZE,
 	    NULL, NULL, NULL,
 	    0, VM_NOSLEEP | VM_BOOTSTRAP, IPL_VM);
+#ifdef PMAP_GROWKERNEL
+	/*
+	 * kmem_arena VA allocations happen independently of uvm_map.
+	 * grow kernel to accommodate the kmem_arena.
+	 */
+	if (uvm_maxkaddr < kmembase + kmemsize) {
+		uvm_maxkaddr = pmap_growkernel(kmembase + kmemsize);
+		KASSERTMSG(uvm_maxkaddr >= kmembase + kmemsize,
+		    "%#"PRIxVADDR" %#"PRIxVADDR" %#"PRIxVSIZE,
+		    uvm_maxkaddr, kmembase, kmemsize);
+	}
+#endif
 
 	vmem_init(kmem_arena);
 
@@ -747,6 +759,16 @@ again:
 	if (rc != 0)
 		return rc;
 
+#ifdef PMAP_GROWKERNEL
+	/*
+	 * These VA allocations happen independently of uvm_map 
+	 * so this allocation must not extend beyond the current limit.
+	 */
+	KASSERTMSG(uvm_maxkaddr >= va + size,
+	    "%#"PRIxVADDR" %#"PRIxPTR" %#zx",
+	    uvm_maxkaddr, va, size);
+#endif
+
 	loopva = va;
 	loopsize = size;
 
@@ -811,6 +833,9 @@ uvm_km_va_starved_p(void)
 	vmem_size_t total;
 	vmem_size_t free;
 
+	if (kmem_arena == NULL)
+		return false;
+
 	total = vmem_size(kmem_arena, VMEM_ALLOC|VMEM_FREE);
 	free = vmem_size(kmem_arena, VMEM_FREE);
 

Index: src/sys/uvm/uvm_map.c
diff -u src/sys/uvm/uvm_map.c:1.313.2.3 src/sys/uvm/uvm_map.c:1.313.2.4
--- src/sys/uvm/uvm_map.c:1.313.2.3	Sat Aug 18 22:03:24 2012
+++ src/sys/uvm/uvm_map.c	Fri Sep  7 22:17:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.313.2.3 2012/08/18 22:03:24 riz Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.313.2.4 2012/09/07 22:17:34 riz Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.313.2.3 2012/08/18 22:03:24 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.313.2.4 2012/09/07 22:17:34 riz Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"

Reply via email to