CVS commit: [netbsd-6] src/sys/uvm

2014-10-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 27 05:42:43 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1133):
sys/uvm/uvm_swap.c: revision 1.163
Set bp-b_resid to bp-b_bcount on error in swstrategy as required.


To generate a diff of this commit:
cvs rdiff -u -r1.161.2.1 -r1.161.2.2 src/sys/uvm/uvm_swap.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_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.161.2.1 src/sys/uvm/uvm_swap.c:1.161.2.2
--- src/sys/uvm/uvm_swap.c:1.161.2.1	Tue Mar 18 08:09:46 2014
+++ src/sys/uvm/uvm_swap.c	Mon Oct 27 05:42:43 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.c,v 1.161.2.1 2014/03/18 08:09:46 msaitoh Exp $	*/
+/*	$NetBSD: uvm_swap.c,v 1.161.2.2 2014/10/27 05:42:43 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uvm_swap.c,v 1.161.2.1 2014/03/18 08:09:46 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_swap.c,v 1.161.2.2 2014/10/27 05:42:43 msaitoh Exp $);
 
 #include opt_uvmhist.h
 #include opt_compat_netbsd.h
@@ -1134,6 +1134,7 @@ swstrategy(struct buf *bp)
 	mutex_exit(uvm_swap_data_lock);
 	if (sdp == NULL) {
 		bp-b_error = EINVAL;
+		bp-b_resid = bp-b_bcount;
 		biodone(bp);
 		UVMHIST_LOG(pdhist,   failed to get swap device, 0, 0, 0, 0);
 		return;



CVS commit: [netbsd-6] src/sys/uvm

2013-11-25 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Nov 25 08:29:58 UTC 2013

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

Log Message:
Pull up following revision(s) (requested by para in ticket #989):
sys/uvm/uvm_km.c: revision 1.125
uvm_km_kmem_alloc: don't hardcode kmem_va_arena


To generate a diff of this commit:
cvs rdiff -u -r1.120.2.3 -r1.120.2.4 src/sys/uvm/uvm_km.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.3 src/sys/uvm/uvm_km.c:1.120.2.4
--- src/sys/uvm/uvm_km.c:1.120.2.3	Fri Sep  7 22:17:34 2012
+++ src/sys/uvm/uvm_km.c	Mon Nov 25 08:29:58 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.120.2.3 2012/09/07 22:17:34 riz Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.120.2.4 2013/11/25 08:29:58 bouyer 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.3 2012/09/07 22:17:34 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_km.c,v 1.120.2.4 2013/11/25 08:29:58 bouyer Exp $);
 
 #include opt_uvmhist.h
 
@@ -787,7 +787,7 @@ again:
 			} else {
 uvm_km_pgremove_intrsafe(kernel_map, va,
 va + size);
-vmem_free(kmem_va_arena, va, size);
+vmem_free(vm, va, size);
 return ENOMEM;
 			}
 		}



CVS commit: [netbsd-6] src/sys/uvm

2012-11-22 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Nov 22 20:25:21 UTC 2012

Modified Files:
src/sys/uvm [netbsd-6]: uvm_aobj.c uvm_aobj.h uvm_object.h

Log Message:
Pull up following revision(s) (requested by rmind in ticket #694):
sys/uvm/uvm_aobj.h: revision 1.22
sys/uvm/uvm_aobj.c: revision 1.117
sys/uvm/uvm_aobj.c: revision 1.118
sys/uvm/uvm_aobj.c: revision 1.119
sys/uvm/uvm_object.h: revision 1.33
- Describe uvm_aobj and the lock order.
- Remove unnecessary uao_dropswap_range1() wrapper.
- KNF.  Sprinkle some __cacheline_aligned.
- Manage anonymous UVM object reference count with atomic ops.
- Fix an old bug of possible lock against oneself (uao_detach_locked() is
  called from uao_swap_off() with uao_list_lock acquired).  Also removes
  the try-lock dance in uao_swap_off(), since the lock order changes.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.116.8.1 src/sys/uvm/uvm_aobj.c
cvs rdiff -u -r1.21 -r1.21.10.1 src/sys/uvm/uvm_aobj.h
cvs rdiff -u -r1.32 -r1.32.2.1 src/sys/uvm/uvm_object.h

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_aobj.c
diff -u src/sys/uvm/uvm_aobj.c:1.116 src/sys/uvm/uvm_aobj.c:1.116.8.1
--- src/sys/uvm/uvm_aobj.c:1.116	Tue Sep  6 16:41:55 2011
+++ src/sys/uvm/uvm_aobj.c	Thu Nov 22 20:25:21 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_aobj.c,v 1.116 2011/09/06 16:41:55 matt Exp $	*/
+/*	$NetBSD: uvm_aobj.c,v 1.116.8.1 2012/11/22 20:25:21 riz Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -38,80 +38,69 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uvm_aobj.c,v 1.116 2011/09/06 16:41:55 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_aobj.c,v 1.116.8.1 2012/11/22 20:25:21 riz Exp $);
 
 #include opt_uvmhist.h
 
 #include sys/param.h
 #include sys/systm.h
-#include sys/proc.h
 #include sys/kernel.h
 #include sys/kmem.h
 #include sys/pool.h
+#include sys/atomic.h
 
 #include uvm/uvm.h
 
 /*
- * an aobj manages anonymous-memory backed uvm_objects.   in addition
- * to keeping the list of resident pages, it also keeps a list of
- * allocated swap blocks.  depending on the size of the aobj this list
- * of allocated swap blocks is either stored in an array (small objects)
- * or in a hash table (large objects).
- */
-
-/*
- * local structures
+ * An anonymous UVM object (aobj) manages anonymous-memory.  In addition to
+ * keeping the list of resident pages, it may also keep a list of allocated
+ * swap blocks.  Depending on the size of the object, this list is either
+ * stored in an array (small objects) or in a hash table (large objects).
+ *
+ * Lock order
+ *
+ *	uao_list_lock -
+ *		uvm_object::vmobjlock
  */
 
 /*
- * for hash tables, we break the address space of the aobj into blocks
- * of UAO_SWHASH_CLUSTER_SIZE pages.   we require the cluster size to
- * be a power of two.
+ * Note: for hash tables, we break the address space of the aobj into blocks
+ * of UAO_SWHASH_CLUSTER_SIZE pages, which shall be a power of two.
  */
 
