From 3d3b036f9541230485c7edd1fafaec6e4345641a Mon Sep 17 00:00:00 2001 From: mdf Date: Fri, 13 May 2011 19:35:01 +0000 Subject: 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 --- sys/vm/vm_kern.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'sys/vm/vm_kern.c') 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)); -- cgit v1.1