summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/include/vmparam.h2
-rw-r--r--sys/arm/include/vmparam.h3
-rw-r--r--sys/dev/md/md.c2
-rw-r--r--sys/dev/null/null.c2
-rw-r--r--sys/i386/include/vmparam.h2
-rw-r--r--sys/ia64/include/vmparam.h2
-rw-r--r--sys/mips/include/vmparam.h2
-rw-r--r--sys/powerpc/include/vmparam.h2
-rw-r--r--sys/sparc64/include/vmparam.h7
-rw-r--r--sys/sun4v/include/vmparam.h2
-rw-r--r--sys/sys/systm.h1
-rw-r--r--sys/vm/vm_kern.c15
12 files changed, 32 insertions, 10 deletions
diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h
index 38a6214..0c65602 100644
--- a/sys/amd64/include/vmparam.h
+++ b/sys/amd64/include/vmparam.h
@@ -212,4 +212,6 @@
#define VM_INITIAL_PAGEIN 16
#endif
+#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */
+
#endif /* _MACHINE_VMPARAM_H_ */
diff --git a/sys/arm/include/vmparam.h b/sys/arm/include/vmparam.h
index c608daa..dd1ba1c 100644
--- a/sys/arm/include/vmparam.h
+++ b/sys/arm/include/vmparam.h
@@ -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_ */
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 71d0365..c488728 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -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. */
diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c
index 04619b2..b053d5d 100644
--- a/sys/dev/null/null.c
+++ b/sys/dev/null/null.c
@@ -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;
diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h
index 9eaa3f7..8fe9b2b 100644
--- a/sys/i386/include/vmparam.h
+++ b/sys/i386/include/vmparam.h
@@ -198,4 +198,6 @@
#define VM_INITIAL_PAGEIN 16
#endif
+#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
+
#endif /* _MACHINE_VMPARAM_H_ */
diff --git a/sys/ia64/include/vmparam.h b/sys/ia64/include/vmparam.h
index e93ca1b..16c5e7d 100644
--- a/sys/ia64/include/vmparam.h
+++ b/sys/ia64/include/vmparam.h
@@ -215,4 +215,6 @@
#define VM_INITIAL_PAGEIN 16
#endif
+#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */
+
#endif /* !_MACHINE_VMPARAM_H_ */
diff --git a/sys/mips/include/vmparam.h b/sys/mips/include/vmparam.h
index ef01601..4a702f5 100644
--- a/sys/mips/include/vmparam.h
+++ b/sys/mips/include/vmparam.h
@@ -187,4 +187,6 @@
*/
#define VM_NFREEORDER 9
+#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
+
#endif /* !_MACHINE_VMPARAM_H_ */
diff --git a/sys/powerpc/include/vmparam.h b/sys/powerpc/include/vmparam.h
index d72e0ea..cec455f 100644
--- a/sys/powerpc/include/vmparam.h
+++ b/sys/powerpc/include/vmparam.h
@@ -198,4 +198,6 @@ struct pmap_physseg {
#endif
#endif
+#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
+
#endif /* _MACHINE_VMPARAM_H_ */
diff --git a/sys/sparc64/include/vmparam.h b/sys/sparc64/include/vmparam.h
index 0638d0d..1b9e537 100644
--- a/sys/sparc64/include/vmparam.h
+++ b/sys/sparc64/include/vmparam.h
@@ -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_ */
diff --git a/sys/sun4v/include/vmparam.h b/sys/sun4v/include/vmparam.h
index 65c7f78..5195f1d 100644
--- a/sys/sun4v/include/vmparam.h
+++ b/sys/sun4v/include/vmparam.h
@@ -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_ */
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 30455a9..e563a5a 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -126,7 +126,6 @@ extern char static_hints[]; /* by config for now */
extern char **kenvp;
extern const void *zero_region; /* address space maps to a zeroed page */
-#define ZERO_REGION_SIZE (2048 * 1024)
/*
* General function declarations.
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index 6b4bbb8..23884af 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -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));
OpenPOWER on IntegriCloud