-#define UAO_SWHASH_CLUSTER_SHIFT 4
-#define UAO_SWHASH_CLUSTER_SIZE (1  UAO_SWHASH_CLUSTER_SHIFT)
+#define	UAO_SWHASH_CLUSTER_SHIFT	4
+#define	UAO_SWHASH_CLUSTER_SIZE		(1  UAO_SWHASH_CLUSTER_SHIFT)
 
-/* get the tag for this page index */
-#define UAO_SWHASH_ELT_TAG(PAGEIDX) \
-	((PAGEIDX)  UAO_SWHASH_CLUSTER_SHIFT)
+/* Get the tag for this page index. */
+#define	UAO_SWHASH_ELT_TAG(idx)		((idx)  UAO_SWHASH_CLUSTER_SHIFT)
+#define UAO_SWHASH_ELT_PAGESLOT_IDX(idx) \
+((idx)  (UAO_SWHASH_CLUSTER_SIZE - 1))
 
-#define UAO_SWHASH_ELT_PAGESLOT_IDX(PAGEIDX) \
-	((PAGEIDX)  (UAO_SWHASH_CLUSTER_SIZE - 1))
+/* Given an ELT and a page index, find the swap slot. */
+#define	UAO_SWHASH_ELT_PAGESLOT(elt, idx) \
+((elt)-slots[UAO_SWHASH_ELT_PAGESLOT_IDX(idx)])
 
-/* given an ELT and a page index, find the swap slot */
-#define UAO_SWHASH_ELT_PAGESLOT(ELT, PAGEIDX) \
-	((ELT)-slots[UAO_SWHASH_ELT_PAGESLOT_IDX(PAGEIDX)])
-
-/* given an ELT, return its pageidx base */
-#define UAO_SWHASH_ELT_PAGEIDX_BASE(ELT) \
-	((ELT)-tag  UAO_SWHASH_CLUSTER_SHIFT)
-
-/*
- * the swhash hash function
- */
+/* Given an ELT, return its pageidx base. */
+#define	UAO_SWHASH_ELT_PAGEIDX_BASE(ELT) \
+((elt)-tag  UAO_SWHASH_CLUSTER_SHIFT)
 
-#define UAO_SWHASH_HASH(AOBJ, PAGEIDX) \
-	((AOBJ)-u_swhash[(((PAGEIDX)  UAO_SWHASH_CLUSTER_SHIFT) \
-			 (AOBJ)-u_swhashmask)])
+/* The hash function. */
+#define	UAO_SWHASH_HASH(aobj, idx) \
+((aobj)-u_swhash[(((idx)  UAO_SWHASH_CLUSTER_SHIFT) \
+ (aobj)-u_swhashmask)])
 
 /*
- * the swhash threshhold determines if we will use an array or a
+ * The threshold which determines whether we will use an array or a
  * hash table to store the list of allocated swap blocks.
  */
