CVS commit: [rmind-uvmplock] src/sys/uvm

2011-06-11 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun Jun 12 02:32:29 UTC 2011

Modified Files:
src/sys/uvm [rmind-uvmplock]: uvm_init.c

Log Message:
Do not call uvm_loan_init() twice.


To generate a diff of this commit:
cvs rdiff -u -r1.36.4.3 -r1.36.4.4 src/sys/uvm/uvm_init.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_init.c
diff -u src/sys/uvm/uvm_init.c:1.36.4.3 src/sys/uvm/uvm_init.c:1.36.4.4
--- src/sys/uvm/uvm_init.c:1.36.4.3	Tue May 31 03:05:14 2011
+++ src/sys/uvm/uvm_init.c	Sun Jun 12 02:32:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_init.c,v 1.36.4.3 2011/05/31 03:05:14 rmind Exp $	*/
+/*	$NetBSD: uvm_init.c,v 1.36.4.4 2011/06/12 02:32:29 rmind Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.36.4.3 2011/05/31 03:05:14 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.36.4.4 2011/06/12 02:32:29 rmind Exp $");
 
 #include 
 #include 
@@ -169,11 +169,6 @@
 	uvm_emap_sysinit();
 
 	/*
-	 * Init the uvm_loan() facility.
-	 */
-	uvm_loan_init();
-
-	/*
 	 * the VM system is now up!  now that kmem is up we can resize the
 	 *  =>  hash table for general use and enable paging
 	 * of kernel objects.



CVS commit: [rmind-uvmplock] src/sys/uvm

2011-05-21 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 21 21:26:48 UTC 2011

Modified Files:
src/sys/uvm [rmind-uvmplock]: uvm_fault.c

Log Message:
uvm_fault_lower_promote: fix assert (move a bit up, where logic applies).


To generate a diff of this commit:
cvs rdiff -u -r1.173.2.7 -r1.173.2.8 src/sys/uvm/uvm_fault.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_fault.c
diff -u src/sys/uvm/uvm_fault.c:1.173.2.7 src/sys/uvm/uvm_fault.c:1.173.2.8
--- src/sys/uvm/uvm_fault.c:1.173.2.7	Thu May 19 03:43:05 2011
+++ src/sys/uvm/uvm_fault.c	Sat May 21 21:26:48 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_fault.c,v 1.173.2.7 2011/05/19 03:43:05 rmind Exp $	*/
+/*	$NetBSD: uvm_fault.c,v 1.173.2.8 2011/05/21 21:26:48 rmind Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.173.2.7 2011/05/19 03:43:05 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.173.2.8 2011/05/21 21:26:48 rmind Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -2039,14 +2039,12 @@
 	int error;
 	UVMHIST_FUNC("uvm_fault_lower_promote"); UVMHIST_CALLED(maphist);
 
+	KASSERT(amap != NULL);
+
 	/*
-	 * if we are going to promote the data to an anon we
+	 * If we are going to promote the data to an anon we
 	 * allocate a blank anon here and plug it into our amap.
 	 */
-#if DIAGNOSTIC
-	if (amap == NULL)
-		panic("uvm_fault: want to promote data, but no anon");
-#endif
 	error = uvmfault_promote(ufi, NULL, uobjpage,
 	&anon, &flt->anon_spare);
 	switch (error) {
@@ -2061,8 +2059,9 @@
 	pg = anon->an_page;
 
 	/*
-	 * fill in the data
+	 * Fill in the data.
 	 */
+	KASSERT(uobj == NULL || (uobjpage->flags & PG_BUSY) != 0);
 
 	if (uobjpage != PGO_DONTCARE) {
 		uvmexp.flt_prcopy++;
@@ -2107,7 +2106,6 @@
 		anon, pg, 0, 0);
 	}
 
-	KASSERT(uobj == NULL || (uobjpage->flags & PG_BUSY) != 0);
 	return uvm_fault_lower_enter(ufi, flt, uobj, anon, pg);
 }
 



CVS commit: [rmind-uvmplock] src/sys/uvm

2010-07-01 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Fri Jul  2 02:09:55 UTC 2010

Modified Files:
src/sys/uvm [rmind-uvmplock]: uvm_km.c

Log Message:
Undo 1.105.2.2 revision, note that uvm_km_pgremove_intrsafe() extracts the
mapping, improve comments.


