Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 May 2011 19:35:01 +0000 (UTC)
From:      Matthew D Fleming <mdf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r221855 - in head/sys: amd64/include arm/include dev/md dev/null i386/include ia64/include mips/include powerpc/include sparc64/include sun4v/include sys vm
Message-ID:  <201105131935.p4DJZ14Q080511@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mdf
Date: Fri May 13 19:35:01 2011
New Revision: 221855
URL: http://svn.freebsd.org/changeset/base/221855

Log:
  Move the ZERO_REGION_SIZE to a machine-dependent file, as on many
  architectures (i386, for example) the virtual memory space may be
  constrained enough that 2MB is a large chunk.  Use 64K for arches
  other than amd64 and ia64, with special handling for sparc64 due to
  differing hardware.
  
  Also commit the comment changes to kmem_init_zero_region() that I
  missed due to not saving the file.  (Darn the unfamiliar development
  environment).
  
  Arch maintainers, please feel free to adjust ZERO_REGION_SIZE as you
  see fit.
  
  Requested by:	alc
  MFC after:	1 week
  MFC with:	r221853

Modified:
  head/sys/amd64/include/vmparam.h
  head/sys/arm/include/vmparam.h
  head/sys/dev/md/md.c
  head/sys/dev/null/null.c
  head/sys/i386/include/vmparam.h
  head/sys/ia64/include/vmparam.h
  head/sys/mips/include/vmparam.h
  head/sys/powerpc/include/vmparam.h
  head/sys/sparc64/include/vmparam.h
  head/sys/sun4v/include/vmparam.h
  head/sys/sys/systm.h
  head/sys/vm/vm_kern.c

Modified: head/sys/amd64/include/vmparam.h
==============================================================================
--- head/sys/amd64/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/amd64/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -212,4 +212,6 @@
 #define	VM_INITIAL_PAGEIN	16
 #endif
 
+#define	ZERO_REGION_SIZE	(2 * 1024 * 1024)	/* 2MB */
+
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/arm/include/vmparam.h
==============================================================================
--- head/sys/arm/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/arm/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -150,4 +150,7 @@
 #ifdef ARM_USE_SMALL_ALLOC
 #define UMA_MD_SMALL_ALLOC
 #endif /* ARM_USE_SMALL_ALLOC */
+
+#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
+
 #endif	/* _MACHINE_VMPARAM_H_ */

Modified: head/sys/dev/md/md.c
==============================================================================
--- head/sys/dev/md/md.c	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/dev/md/md.c	Fri May 13 19:35:01 2011	(r221855)
@@ -89,6 +89,8 @@
 #include <vm/swap_pager.h>
 #include <vm/uma.h>
 
+#include <machine/vmparam.h>
+
 #define MD_MODVER 1
 
 #define MD_SHUTDOWN	0x10000		/* Tell worker thread to terminate. */

Modified: head/sys/dev/null/null.c
==============================================================================
--- head/sys/dev/null/null.c	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/dev/null/null.c	Fri May 13 19:35:01 2011	(r221855)
@@ -39,7 +39,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/priv.h>
 #include <sys/disk.h>
 #include <sys/bus.h>
+
 #include <machine/bus.h>
+#include <machine/vmparam.h>
 
 /* For use with destroy_dev(9). */
 static struct cdev *null_dev;

Modified: head/sys/i386/include/vmparam.h
==============================================================================
--- head/sys/i386/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/i386/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -198,4 +198,6 @@
 #define	VM_INITIAL_PAGEIN	16
 #endif
 
+#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
+
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/ia64/include/vmparam.h
==============================================================================
--- head/sys/ia64/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/ia64/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -215,4 +215,6 @@
 #define	VM_INITIAL_PAGEIN	16
 #endif
 
+#define	ZERO_REGION_SIZE	(2 * 1024 * 1024)	/* 2MB */
+
 #endif	/* !_MACHINE_VMPARAM_H_ */

Modified: head/sys/mips/include/vmparam.h
==============================================================================
--- head/sys/mips/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/mips/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -187,4 +187,6 @@
  */
 #define	VM_NFREEORDER		9
 
+#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
+
 #endif /* !_MACHINE_VMPARAM_H_ */

Modified: head/sys/powerpc/include/vmparam.h
==============================================================================
--- head/sys/powerpc/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/powerpc/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -198,4 +198,6 @@ struct pmap_physseg {
 #endif
 #endif
 
+#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
+
 #endif /* _MACHINE_VMPARAM_H_ */

Modified: head/sys/sparc64/include/vmparam.h
==============================================================================
--- head/sys/sparc64/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/sparc64/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -240,4 +240,11 @@
 
 extern vm_offset_t vm_max_kernel_address;
 
+/*
+ * Older sparc64 machines have a virtually indexed L1 data cache of 16KB.
+ * Consequently, mapping the same physical page multiple times may have
+ * caching disabled.
+ */
+#define	ZERO_REGION_SIZE	PAGE_SIZE
+
 #endif /* !_MACHINE_VMPARAM_H_ */

Modified: head/sys/sun4v/include/vmparam.h
==============================================================================
--- head/sys/sun4v/include/vmparam.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/sun4v/include/vmparam.h	Fri May 13 19:35:01 2011	(r221855)
@@ -223,4 +223,6 @@
 #define	UMA_MD_SMALL_ALLOC
 extern vm_offset_t vm_max_kernel_address;
 
+#define	ZERO_REGION_SIZE	(64 * 1024)	/* 64KB */
+
 #endif /* !_MACHINE_VMPARAM_H_ */

Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/sys/systm.h	Fri May 13 19:35:01 2011	(r221855)
@@ -126,7 +126,6 @@ extern char static_hints[];	/* by config
 extern char **kenvp;
 
 extern const void *zero_region;	/* address space maps to a zeroed page	*/
-#define	ZERO_REGION_SIZE	(2048 * 1024)
 
 /*
  * General function declarations.

Modified: head/sys/vm/vm_kern.c
==============================================================================
--- head/sys/vm/vm_kern.c	Fri May 13 19:18:15 2011	(r221854)
+++ head/sys/vm/vm_kern.c	Fri May 13 19:35:01 2011	(r221855)
@@ -533,25 +533,22 @@ kmem_free_wakeup(map, addr, size)
 static void
 kmem_init_zero_region(void)
 {
-	vm_offset_t addr;
+	vm_offset_t addr, i;
 	vm_page_t m;
-	unsigned int i;
 	int error;
 
-	/* Allocate virtual address space. */
+	/*
+	 * Map a single physical page of zeros to a larger virtual range.
+	 * This requires less looping in places that want large amounts of
+	 * zeros, while not using much more physical resources.
+	 */
 	addr = kmem_alloc_nofault(kernel_map, ZERO_REGION_SIZE);
-
-	/* Allocate a page and zero it. */
 	m = vm_page_alloc(NULL, OFF_TO_IDX(addr - VM_MIN_KERNEL_ADDRESS),
 	    VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
 	if ((m->flags & PG_ZERO) == 0)
 		pmap_zero_page(m);
-
-	/* Map the address space to the page. */
 	for (i = 0; i < ZERO_REGION_SIZE; i += PAGE_SIZE)
 		pmap_qenter(addr + i, &m, 1);
-
-	/* Protect it r/o. */
 	error = vm_map_protect(kernel_map, addr, addr + ZERO_REGION_SIZE,
 	    VM_PROT_READ, TRUE);
 	KASSERT(error == 0, ("error=%d", error));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105131935.p4DJZ14Q080511>