From owner-svn-src-all@FreeBSD.ORG Thu Oct 27 02:52:25 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 466EB106564A; Thu, 27 Oct 2011 02:52:25 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D0FD8FC08; Thu, 27 Oct 2011 02:52:25 +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 p9R2qPQ4080176; Thu, 27 Oct 2011 02:52:25 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9R2qOd8080173; Thu, 27 Oct 2011 02:52:24 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201110270252.p9R2qOd8080173@svn.freebsd.org> From: Alan Cox Date: Thu, 27 Oct 2011 02:52:24 +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: r226824 - in head/sys: kern vm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2011 02:52:25 -0000 Author: alc Date: Thu Oct 27 02:52:24 2011 New Revision: 226824 URL: http://svn.freebsd.org/changeset/base/226824 Log: contigmalloc(9) and contigfree(9) are now implemented in terms of other more general VM system interfaces. So, their implementation can now reside in kern_malloc.c alongside the other functions that are declared in malloc.h. Modified: head/sys/kern/kern_malloc.c head/sys/vm/vm_contig.c Modified: head/sys/kern/kern_malloc.c ============================================================================== --- head/sys/kern/kern_malloc.c Thu Oct 27 02:40:43 2011 (r226823) +++ head/sys/kern/kern_malloc.c Thu Oct 27 02:52:24 2011 (r226824) @@ -408,6 +408,43 @@ malloc_type_freed(struct malloc_type *mt } /* + * contigmalloc: + * + * Allocate a block of physically contiguous memory. + * + * If M_NOWAIT is set, this routine will not block and return NULL if + * the allocation fails. + */ +void * +contigmalloc(unsigned long size, struct malloc_type *type, int flags, + vm_paddr_t low, vm_paddr_t high, unsigned long alignment, + unsigned long boundary) +{ + void *ret; + + ret = (void *)kmem_alloc_contig(kernel_map, size, flags, low, high, + alignment, boundary, VM_MEMATTR_DEFAULT); + if (ret != NULL) + malloc_type_allocated(type, round_page(size)); + return (ret); +} + +/* + * contigfree: + * + * Free a block of memory allocated by contigmalloc. + * + * This routine may not block. + */ +void +contigfree(void *addr, unsigned long size, struct malloc_type *type) +{ + + kmem_free(kernel_map, (vm_offset_t)addr, size); + malloc_type_freed(type, round_page(size)); +} + +/* * malloc: * * Allocate a block of memory. Modified: head/sys/vm/vm_contig.c ============================================================================== --- head/sys/vm/vm_contig.c Thu Oct 27 02:40:43 2011 (r226823) +++ head/sys/vm/vm_contig.c Thu Oct 27 02:52:24 2011 (r226824) @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -334,25 +333,6 @@ contigmapping(vm_map_t map, vm_size_t si return (addr); } -void * -contigmalloc( - unsigned long size, /* should be size_t here and for malloc() */ - struct malloc_type *type, - int flags, - vm_paddr_t low, - vm_paddr_t high, - unsigned long alignment, - unsigned long boundary) -{ - void *ret; - - ret = (void *)kmem_alloc_contig(kernel_map, size, flags, low, high, - alignment, boundary, VM_MEMATTR_DEFAULT); - if (ret != NULL) - malloc_type_allocated(type, round_page(size)); - return (ret); -} - vm_offset_t kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low, vm_paddr_t high, unsigned long alignment, unsigned long boundary, @@ -382,11 +362,3 @@ retry: } return (ret); } - -void -contigfree(void *addr, unsigned long size, struct malloc_type *type) -{ - - kmem_free(kernel_map, (vm_offset_t)addr, size); - malloc_type_freed(type, round_page(size)); -}