topdown-vm for sun2/sun3

Chuck Silvers <[email protected]> Mon, 10 Dec 2012 08:34:43 -0800
Newsgroups gmane.os.netbsd.ports.sun3,gmane.os.netbsd.ports.sun2
Message-ID <[email protected]>
--pWyiEgJYm5f9v55/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

hi folks,

the attached patch enables __USE_TOPDOWN_VM for sun2 and sun3.
I've tested only on a sun3/60.  sun3x should be fine since doesn't
use PMAP_PREFER(), and I just applied the same change to sun2.
does anyone see any problem with this?

-Chuck

--pWyiEgJYm5f9v55/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.sun23-topdown.1"

Index: src/sys/arch/sun2/include/pmap.h
===================================================================
RCS file: /home/chs/netbsd/cvs/src/sys/arch/sun2/include/pmap.h,v
retrieving revision 1.24
diff -u -p -r1.24 pmap.h
--- src/sys/arch/sun2/include/pmap.h	3 Jun 2011 17:03:52 -0000	1.24
+++ src/sys/arch/sun2/include/pmap.h	7 Dec 2012 23:58:30 -0000
@@ -51,7 +51,7 @@ int _pmap_fault(struct vm_map *, vaddr_t
 
 /* This lets us have some say in choosing VA locations. */
 extern void pmap_prefer(vaddr_t, vaddr_t *);
-#define PMAP_PREFER(fo, ap, sz, td) pmap_prefer((fo), (ap))
+#define PMAP_PREFER(fo, ap, sz, td) pmap_prefer((fo), (ap), (td))
 
 /* This needs to be a macro for kern_sysctl.c */
 extern segsz_t pmap_resident_pages(pmap_t);
Index: src/sys/arch/sun2/include/vmparam.h
===================================================================
RCS file: /home/chs/netbsd/cvs/src/sys/arch/sun2/include/vmparam.h,v
retrieving revision 1.14
diff -u -p -r1.14 vmparam.h
--- src/sys/arch/sun2/include/vmparam.h	6 Nov 2010 15:42:49 -0000	1.14
+++ src/sys/arch/sun2/include/vmparam.h	7 Dec 2012 23:59:29 -0000
@@ -26,6 +26,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define __USE_TOPDOWN_VM
+
 /*
  * Machine dependent constants for Sun2
  *
Index: src/sys/arch/sun2/sun2/pmap.c
===================================================================
RCS file: /home/chs/netbsd/cvs/src/sys/arch/sun2/sun2/pmap.c,v
retrieving revision 1.45
diff -u -p -r1.45 pmap.c
--- src/sys/arch/sun2/sun2/pmap.c	31 Jan 2012 22:47:08 -0000	1.45
+++ src/sys/arch/sun2/sun2/pmap.c	7 Dec 2012 23:59:52 -0000
@@ -3683,12 +3683,18 @@ pmap_zero_page(paddr_t pa)
  * (This will just seg-align mappings.)
  */
 void 
-pmap_prefer(vaddr_t fo, vaddr_t *va)
+pmap_prefer(vaddr_t fo, vaddr_t *va, int td)
 {
 	long d;
 
 	d = fo - *va;
 	d &= SEGOFSET;
+	if (d == 0) {
+		return;
+	}
+	if (td) {
+		*va -= SEGOFSET + 1;
+	}
 	*va += d;
 }
 
Index: src/sys/arch/sun3/include/pmap3.h
===================================================================
RCS file: /home/chs/netbsd/cvs/src/sys/arch/sun3/include/pmap3.h,v
retrieving revision 1.48
diff -u -p -r1.48 pmap3.h
--- src/sys/arch/sun3/include/pmap3.h	3 Jun 2011 17:03:52 -0000	1.48
+++ src/sys/arch/sun3/include/pmap3.h	7 Dec 2012 23:46:47 -0000
@@ -50,8 +50,8 @@ struct pmap {
 int _pmap_fault(struct vm_map *, vaddr_t, vm_prot_t);
 
 /* This lets us have some say in choosing VA locations. */
-extern void pmap_prefer(vaddr_t, vaddr_t *);
-#define PMAP_PREFER(fo, ap, sz, td) pmap_prefer((fo), (ap))
+extern void pmap_prefer(vaddr_t, vaddr_t *, int);
+#define PMAP_PREFER(fo, ap, sz, td) pmap_prefer((fo), (ap), (td))
 
 /* This needs to be a macro for kern_sysctl.c */
 extern segsz_t pmap_resident_pages(pmap_t);
Index: src/sys/arch/sun3/include/vmparam.h
===================================================================
RCS file: /home/chs/netbsd/cvs/src/sys/arch/sun3/include/vmparam.h,v
retrieving revision 1.36
diff -u -p -r1.36 vmparam.h
--- src/sys/arch/sun3/include/vmparam.h	6 Nov 2010 15:42:49 -0000	1.36
+++ src/sys/arch/sun3/include/vmparam.h	7 Dec 2012 22:57:42 -0000
@@ -29,6 +29,8 @@
 #ifndef _SUN3_VMPARAM_H_
 #define _SUN3_VMPARAM_H_ 1
 
+#define __USE_TOPDOWN_VM
+
 /*
  * We use 8K pages on both the sun3 and sun3x.  Override PAGE_*
  * to be compile-time constants.
Index: src/sys/arch/sun3/sun3/pmap.c
===================================================================
RCS file: /home/chs/netbsd/cvs/src/sys/arch/sun3/sun3/pmap.c,v
retrieving revision 1.167
diff -u -p -r1.167 pmap.c
--- src/sys/arch/sun3/sun3/pmap.c	29 Jan 2012 16:24:51 -0000	1.167
+++ src/sys/arch/sun3/sun3/pmap.c	7 Dec 2012 23:52:26 -0000
@@ -3621,12 +3621,18 @@ pmap_zero_page(paddr_t pa)
  * (This will just seg-align mappings.)
  */
 void 
-pmap_prefer(vaddr_t fo, vaddr_t *va)
+pmap_prefer(vaddr_t fo, vaddr_t *va, int td)
 {
 	long d;
 
 	d = fo - *va;
 	d &= SEGOFSET;
+	if (d == 0) {
+		return;
+	}
+	if (td) {
+		*va -= SEGOFSET + 1;
+	}
 	*va += d;
 }
 

--pWyiEgJYm5f9v55/--