To generate a diff of this commit:
cvs rdiff -u -r1.105.2.3 -r1.105.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.105.2.3 src/sys/uvm/uvm_km.c:1.105.2.4
--- src/sys/uvm/uvm_km.c:1.105.2.3	Sun May 30 05:18:10 2010
+++ src/sys/uvm/uvm_km.c	Fri Jul  2 02:09:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.105.2.3 2010/05/30 05:18:10 rmind Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.105.2.4 2010/07/02 02:09:54 rmind Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -127,7 +127,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.105.2.3 2010/05/30 05:18:10 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.105.2.4 2010/07/02 02:09:54 rmind Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -657,20 +657,24 @@
 
 	if (flags & UVM_KMF_PAGEABLE) {
 		/*
-		 * no need to lock for pmap, as the kernel is
-		 * self-consistent.  the pages cannot be in
-		 * use elsewhere.
+		 * No need to lock for pmap, since the kernel is always
+		 * self-consistent.  The pages cannot be in use elsewhere.
 		 */
-
-		pmap_remove(pmap_kernel(), addr, addr + size);
 		uvm_km_pgremove(addr, addr + size);
+		pmap_remove(pmap_kernel(), addr, addr + size);
+
 	} else if (flags & UVM_KMF_WIRED) {
-		pmap_kremove(addr, size);
+		/*
+		 * Note: uvm_km_pgremove_intrsafe() extracts mapping, thus
+		 * remove it after.  See comment below about KVA visibility.
+		 */
 		uvm_km_pgremove_intrsafe(map, addr, addr + size);
+		pmap_kremove(addr, size);
 	}
 
 	/*
-	 * uvm_unmap_remove calls pmap_update for us.
+	 * Note: uvm_unmap_remove() calls pmap_update() for us, before
+	 * KVA becomes globally available.
 	 */
 
 	uvm_unmap1(map, addr, addr + size, UVM_FLAG_QUANTUM|UVM_FLAG_VAONLY);



CVS commit: [rmind-uvmplock] src/sys/uvm

2010-04-25 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Mon Apr 26 02:20:59 UTC 2010

Modified Files:
src/sys/uvm [rmind-uvmplock]: uvm_bio.c uvm_extern.h uvm_object.c
uvm_object.h

Log Message:
Add ubc_purge() and purge/deassociate any related UBC entries during
object (usually, vnode) destruction.  Since locking (and thus object)
is required to enter/remove mappings - object is not allowed anymore
to disappear with any UBC entries left.

>From original patch by ad@ with some modifications.


To generate a diff of this commit:
cvs rdiff -u -r1.68.4.3 -r1.68.4.4 src/sys/uvm/uvm_bio.c
cvs rdiff -u -r1.162.2.3 -r1.162.2.4 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.7.4.3 -r1.7.4.4 src/sys/uvm/uvm_object.c
cvs rdiff -u -r1.26.20.1 -r1.26.20.2 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_bio.c
diff -u src/sys/uvm/uvm_bio.c:1.68.4.3 src/sys/uvm/uvm_bio.c:1.68.4.4
--- src/sys/uvm/uvm_bio.c:1.68.4.3	Sun Apr 25 22:48:26 2010
+++ src/sys/uvm/uvm_bio.c	Mon Apr 26 02:20:59 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_bio.c,v 1.68.4.3 2010/04/25 22:48:26 rmind Exp $	*/
+/*	$NetBSD: uvm_bio.c,v 1.68.4.4 2010/04/26 02:20:59 rmind Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.68.4.3 2010/04/25 22:48:26 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.68.4.4 2010/04/26 02:20:59 rmind Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -79,8 +79,7 @@
 #define UMAP_PAGES_LOCKED	0x0001
 #define UMAP_MAPPING_CACHED	0x0002
 
-struct ubc_map
-{
+struct ubc_map {
 	struct uvm_object *	uobj;		/* mapped object */
 	voff_t			offset;		/* offset into uobj */
 	voff_t			writeoff;	/* write offset */
@@ -91,10 +90,10 @@
 
 	LIST_ENTRY(ubc_map)	hash;		/* hash table */
 	TAILQ_ENTRY(ubc_map)	inactive;	/* inactive queue */
+	LIST_ENTRY(ubc_map)	list;		/* per-object list */
 };
 
