Module Name:    src
Committed By:   yamt
Date:           Sun Nov 13 01:18:03 UTC 2011

Modified Files:
        src/sys/uvm [yamt-pagecache]: uvm_aobj.c uvm_page.c uvm_page.h
            uvm_page_status.c

Log Message:
cache UVM_OBJ_IS_VNODE in pqflags


To generate a diff of this commit:
cvs rdiff -u -r1.116.2.3 -r1.116.2.4 src/sys/uvm/uvm_aobj.c
cvs rdiff -u -r1.178.2.4 -r1.178.2.5 src/sys/uvm/uvm_page.c
cvs rdiff -u -r1.73.2.3 -r1.73.2.4 src/sys/uvm/uvm_page.h
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/uvm/uvm_page_status.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_aobj.c
diff -u src/sys/uvm/uvm_aobj.c:1.116.2.3 src/sys/uvm/uvm_aobj.c:1.116.2.4
--- src/sys/uvm/uvm_aobj.c:1.116.2.3	Sun Nov  6 22:05:00 2011
+++ src/sys/uvm/uvm_aobj.c	Sun Nov 13 01:18:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_aobj.c,v 1.116.2.3 2011/11/06 22:05:00 yamt Exp $	*/
+/*	$NetBSD: uvm_aobj.c,v 1.116.2.4 2011/11/13 01:18:02 yamt Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.116.2.3 2011/11/06 22:05:00 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.116.2.4 2011/11/13 01:18:02 yamt Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -909,7 +909,6 @@ uao_get(struct uvm_object *uobj, voff_t 
 				    NULL, UVM_FLAG_COLORMATCH|UVM_PGA_ZERO);
 				if (ptmp) {
 					/* new page */
-					ptmp->pqflags |= PQ_AOBJ;
 					ptmp->flags &= ~PG_FAKE;
 					uvm_pagemarkdirty(ptmp,
 					    UVM_PAGE_STATUS_UNKNOWN);
@@ -1018,13 +1017,6 @@ gotpage:
 				}
 
 				/*
-				 * safe with PQ's unlocked: because we just
-				 * alloc'd the page
-				 */
-
-				ptmp->pqflags |= PQ_AOBJ;
-
-				/*
 				 * got new page ready for I/O.  break pps while
 				 * loop.  pps[lcv] is still NULL.
 				 */

Index: src/sys/uvm/uvm_page.c
diff -u src/sys/uvm/uvm_page.c:1.178.2.4 src/sys/uvm/uvm_page.c:1.178.2.5
--- src/sys/uvm/uvm_page.c:1.178.2.4	Sat Nov 12 02:54:04 2011
+++ src/sys/uvm/uvm_page.c	Sun Nov 13 01:18:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.c,v 1.178.2.4 2011/11/12 02:54:04 yamt Exp $	*/
+/*	$NetBSD: uvm_page.c,v 1.178.2.5 2011/11/13 01:18:02 yamt Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.178.2.4 2011/11/12 02:54:04 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.178.2.5 2011/11/13 01:18:02 yamt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -169,8 +169,6 @@ static inline void
 uvm_pageinsert_list(struct uvm_object *uobj, struct vm_page *pg,
     struct vm_page *where)
 {
-	const bool isvnode = UVM_OBJ_IS_VNODE(uobj);
-	const bool isaobj = UVM_OBJ_IS_AOBJ(uobj);
 
 	KASSERT(uobj == pg->uobject);
 	KASSERT(mutex_owned(uobj->vmobjlock));
@@ -178,15 +176,17 @@ uvm_pageinsert_list(struct uvm_object *u
 	KASSERT(where == NULL || (where->flags & PG_TABLED));
 	KASSERT(where == NULL || (where->uobject == uobj));
 
-	if (isvnode || isaobj) {
+	if ((pg->pqflags & PQ_STAT) != 0) {
 		struct uvm_cpu *ucpu;
 		const unsigned int status = uvm_pagegetdirty(pg);
+		const bool isaobj = (pg->pqflags & PQ_AOBJ) != 0;
 
 		kpreempt_disable();
 		ucpu = curcpu()->ci_data.cpu_uvm;
 		ucpu->pagestate[isaobj][status]++;
 		kpreempt_enable();
-		if (isvnode) {
+		if (!isaobj) {
+			KASSERT((pg->pqflags & PQ_FILE) != 0);
 			if (uobj->uo_npages == 0) {
 				struct vnode *vp = (struct vnode *)uobj;
 
@@ -248,22 +248,22 @@ uvm_pageinsert(struct uvm_object *uobj, 
 static inline void
 uvm_pageremove_list(struct uvm_object *uobj, struct vm_page *pg)
 {
-	const bool isvnode = UVM_OBJ_IS_VNODE(uobj);
-	const bool isaobj = UVM_OBJ_IS_AOBJ(uobj);
 
 	KASSERT(uobj == pg->uobject);
 	KASSERT(mutex_owned(uobj->vmobjlock));
 	KASSERT(pg->flags & PG_TABLED);
 
-	if (isvnode || isaobj) {
+	if ((pg->pqflags & PQ_STAT) != 0) {
 		struct uvm_cpu *ucpu;
 		const unsigned int status = uvm_pagegetdirty(pg);
+		const bool isaobj = (pg->pqflags & PQ_AOBJ) != 0;
 
 		kpreempt_disable();
 		ucpu = curcpu()->ci_data.cpu_uvm;
 		ucpu->pagestate[isaobj][status]--;
 		kpreempt_enable();
-		if (isvnode) {
+		if (!isaobj) {
+			KASSERT((pg->pqflags & PQ_FILE) != 0);
 			if (uobj->uo_npages == 1) {
 				struct vnode *vp = (struct vnode *)uobj;
 
@@ -1324,18 +1324,27 @@ uvm_pagealloc_strat(struct uvm_object *o
 	 * otherwise we race with uvm_pglistalloc.
 	 */
 	pg->pqflags = 0;
