Module Name:    src
Committed By:   hannken
Date:           Thu Jul 29 10:54:51 UTC 2010

Modified Files:
        src/sys/arch/sparc64/sparc64: pmap.c
        src/sys/kern: vfs_subr.c
        src/sys/miscfs/genfs: genfs_io.c
        src/sys/rump/librump/rumpkern: vm.c
        src/sys/ufs/lfs: lfs_vnops.c
        src/sys/uvm: uvm_aobj.c uvm_page.h

Log Message:
Add vm page flag PG_MARKER and use it to tag dummy marker pages
in genfs_do_putpages() and uao_put().
Use 'v_uobj.uo_npages' to check for an empty memq.
Put some assertions where these marker pages may not appear.

Ok: YAMAMOTO Takashi <[email protected]>


To generate a diff of this commit:
cvs rdiff -u -r1.264 -r1.265 src/sys/arch/sparc64/sparc64/pmap.c
cvs rdiff -u -r1.413 -r1.414 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.36 -r1.37 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.84 -r1.85 src/sys/rump/librump/rumpkern/vm.c
cvs rdiff -u -r1.229 -r1.230 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.109 -r1.110 src/sys/uvm/uvm_aobj.c
cvs rdiff -u -r1.59 -r1.60 src/sys/uvm/uvm_page.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/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.264 src/sys/arch/sparc64/sparc64/pmap.c:1.265
--- src/sys/arch/sparc64/sparc64/pmap.c:1.264	Tue May 18 04:30:16 2010
+++ src/sys/arch/sparc64/sparc64/pmap.c	Thu Jul 29 10:54:50 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.264 2010/05/18 04:30:16 mrg Exp $	*/
+/*	$NetBSD: pmap.c,v 1.265 2010/07/29 10:54:50 hannken Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.264 2010/05/18 04:30:16 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.265 2010/07/29 10:54:50 hannken Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -1444,6 +1444,7 @@
 
 	/* we could be a little smarter and leave pages zeroed */
 	for (pg = TAILQ_FIRST(&pm->pm_obj.memq); pg != NULL; pg = nextpg) {
+		KASSERT((pg->flags & PG_MARKER) == 0);
 		nextpg = TAILQ_NEXT(pg, listq.queue);
 		TAILQ_REMOVE(&pm->pm_obj.memq, pg, listq.queue);
 		KASSERT(pg->mdpage.mdpg_pvh.pv_pmap == NULL);

Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.413 src/sys/kern/vfs_subr.c:1.414
--- src/sys/kern/vfs_subr.c:1.413	Wed Jul 28 11:03:47 2010
+++ src/sys/kern/vfs_subr.c	Thu Jul 29 10:54:50 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.413 2010/07/28 11:03:47 hannken Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.414 2010/07/29 10:54:50 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.413 2010/07/28 11:03:47 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.414 2010/07/29 10:54:50 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -1136,7 +1136,7 @@
 	if (LIST_NEXT(bp, b_vnbufs) != NOLIST)
 		bufremvn(bp);
 
-	if (TAILQ_EMPTY(&vp->v_uobj.memq) && (vp->v_iflag & VI_ONWORKLST) &&
+	if (vp->v_uobj.uo_npages == 0 && (vp->v_iflag & VI_ONWORKLST) &&
 	    LIST_FIRST(&vp->v_dirtyblkhd) == NULL) {
 		vp->v_iflag &= ~VI_WRMAPDIRTY;
 		vn_syncer_remove_from_worklist(vp);
@@ -1176,7 +1176,7 @@
 	 */
 	if ((bp->b_oflags & BO_DELWRI) == 0) {
 		listheadp = &vp->v_cleanblkhd;
-		if (TAILQ_EMPTY(&vp->v_uobj.memq) &&
+		if (vp->v_uobj.uo_npages == 0 &&
 		    (vp->v_iflag & VI_ONWORKLST) &&
 		    LIST_FIRST(&vp->v_dirtyblkhd) == NULL) {
 			vp->v_iflag &= ~VI_WRMAPDIRTY;

Index: src/sys/miscfs/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.36 src/sys/miscfs/genfs/genfs_io.c:1.37
--- src/sys/miscfs/genfs/genfs_io.c:1.36	Sat Jan 30 12:06:20 2010
+++ src/sys/miscfs/genfs/genfs_io.c	Thu Jul 29 10:54:50 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.36 2010/01/30 12:06:20 uebayasi Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.37 2010/07/29 10:54:50 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36 2010/01/30 12:06:20 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.37 2010/07/29 10:54:50 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -891,12 +891,8 @@
 	dirtygen = gp->g_dirtygen;
 	freeflag = pagedaemon ? PG_PAGEOUT : PG_RELEASED;
 	if (by_list) {
-		curmp.uobject = uobj;
-		curmp.offset = (voff_t)-1;
-		curmp.flags = PG_BUSY;
-		endmp.uobject = uobj;
-		endmp.offset = (voff_t)-1;
-		endmp.flags = PG_BUSY;
+		curmp.flags = PG_MARKER;
+		endmp.flags = PG_MARKER;
 		pg = TAILQ_FIRST(&uobj->memq);
 		TAILQ_INSERT_TAIL(&uobj->memq, &endmp, listq.queue);
 	} else {
@@ -909,14 +905,19 @@
 		 * if the current page is not interesting, move on to the next.
 		 */
 
-		KASSERT(pg == NULL || pg->uobject == uobj);
+		KASSERT(pg == NULL || pg->uobject == uobj ||
+		    (pg->flags & PG_MARKER) != 0);
 		KASSERT(pg == NULL ||
 		    (pg->flags & (PG_RELEASED|PG_PAGEOUT)) == 0 ||
-		    (pg->flags & PG_BUSY) != 0);
+		    (pg->flags & (PG_BUSY|PG_MARKER)) != 0);
 		if (by_list) {
 			if (pg == &endmp) {
 				break;
 			}
+			if (pg->flags & PG_MARKER) {
+				pg = TAILQ_NEXT(pg, listq.queue);
+				continue;
+			}
 			if (pg->offset < startoff || pg->offset >= endoff ||
 			    pg->flags & (PG_RELEASED|PG_PAGEOUT)) {
 				if (pg->flags & (PG_RELEASED|PG_PAGEOUT)) {
@@ -1186,6 +1187,9 @@
 	    (vp->v_iflag & VI_ONWORKLST) != 0) {
 #if defined(DEBUG)
 		TAILQ_FOREACH(pg, &uobj->memq, listq.queue) {
+			if ((pg->flags & PG_MARKER) != 0) {
+				continue;
+			}
 			if ((pg->flags & PG_CLEAN) == 0) {
 				printf("%s: %p: !CLEAN\n", __func__, pg);
 			}

Index: src/sys/rump/librump/rumpkern/vm.c
diff -u src/sys/rump/librump/rumpkern/vm.c:1.84 src/sys/rump/librump/rumpkern/vm.c:1.85
--- src/sys/rump/librump/rumpkern/vm.c:1.84	Mon Jun 14 21:04:56 2010
+++ src/sys/rump/librump/rumpkern/vm.c	Thu Jul 29 10:54:50 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm.c,v 1.84 2010/06/14 21:04:56 pooka Exp $	*/
+/*	$NetBSD: vm.c,v 1.85 2010/07/29 10:54:50 hannken Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.84 2010/06/14 21:04:56 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.85 2010/07/29 10:54:50 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -459,6 +459,7 @@
 	struct vm_page *pg;
 
 	TAILQ_FOREACH(pg, &uobj->memq, listq.queue) {
+		KASSERT((pg->flags & PG_MARKER) == 0);
 		if (pg->offset == off) {
 			return pg;
 		}

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.229 src/sys/ufs/lfs/lfs_vnops.c:1.230
--- src/sys/ufs/lfs/lfs_vnops.c:1.229	Thu Jun 24 13:03:19 2010
+++ src/sys/ufs/lfs/lfs_vnops.c	Thu Jul 29 10:54:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.229 2010/06/24 13:03:19 hannken Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.230 2010/07/29 10:54:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.229 2010/06/24 13:03:19 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.230 2010/07/29 10:54:51 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1848,12 +1848,16 @@
 			 * blocks outside our area of interest or beyond
 			 * the end of file.
 			 */
+			KASSERT((curpg->flags & PG_MARKER) == 0);
 			if (pages_per_block > 1) {
 				while (curpg &&
-				       ((curpg->offset & fs->lfs_bmask) ||
-					curpg->offset >= vp->v_size ||
-					curpg->offset >= endoffset))
+				    ((curpg->offset & fs->lfs_bmask) ||
+				    curpg->offset >= vp->v_size ||
+				    curpg->offset >= endoffset)) {
 					curpg = TAILQ_NEXT(curpg, listq.queue);
+					KASSERT(curpg == NULL ||
+					    (curpg->flags & PG_MARKER) == 0);
+				}
 			}
 			if (curpg == NULL)
 				break;

Index: src/sys/uvm/uvm_aobj.c
diff -u src/sys/uvm/uvm_aobj.c:1.109 src/sys/uvm/uvm_aobj.c:1.110
--- src/sys/uvm/uvm_aobj.c:1.109	Fri May 28 23:41:14 2010
+++ src/sys/uvm/uvm_aobj.c	Thu Jul 29 10:54:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_aobj.c,v 1.109 2010/05/28 23:41:14 rmind Exp $	*/
+/*	$NetBSD: uvm_aobj.c,v 1.110 2010/07/29 10:54:51 hannken Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.109 2010/05/28 23:41:14 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.110 2010/07/29 10:54:51 hannken Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -789,12 +789,8 @@
 	 * genfs_putpages() also.
 	 */
 
-	curmp.uobject = uobj;
-	curmp.offset = (voff_t)-1;
-	curmp.flags = PG_BUSY;
-	endmp.uobject = uobj;
-	endmp.offset = (voff_t)-1;
-	endmp.flags = PG_BUSY;
+	curmp.flags = PG_MARKER;
+	endmp.flags = PG_MARKER;
 
 	/*
 	 * now do it.  note: we must update nextpg in the body of loop or we
@@ -817,6 +813,8 @@
 			if (pg == &endmp)
 				break;
 			nextpg = TAILQ_NEXT(pg, listq.queue);
+			if (pg->flags & PG_MARKER)
+				continue;
 			if (pg->offset < start || pg->offset >= stop)
 				continue;
 		} else {

Index: src/sys/uvm/uvm_page.h
diff -u src/sys/uvm/uvm_page.h:1.59 src/sys/uvm/uvm_page.h:1.60
--- src/sys/uvm/uvm_page.h:1.59	Sat Feb  6 12:10:59 2010
+++ src/sys/uvm/uvm_page.h	Thu Jul 29 10:54:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.h,v 1.59 2010/02/06 12:10:59 uebayasi Exp $	*/
+/*	$NetBSD: uvm_page.h,v 1.60 2010/07/29 10:54:51 hannken Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -180,12 +180,13 @@
 #define	PG_FAKE		0x0040		/* page is not yet initialized */
 #define	PG_RDONLY	0x0080		/* page must be mapped read-only */
 #define	PG_ZERO		0x0100		/* page is pre-zero'd */
+#define	PG_MARKER	0x0200		/* dummy marker page */
 
 #define PG_PAGER1	0x1000		/* pager-specific flag */
 
 #define	UVM_PGFLAGBITS \
 	"\20\1BUSY\2WANTED\3TABLED\4CLEAN\5PAGEOUT\6RELEASED\7FAKE\10RDONLY" \
-	"\11ZERO\15PAGER1"
+	"\11ZERO\12MARKER\15PAGER1"
 
 #define PQ_FREE		0x0001		/* page is on free list */
 #define PQ_ANON		0x0002		/* page is part of an anon, rather

Reply via email to