-static struct ubc_object
-{
+static struct ubc_object {
 	struct uvm_object uobj;		/* glue for uvm_map() */
 	char *kva;			/* where ubc_object is mapped */
 	struct ubc_map *umap;		/* array of ubc_map's */
@@ -104,7 +103,6 @@
 
 	TAILQ_HEAD(ubc_inactive_head, ubc_map) *inactive;
 	/* inactive queues for ubc_map's */
-
 } ubc_object;
 
 const struct uvm_pagerops ubc_pager = {
@@ -449,8 +447,8 @@
 
 	/*
 	 * The object is already referenced, so we do not need to add a ref.
+	 * Lock order: UBC object -> ubc_map::uobj.
 	 */
-
 	mutex_enter(ubc_object.uobj.vmobjlock);
 again:
 	umap = ubc_find_mapping(uobj, umap_offset);
@@ -474,6 +472,7 @@
 
 		if (oobj != NULL) {
 			LIST_REMOVE(umap, hash);
+			LIST_REMOVE(umap, list);
 			if (umap->flags & UMAP_MAPPING_CACHED) {
 umap->flags &= ~UMAP_MAPPING_CACHED;
 mutex_enter(oobj->vmobjlock);
@@ -489,6 +488,7 @@
 		umap->offset = umap_offset;
 		LIST_INSERT_HEAD(&ubc_object.hash[UBC_HASH(uobj, umap_offset)],
 		umap, hash);
+		LIST_INSERT_HEAD(&uobj->uo_ubc, umap, list);
 	} else {
 		UBC_EVCNT_INCR(wincachehit);
 		va = UBC_UMAP_ADDR(umap);
@@ -709,7 +709,6 @@
 	return error;
 }
 
-
 /*
  * uvm_vnp_zerorange:  set a range of bytes in a file to zero.
  */
@@ -737,3 +736,30 @@
 		len -= bytelen;
 	}
 }
+
+/*
+ * ubc_purge: disassociate ubc_map structures from an empty uvm_object.
+ */
+
+void
+ubc_purge(struct uvm_object *uobj)
+{
+	struct ubc_map *umap;
+	vaddr_t va;
+
+	KASSERT(uobj->uo_npages == 0);
+
+	mutex_enter(ubc_object.uobj.vmobjlock);
+	while ((umap = LIST_FIRST(&uobj->uo_ubc)) != NULL) {
+		KASSERT(umap->refcount == 0);
+		for (va = 0; va < ubc_winsize; va += PAGE_SIZE) {
+			KASSERT(!pmap_extract(pmap_kernel(),
+			va + UBC_UMAP_ADDR(umap), NULL));
+		}
+		LIST_REMOVE(umap, list);
+		LIST_REMOVE(umap, hash);
+		umap->flags &= ~UMAP_MAPPING_CACHED;
+		umap->uobj = NULL;
+	}
+	mutex_exit(ubc_object.uobj.vmobjlock);
+}

Index: src/sys/uvm/uvm_extern.h
diff -u src/sys/uvm/uvm_extern.h:1.162.2.3 src/sys/uvm/uvm_extern.h:1.162.2.4
--- src/sys/uvm/uvm_extern.h:1.162.2.3	Fri Apr 23 21:18:00 2010
+++ src/sys/uvm/uvm_extern.h	Mon Apr 26 02:20:59 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_extern.h,v 1.162.2.3 2010/04/23 21:18:00 rmind Exp $	*/
+/*	$NetBSD: uvm_extern.h,v 1.162.2.4 2010/04/26 02:20:59 rmind Exp $	*/
 
 /*
  *
@@ -579,6 +579,7 @@
 void			ubc_release(void *, int);
 int			ubc_uiomove(struct uvm_object *, struct uio *, vsize_t,
 			int, int);
+void			ubc_purge(struct uvm_object *);
 
 /* uvm_emap.c */
 void			uvm_emap_sysinit(void);

Index: src/sys/uvm/uvm_object.c
diff -u src/sys/uvm/uvm_object.c:1.7.4.3 src/sys/uvm/uvm_object.c:1.7.4.4
--- src/sys/uvm/uvm_object.c:1.7.4.3	Sat Apr 24 21:24:03 2010
+++ src/sys/uvm/uvm_object.c	Mon Apr 26 02:20:59 2010
@@ -1,7 +1,7 @@
-/*	$NetBSD: uvm_object.c,v 1.7.4.3 2010/04/24 21:24:03 rmind Exp $	*/
+/*	$NetBSD: uvm_object.c,v 1.7.4.4 2010/04/26 02:20:59 rmind Exp $	*/
 
 /*
- * Copyright (c) 2006 The NetBSD Fo

CVS commit: [rmind-uvmplock] src/sys/uvm

2010-04-25 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun Apr 25 22:48:27 UTC 2010

Modified Files:
src/sys/uvm [rmind-uvmplock]: uvm_bio.c

Log Message:
ubc_alloc: when replacing a cache entry, lock the old object from which we
are deassociating and removing the old mapping.


To generate a diff of this commit:
cvs rdiff -u -r1.68.4.2 -r1.68.4.3 src/sys/uvm/uvm_bio.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_bio.c
diff -u src/sys/uvm/uvm_bio.c:1.68.4.2 src/sys/uvm/uvm_bio.c:1.68.4.3
--- src/sys/uvm/uvm_bio.c:1.68.4.2	Wed Mar 17 06:03:17 2010
+++ src/sys/uvm/uvm_bio.c	Sun Apr 25 22:48:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_bio.c,v 1.68.4.2 2010/03/17 06:03:17 rmind Exp $	*/
+/*	$NetBSD: uvm_bio.c,v 1.68.4.3 2010/04/25 22:48:26 rmind Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.68.4.2 2010/03/17 06:03:17 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.68.4.3 2010/04/25 22:48:26 rmind Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -448,13 +448,15 @@
 	*lenp = MIN(*lenp, ubc_winsize - slot_offset);
 
 	/*
-	 * the object is always locked here, so we don't need to add a ref.
+	 * The object is already referenced, so we do not need to add a ref.
 	 */
 
 	mutex_enter(ubc_object.uobj.vmobjlock);
 again:
 	umap = ubc_find_mapping(uobj, umap_offset);
 	if (umap == NULL) {
+		struct uvm_object *oobj;
+
 		UBC_EVCNT_INCR(wincachemiss);
 		umap = TAILQ_FIRST(UBC_QUEUE(offset));
 		if (umap == NULL) {
@@ -463,23 +465,30 @@
 			goto again;
 		}
 
+		va = UBC_UMAP_ADDR(umap);
+		oobj = umap->uobj;
+
 		/*
 		 * remove from old hash (if any), add to new hash.
 		 */
 
-		if (umap->uobj != NULL) {
+		if (oobj != NULL) {
 			LIST_REMOVE(umap, hash);
+			if (umap->flags & UMAP_MAPPING_CACHED) {
+umap->flags &= ~UMAP_MAPPING_CACHED;
+mutex_enter(oobj->vmobjlock);
+pmap_remove(pmap_kernel(), va,
+va + ubc_winsize);
+mutex_exit(oobj->vmobjlock);
+pmap_update(pmap_kernel());
+			}
+		} else {
+			KASSERT((umap->flags & UMAP_MAPPING_CACHED) == 0);
 		}
 		umap->uobj = uobj;
 		umap->offset = umap_offset;
 		LIST_INSERT_HEAD(&ubc_object.hash[UBC_HASH(uobj, umap_offset)],
 		umap, hash);
-		va = UBC_UMAP_ADDR(umap);
-		if (umap->flags & UMAP_MAPPING_CACHED) {
-			umap->flags &= ~UMAP_MAPPING_CACHED;
-			pmap_remove(pmap_kernel(), va, va + ubc_winsize);
-			pmap_update(pmap_kernel());
-		}
 	} else {
 		UBC_EVCNT_INCR(wincachehit);
 		va = UBC_UMAP_ADDR(umap);



CVS commit: [rmind-uvmplock] src/sys/uvm

2010-04-24 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Apr 24 21:24:03 UTC 2010

Modified Files:
src/sys/uvm [rmind-uvmplock]: uvm_object.c

Log Message:
Amend previous.


To generate a diff of this commit:
cvs rdiff -u -r1.7.4.2 -r1.7.4.3 src/sys/uvm/uvm_object.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_object.c
diff -u src/sys/uvm/uvm_object.c:1.7.4.2 src/sys/uvm/uvm_object.c:1.7.4.3
--- src/sys/uvm/uvm_object.c:1.7.4.2	Fri Apr 23 21:18:00 2010
+++ src/sys/uvm/uvm_object.c	Sat Apr 24 21:24:03 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_object.c,v 1.7.4.2 2010/04/23 21:18:00 rmind Exp $	*/
+/*	$NetBSD: uvm_object.c,v 1.7.4.3 2010/04/24 21:24:03 rmind Exp $	*/
 
 /*
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_object.c,v 1.7.4.2 2010/04/23 21:18:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_object.c,v 1.7.4.3 2010/04/24 21:24:03 rmind Exp $");
 
 #include "opt_ddb.h"
 
@@ -169,7 +169,7 @@
 
 error:
 	/* Unwire the pages which has been wired */
-	uobj_unwirepages(uobj, start, offset);
+	uvm_obj_unwirepages(uobj, start, offset);
 
 	return error;
 }