-	if (anon) {
-		ucpu->pagestate[1][UVM_PAGE_STATUS_CLEAN]++;
-	}
 	mutex_spin_exit(&uvm_fpageqlock);
 	if (anon) {
 		anon->an_page = pg;
 		pg->pqflags = PQ_ANON;
 		atomic_inc_uint(&uvmexp.anonpages);
+		kpreempt_disable();
+		ucpu = curcpu()->ci_data.cpu_uvm;
+		ucpu->pagestate[1][UVM_PAGE_STATUS_CLEAN]++;
+		kpreempt_enable();
 	} else {
 		if (obj) {
 			int error;
 
+			/*
+			 * set PQ_FILE|PQ_AOBJ before the first uvm_pageinsert.
+			 */
+			if (UVM_OBJ_IS_VNODE(obj)) {
+				pg->pqflags |= PQ_FILE;
+			} else {
+				pg->pqflags |= PQ_AOBJ;
+			}
 			error = uvm_pageinsert(obj, pg);
 			if (error != 0) {
 #if 1

Index: src/sys/uvm/uvm_page.h
diff -u src/sys/uvm/uvm_page.h:1.73.2.3 src/sys/uvm/uvm_page.h:1.73.2.4
--- src/sys/uvm/uvm_page.h:1.73.2.3	Fri Nov 11 10:34:24 2011
+++ src/sys/uvm/uvm_page.h	Sun Nov 13 01:18:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.h,v 1.73.2.3 2011/11/11 10:34:24 yamt Exp $	*/
+/*	$NetBSD: uvm_page.h,v 1.73.2.4 2011/11/13 01:18:02 yamt Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -194,6 +194,8 @@ struct vm_page {
 					   uvm_object */
 #define PQ_SWAPBACKED	(PQ_ANON|PQ_AOBJ)
 #define PQ_READAHEAD	0x0008	/* read-ahead but has not been "hit" yet */
+#define	PQ_FILE		0x0010		/* file backed (non-anonymous) */
+#define	PQ_STAT		(PQ_ANON|PQ_AOBJ|PQ_FILE)
 
 #define PQ_PRIVATE1	0x0100
 #define PQ_PRIVATE2	0x0200
@@ -205,7 +207,7 @@ struct vm_page {
 #define PQ_PRIVATE8	0x8000
 
 #define	UVM_PQFLAGBITS \
-	"\20\1FREE\2ANON\3AOBJ\4READAHEAD" \
+	"\20\1FREE\2ANON\3AOBJ\4READAHEAD\5FILE" \
 	"\11PRIVATE1\12PRIVATE2\13PRIVATE3\14PRIVATE4" \
 	"\15PRIVATE5\16PRIVATE6\17PRIVATE7\20PRIVATE8"
 

Index: src/sys/uvm/uvm_page_status.c
diff -u src/sys/uvm/uvm_page_status.c:1.1.2.3 src/sys/uvm/uvm_page_status.c:1.1.2.4
--- src/sys/uvm/uvm_page_status.c:1.1.2.3	Sat Nov 12 02:54:04 2011
+++ src/sys/uvm/uvm_page_status.c	Sun Nov 13 01:18:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page_status.c,v 1.1.2.3 2011/11/12 02:54:04 yamt Exp $	*/
+/*	$NetBSD: uvm_page_status.c,v 1.1.2.4 2011/11/13 01:18:02 yamt Exp $	*/
 
 /*-
  * Copyright (c)2011 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page_status.c,v 1.1.2.3 2011/11/12 02:54:04 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page_status.c,v 1.1.2.4 2011/11/13 01:18:02 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -125,15 +125,9 @@ uvm_pagemarkdirty(struct vm_page *pg, un
 	pg->flags |= newstatus;
 	KASSERT(uobj == NULL || ((pg->flags & PG_CLEAN) == 0) ==
 	    radix_tree_get_tag(&uobj->uo_pages, idx, UVM_PAGE_DIRTY_TAG));
-	if (uobj != NULL) {
-		const bool isvnode = UVM_OBJ_IS_VNODE(uobj);
-		const bool isaobj = UVM_OBJ_IS_AOBJ(uobj);
-
-		if (isvnode || isaobj) {
-			stat_update(isaobj, oldstatus, newstatus);
-		}
-	} else {
-		stat_update(true, oldstatus, newstatus);
+	if ((pg->pqflags & PQ_STAT) != 0) {
+		stat_update((pg->pqflags & PQ_SWAPBACKED) != 0,
+		    oldstatus, newstatus);
 	}
 }
 

Reply via email to