-
-#define UAO_SWHASH_THRESHOLD (UAO_SWHASH_CLUSTER_SIZE * 4)
-#define UAO_USES_SWHASH(AOBJ) \
-	((AOBJ)-u_pages  UAO_SWHASH_THRESHOLD)	/* use hash? 

CVS commit: [netbsd-6] src/sys/uvm

2012-09-07 Thread Jeff Rizzo
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



CVS commit: [netbsd-6] src/sys/uvm

2012-08-18 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Aug 18 22:03:24 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by chs in ticket #508):
sys/uvm/uvm_map.c: revision 1.319
avoid leaking a uvm_object reference when merging a new map entry
with the entries on both sides.  fixes PR 46807.


To generate a diff of this commit:
cvs rdiff -u -r1.313.2.2 -r1.313.2.3 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_map.c
diff -u src/sys/uvm/uvm_map.c:1.313.2.2 src/sys/uvm/uvm_map.c:1.313.2.3
--- src/sys/uvm/uvm_map.c:1.313.2.2	Thu Apr 12 17:05:37 2012
+++ src/sys/uvm/uvm_map.c	Sat Aug 18 22:03:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.313.2.2 2012/04/12 17:05:37 riz Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.313.2.3 2012/08/18 22:03:24 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.2 2012/04/12 17:05:37 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_map.c,v 1.313.2.3 2012/08/18 22:03:24 riz Exp $);
 
 #include opt_ddb.h
 #include opt_uvmhist.h
@@ -1466,9 +1466,8 @@ forwardmerge:
 		/*
 		 * drop our reference to uobj since we are extending a reference
 		 * that we already have (the ref count can not drop to zero).
-		 * (if merged, we've already detached)
 		 */
