From owner-svn-src-head@FreeBSD.ORG Fri May 13 19:35:02 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DBA1106566C; Fri, 13 May 2011 19:35:02 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 081B68FC15; Fri, 13 May 2011 19:35:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4DJZ1WW080524; Fri, 13 May 2011 19:35:01 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4DJZ14Q080511; Fri, 13 May 2011 19:35:01 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201105131935.p4DJZ14Q080511@svn.freebsd.org> From: Matthew D Fleming Date: Fri, 13 May 2011 19:35:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: 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 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2011 19:35:02 -0000 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 #include +#include + #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 #include #include + #include +#include /* 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));