From owner-svn-src-head@FreeBSD.ORG Mon Aug 19 23:02:40 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C5A77151; Mon, 19 Aug 2013 23:02:40 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 97D522EB7; Mon, 19 Aug 2013 23:02:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7JN2eMv088399; Mon, 19 Aug 2013 23:02:40 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7JN2eLq088397; Mon, 19 Aug 2013 23:02:40 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201308192302.r7JN2eLq088397@svn.freebsd.org> From: Jeff Roberson Date: Mon, 19 Aug 2013 23:02:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254543 - in head/sys: kern vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Mon, 19 Aug 2013 23:02:40 -0000 Author: jeff Date: Mon Aug 19 23:02:39 2013 New Revision: 254543 URL: http://svnweb.freebsd.org/changeset/base/254543 Log: - Use an arbitrary but reasonably large import size for kva on architectures that don't support superpages. This keeps the number of spans and internal fragmentation lower. - When the user asks for alignment from vmem_xalloc adjust the imported size by 2*align to be certain we can satisfy the allocation. This comes at the expense of potential failures when the backend can't supply enough memory but could supply the requested size and alignment. Sponsored by: EMC / Isilon Storage Division Modified: head/sys/kern/subr_vmem.c head/sys/vm/vm_init.c Modified: head/sys/kern/subr_vmem.c ============================================================================== --- head/sys/kern/subr_vmem.c Mon Aug 19 22:25:36 2013 (r254542) +++ head/sys/kern/subr_vmem.c Mon Aug 19 23:02:39 2013 (r254543) @@ -758,6 +758,7 @@ vmem_add1(vmem_t *vm, vmem_addr_t addr, bt_t *btfree; MPASS(type == BT_TYPE_SPAN || type == BT_TYPE_SPAN_STATIC); + MPASS((size & vm->vm_quantum_mask) == 0); btspan = bt_alloc(vm); btspan->bt_type = type; @@ -805,7 +806,7 @@ vmem_destroy1(vmem_t *vm) } static int -vmem_import(vmem_t *vm, vmem_size_t size, int flags) +vmem_import(vmem_t *vm, vmem_size_t size, vmem_size_t align, int flags) { vmem_addr_t addr; int error; @@ -813,6 +814,12 @@ vmem_import(vmem_t *vm, vmem_size_t size if (vm->vm_importfn == NULL) return EINVAL; + /* + * To make sure we get a span that meets the alignment we double it + * and add the size to the tail. This slightly overestimates. + */ + if (align != vm->vm_quantum_mask + 1) + size = (align * 2) + size; size = roundup(size, vm->vm_import_quantum); /* @@ -1157,7 +1164,7 @@ vmem_xalloc(vmem_t *vm, const vmem_size_ * imported region. It is up to the user to specify the * import quantum such that it can satisfy any allocation. */ - if (vmem_import(vm, size, flags) == 0) + if (vmem_import(vm, size, align, flags) == 0) continue; /* Modified: head/sys/vm/vm_init.c ============================================================================== --- head/sys/vm/vm_init.c Mon Aug 19 22:25:36 2013 (r254542) +++ head/sys/vm/vm_init.c Mon Aug 19 23:02:39 2013 (r254543) @@ -156,7 +156,8 @@ vm_mem_init(dummy) #if VM_NRESERVLEVEL > 0 1 << (VM_LEVEL_0_ORDER + PAGE_SHIFT)); #else - PAGE_SIZE); + /* On non-superpage architectures want large import sizes. */ + PAGE_SIZE * 1024); #endif kmem_init_zero_region();