-		if (uobj  uobj-pgops-pgo_detach  !merged)
+		if (uobj  uobj-pgops-pgo_detach)
 			uobj-pgops-pgo_detach(uobj);
 
 		if (merged) {



CVS commit: [netbsd-6] src/sys/uvm

2012-04-09 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Apr  9 17:58:11 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by chs in ticket #167):
sys/uvm/uvm_glue.c: revision 1.158
fix uarea_system_poolpage_free() to handle freeing a uarea
that was not allocated by cpu_uarea_alloc() (ie. on plaforms
where cpu_uarea_alloc() failing is not fatal).
fixes PR 46284.


To generate a diff of this commit:
cvs rdiff -u -r1.156.2.1 -r1.156.2.2 src/sys/uvm/uvm_glue.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_glue.c
diff -u src/sys/uvm/uvm_glue.c:1.156.2.1 src/sys/uvm/uvm_glue.c:1.156.2.2
--- src/sys/uvm/uvm_glue.c:1.156.2.1	Mon Feb 20 21:54:57 2012
+++ src/sys/uvm/uvm_glue.c	Mon Apr  9 17:58:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_glue.c,v 1.156.2.1 2012/02/20 21:54:57 sborrill Exp $	*/
+/*	$NetBSD: uvm_glue.c,v 1.156.2.2 2012/04/09 17:58:11 riz Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -62,7 +62,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uvm_glue.c,v 1.156.2.1 2012/02/20 21:54:57 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_glue.c,v 1.156.2.2 2012/04/09 17:58:11 riz Exp $);
 
 #include opt_kgdb.h
 #include opt_kstack.h
@@ -315,8 +315,11 @@ uarea_system_poolpage_alloc(struct pool 
 static void
 uarea_system_poolpage_free(struct pool *pp, void *addr)
 {
-	if (!cpu_uarea_free(addr))
-		panic(%s: failed to free uarea %p, __func__, addr);
+	if (cpu_uarea_free(addr))
+		return;
+
+	uvm_km_free(kernel_map, (vaddr_t)addr, pp-pr_alloc-pa_pagesz,
+	UVM_KMF_WIRED);
 }
 
 static struct pool_allocator uvm_uarea_system_allocator = {



CVS commit: [netbsd-6] src/sys/uvm

2012-04-09 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Apr  9 18:13:11 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by chs in ticket #173):
sys/uvm/uvm_amap.c: revision 1.107
initialize amap per-page reference counts before changing the amap's
overall reference count.  this fixes the crashes seen for the last 9 months
with web browers and plugins, which was also the cause of PR 46193.


To generate a diff of this commit:
cvs rdiff -u -r1.105.2.1 -r1.105.2.2 src/sys/uvm/uvm_amap.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_amap.c
diff -u src/sys/uvm/uvm_amap.c:1.105.2.1 src/sys/uvm/uvm_amap.c:1.105.2.2
--- src/sys/uvm/uvm_amap.c:1.105.2.1	Tue Apr  3 15:40:36 2012
+++ src/sys/uvm/uvm_amap.c	Mon Apr  9 18:13:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_amap.c,v 1.105.2.1 2012/04/03 15:40:36 riz Exp $	*/
+/*	$NetBSD: uvm_amap.c,v 1.105.2.2 2012/04/09 18:13:11 riz Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uvm_amap.c,v 1.105.2.1 2012/04/03 15:40:36 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_amap.c,v 1.105.2.2 2012/04/09 18:13:11 riz Exp $);
 
 #include opt_uvmhist.h
 
@@ -888,6 +888,7 @@ amap_copy(struct vm_map *map, struct vm_
 			continue;
 		KASSERT(amap-am_anon[lcv]-an_lock == srcamap-am_lock);
 		KASSERT(amap-am_anon[lcv]-an_ref  0);
+		KASSERT(amap-am_nused  amap-am_maxslot);
 		amap-am_anon[lcv]-an_ref++;
 		amap-am_bckptr[lcv] = amap-am_nused;
 		amap-am_slots[amap-am_nused] = lcv;
@@ -1193,6 +1194,7 @@ amap_pp_adjref(struct vm_amap *amap, int
 		}
 		ref += adjval;
 		KASSERT(ref = 0);
+		KASSERT(ref = amap-am_ref);
 		if (lcv == prevlcv + prevlen  ref == prevref) {
 			pp_setreflen(ppref, prevlcv, ref, prevlen + len);
 		} else {
@@ -1490,6 +1492,7 @@ amap_add(struct vm_aref *aref, vaddr_t o
 		}
 	} else {
 		KASSERT(amap-am_anon[slot] == NULL);
+		KASSERT(amap-am_nused  amap-am_maxslot);
 		amap-am_bckptr[slot] = amap-am_nused;
 		amap-am_slots[amap-am_nused] = slot;
 		amap-am_nused++;
@@ -1534,7 +1537,7 @@ amap_unadd(struct vm_aref *aref, vaddr_t
 }
 
 /*
- * amap_adjref_anons: adjust the reference count(s) on anons of the amap.
+ * amap_adjref_anons: adjust the reference count(s) on amap and its anons.
  */
 static void
 amap_adjref_anons(struct vm_amap *amap, vaddr_t offset, vsize_t len,
@@ -1545,9 +1548,19 @@ amap_adjref_anons(struct vm_amap *amap, 
 #ifdef UVM_AMAP_PPREF
 	KASSERT(mutex_owned(amap-am_lock));
 
+	/*
+	 * We must establish the ppref array before changing am_ref
+	 * so that the ppref values match the current amap refcount.
+	 */
+
 	if (amap-am_ppref == NULL  !all  len != amap-am_nslot) {
 		amap_pp_establish(amap, offset);
 	}
+#endif
+
+	amap-am_ref += refv;
+
+#ifdef UVM_AMAP_PPREF
 	if (amap-am_ppref  amap-am_ppref != PPREF_NONE) {
 		if (all) {
 			amap_pp_adjref(amap, 0, amap-am_nslot, refv, tofree);
@@ -1575,7 +1588,6 @@ amap_ref(struct vm_amap *amap, vaddr_t o
 	if (flags  AMAP_SHARED) {
 		amap-am_flags |= AMAP_SHARED;
 	}
-	amap-am_ref++;
 	amap_adjref_anons(amap, offset, len, 1, (flags  AMAP_REFALL) != 0);
 
 	UVMHIST_LOG(maphist,- done!  amap=0x%x, amap, 0, 0, 0);
@@ -1599,10 +1611,12 @@ amap_unref(struct vm_amap *amap, vaddr_t
 	amap, amap-am_ref, amap-am_nused, 0);
 	KASSERT(amap-am_ref  0);
 
-	if (--amap-am_ref == 0) {
+	if (amap-am_ref == 1) {
+
 		/*
 		 * If the last reference - wipeout and destroy the amap.
 		 */
+		amap-am_ref--;
 		amap_wipeout(amap);
 		UVMHIST_LOG(maphist,- done (was last ref)!, 0, 0, 0, 0);
 		return;
@@ -1612,7 +1626,7 @@ amap_unref(struct vm_amap *amap, vaddr_t
 	 * Otherwise, drop the reference count(s) on anons.
 	 */
 
-	if (amap-am_ref == 1  (amap-am_flags  AMAP_SHARED) != 0) {
+	if (amap-am_ref == 2  (amap-am_flags  AMAP_SHARED) != 0) {
 		amap-am_flags = ~AMAP_SHARED;
 	}
 	amap_adjref_anons(amap, offset, len, -1, all);



CVS commit: [netbsd-6] src/sys/uvm

2012-04-03 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Apr  3 15:40:36 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by chs in ticket #150):
sys/uvm/uvm_amap.c: revision 1.106
adjust amap_cow_now() to make UVM_PAGE_TRKOWN happy.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.105.2.1 src/sys/uvm/uvm_amap.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_amap.c
diff -u src/sys/uvm/uvm_amap.c:1.105 src/sys/uvm/uvm_amap.c:1.105.2.1
--- src/sys/uvm/uvm_amap.c:1.105	Fri Jan 27 19:48:41 2012
+++ src/sys/uvm/uvm_amap.c	Tue Apr  3 15:40:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_amap.c,v 1.105 2012/01/27 19:48:41 para Exp $	*/
+/*	$NetBSD: uvm_amap.c,v 1.105.2.1 2012/04/03 15:40:36 riz Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uvm_amap.c,v 1.105 2012/01/27 19:48:41 para Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_amap.c,v 1.105.2.1 2012/04/03 15:40:36 riz Exp $);
 
 #include opt_uvmhist.h
 
@@ -1035,6 +1035,7 @@ ReStart:
 
 		nanon = uvm_analloc();
 		if (nanon) {
+			nanon-an_lock = amap-am_lock;
 			npg = uvm_pagealloc(NULL, 0, nanon, 0);
 		} else {
 			npg = NULL;
@@ -1042,6 +1043,7 @@ ReStart:
 		if (nanon == NULL || npg == NULL) {
 			amap_unlock(amap);
 			if (nanon) {
+nanon-an_lock = NULL;
 nanon-an_ref--;
 KASSERT(nanon-an_ref == 0);
 uvm_anon_free(nanon);
@@ -1055,7 +1057,6 @@ ReStart:
 		 * Also, setup its lock (share the with amap's lock).
 		 */
 
-		nanon-an_lock = amap-am_lock;
 		uvm_pagecopy(pg, npg);
 		anon-an_ref--;
 		KASSERT(anon-an_ref  0);



CVS commit: [netbsd-6] src/sys/uvm

2012-03-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Mar 17 17:29:34 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by rmind in ticket #113):
sys/uvm/uvm_km.c: revision 1.123
uvm_km_kmem_alloc: return ENOMEM on failure in PMAP_MAP_POOLPAGE case.


To generate a diff of this commit:
cvs rdiff -u -r1.120.2.1 -r1.120.2.2 src/sys/uvm/uvm_km.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.1 src/sys/uvm/uvm_km.c:1.120.2.2
--- src/sys/uvm/uvm_km.c:1.120.2.1	Wed Feb 22 18:56:48 2012
+++ src/sys/uvm/uvm_km.c	Sat Mar 17 17:29:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.120.2.1 2012/02/22 18:56:48 riz Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.120.2.2 2012/03/17 17:29:34 bouyer 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.1 2012/02/22 18:56:48 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: uvm_km.c,v 1.120.2.2 2012/03/17 17:29:34 bouyer Exp $);
 
 #include opt_uvmhist.h
 
@@ -731,6 +731,7 @@ again:
 uvm_wait(plpg);
 goto again;
 			}
+			return ENOMEM;
 		}
 		va = PMAP_MAP_POOLPAGE(VM_PAGE_TO_PHYS(pg));
 		if (__predict_false(va == 0)) {
@@ -768,7 +769,7 @@ again:
 return ENOMEM;
 			}
 		}
-	
+
 		pg-flags = ~PG_BUSY;	/* new page */
 		UVM_PAGE_OWN(pg, NULL);
 		pmap_kenter_pa(loopva, VM_PAGE_TO_PHYS(pg),
@@ -815,4 +816,3 @@ uvm_km_va_starved_p(void)
 
 	return (free  (total / 10));
 }
-