diff options
author | mdf <mdf@FreeBSD.org> | 2011-05-13 19:35:01 +0000 |
---|---|---|
committer | mdf <mdf@FreeBSD.org> | 2011-05-13 19:35:01 +0000 |
commit | 3d3b036f9541230485c7edd1fafaec6e4345641a (patch) | |
tree | a7b19af758b87ed8c5280b36452735563a1afd59 /sys/vm/vm_kern.c | |
parent | 9465c340011c0f0d939dc79a97cb31b7b974f015 (diff) | |
download | FreeBSD-src-3d3b036f9541230485c7edd1fafaec6e4345641a.zip FreeBSD-src-3d3b036f9541230485c7edd1fafaec6e4345641a.tar.gz |
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
Diffstat (limited to 'sys/vm/vm_kern.c')
-rw-r--r-- | sys/vm/vm_kern.c | 15 |
1 files changed, 6 insertions, 9 deletions
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)); |