Module Name:    src
Committed By:   ad
Date:           Tue Jan 21 20:37:06 UTC 2020

Modified Files:
        src/sys/uvm: uvm_page.c uvm_page.h uvm_pdpolicy_clock.c

Log Message:
uvmpdpol_pageactive(): the change to not re-activate recently activated
pages worked great with uvm_pageqlock, but it doesn't buy anything any more,
because now the busy pages are likely in a per-CPU queue somewhere waiting
to be processed, and changing the intent on those queued pages costs next
to nothing.  Remove this and get back all the bits in pg->pqflags.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/uvm/uvm_page.c
cvs rdiff -u -r1.96 -r1.97 src/sys/uvm/uvm_page.h
cvs rdiff -u -r1.30 -r1.31 src/sys/uvm/uvm_pdpolicy_clock.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_page.c
diff -u src/sys/uvm/uvm_page.c:1.224 src/sys/uvm/uvm_page.c:1.225
--- src/sys/uvm/uvm_page.c:1.224	Wed Jan 15 17:55:45 2020
+++ src/sys/uvm/uvm_page.c	Tue Jan 21 20:37:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.c,v 1.224 2020/01/15 17:55:45 ad Exp $	*/
+/*	$NetBSD: uvm_page.c,v 1.225 2020/01/21 20:37:06 ad Exp $	*/
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.224 2020/01/15 17:55:45 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.225 2020/01/21 20:37:06 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvm.h"
@@ -2149,6 +2149,7 @@ uvm_direct_process(struct vm_page **pgs,
  */
 
 static const char page_flagbits[] = UVM_PGFLAGBITS;
+static const char page_pqflagbits[] = UVM_PQFLAGBITS;
 
 void
 uvm_page_printit(struct vm_page *pg, bool full,
@@ -2162,12 +2163,15 @@ uvm_page_printit(struct vm_page *pg, boo
 
 	(*pr)("PAGE %p:\n", pg);
 	snprintb(pgbuf, sizeof(pgbuf), page_flagbits, pg->flags);
-	(*pr)("  flags=%s\n  pqflags=%x, wire_count=%d, pa=0x%lx\n",
-	    pgbuf, pg->pqflags, pg->wire_count, (long)VM_PAGE_TO_PHYS(pg));
-	(*pr)("  uobject=%p, uanon=%p, offset=0x%llx loan_count=%d\n",
-	    pg->uobject, pg->uanon, (long long)pg->offset, pg->loan_count);
-	(*pr)("  bucket=%d freelist=%d\n",
-	    uvm_page_get_bucket(pg), uvm_page_get_freelist(pg));
+	(*pr)("  flags=%s\n", pgbuf);
+	snprintb(pgbuf, sizeof(pgbuf), page_pqflagbits, pg->pqflags);
+	(*pr)("  pqflags=%s\n", pgbuf);
+	(*pr)("  uobject=%p, uanon=%p, offset=0x%llx\n",
+	    pg->uobject, pg->uanon, (long long)pg->offset);
+	(*pr)("  loan_count=%d wire_count=%d bucket=%d freelist=%d\n",
+	    pg->loan_count, pg->wire_count, uvm_page_get_bucket(pg),
+	    uvm_page_get_freelist(pg));
+	(*pr)("  pa=0x%lx\n", (long)VM_PAGE_TO_PHYS(pg));
 #if defined(UVM_PAGE_TRKOWN)
 	if (pg->flags & PG_BUSY)
 		(*pr)("  owning process = %d, tag=%s\n",

Index: src/sys/uvm/uvm_page.h
diff -u src/sys/uvm/uvm_page.h:1.96 src/sys/uvm/uvm_page.h:1.97
--- src/sys/uvm/uvm_page.h:1.96	Wed Jan 15 17:55:45 2020
+++ src/sys/uvm/uvm_page.h	Tue Jan 21 20:37:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.h,v 1.96 2020/01/15 17:55:45 ad Exp $	*/
+/*	$NetBSD: uvm_page.h,v 1.97 2020/01/21 20:37:06 ad Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -181,7 +181,7 @@ struct vm_page {
 };
 
 /*
- * Overview of UVM page flags.
+ * Overview of UVM page flags, stored in pg->flags.
  *
  * Locking notes:
  *
@@ -275,12 +275,9 @@ struct vm_page {
 	"\21PAGER1"
 
 /*
- * uvmpdpol state flags.
+ * Flags stored in pg->pqflags, which is protected by pg->interlock.
  *
- * => may only be changed with pg->interlock held.
- * => changing them is the responsibility of uvmpdpol ..
- * => .. but uvm_page needs to know about them in order to purge updates.
- * => PQ_PRIVATE is private to the individual uvmpdpol implementation.
+ * PQ_PRIVATE is for uvmpdpol to do whatever it wants with.
  */
 
 #define	PQ_INTENT_A		0x00000000	/* intend activation */
@@ -290,7 +287,12 @@ struct vm_page {
 #define	PQ_INTENT_MASK		0x00000003	/* mask of intended state */
 #define	PQ_INTENT_SET		0x00000004	/* not realized yet */
 #define	PQ_INTENT_QUEUED	0x00000008	/* queued for processing */
-#define	PQ_PRIVATE		0xfffffff0
+#define	PQ_PRIVATE		0x00000ff0	/* private for pdpolicy */
+
+#define	UVM_PQFLAGBITS \
+	"\20\1INTENT_0\2INTENT_1\3INTENT_SET\4INTENT_QUEUED" \
+	"\5PRIVATE1\6PRIVATE2\7PRIVATE3\10PRIVATE4" \
+	"\11PRIVATE5\12PRIVATE6\13PRIVATE7\14PRIVATE8"
 
 /*
  * physical memory layout structure

Index: src/sys/uvm/uvm_pdpolicy_clock.c
diff -u src/sys/uvm/uvm_pdpolicy_clock.c:1.30 src/sys/uvm/uvm_pdpolicy_clock.c:1.31
--- src/sys/uvm/uvm_pdpolicy_clock.c:1.30	Wed Jan  1 14:33:48 2020
+++ src/sys/uvm/uvm_pdpolicy_clock.c	Tue Jan 21 20:37:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pdpolicy_clock.c,v 1.30 2020/01/01 14:33:48 ad Exp $	*/
+/*	$NetBSD: uvm_pdpolicy_clock.c,v 1.31 2020/01/21 20:37:06 ad Exp $	*/
 /*	NetBSD: uvm_pdaemon.c,v 1.72 2006/01/05 10:47:33 yamt Exp $	*/
 
 /*-
@@ -98,7 +98,7 @@
 #else /* defined(PDSIM) */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.30 2020/01/01 14:33:48 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clock.c,v 1.31 2020/01/21 20:37:06 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -124,7 +124,6 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy
 #define	CLOCK_PDQ_SIZE	128
 #endif /* !defined(CLOCK_PDQ_SIZE) */
 
-#define	PQ_TIME		0xffffffc0	/* time of last activation */
 #define PQ_INACTIVE	0x00000010	/* page is in inactive list */
 #define PQ_ACTIVE	0x00000020	/* page is in active list */
 
@@ -487,29 +486,17 @@ uvmpdpol_pageactivate_locked(struct vm_p
 	uvmpdpol_pagedequeue_locked(pg);
 	TAILQ_INSERT_TAIL(&pdpol_state.s_activeq, pg, pdqueue);
 	pdpol_state.s_active++;
-	pg->pqflags = (pg->pqflags & PQ_INTENT_QUEUED) | PQ_ACTIVE |
-	    (hardclock_ticks & PQ_TIME);
+	pg->pqflags = (pg->pqflags & PQ_INTENT_QUEUED) | PQ_ACTIVE;
 }
 
 void
 uvmpdpol_pageactivate(struct vm_page *pg)
 {
-	uint32_t pqflags;
 
 	KASSERT(uvm_page_owner_locked_p(pg));
 	KASSERT(mutex_owned(&pg->interlock));
 
-	/*
-	 * if there is any intent set on the page, or the page is not
-	 * active, or the page was activated in the "distant" past, then
-	 * it needs to be activated anew.
-	 */
-	pqflags = pg->pqflags;
-	if ((pqflags & PQ_INTENT_SET) != 0 ||
-	    (pqflags & PQ_ACTIVE) == 0 ||
-	    ((hardclock_ticks & PQ_TIME) - (pqflags & PQ_TIME)) > hz) {
-		uvmpdpol_set_intent(pg, PQ_INTENT_A);
-	}
+	uvmpdpol_set_intent(pg, PQ_INTENT_A);
 }
 
 static void

Reply via email to