svn commit: r226824 - in head/sys: kern vm

Alan Cox alc at FreeBSD.org
Thu Oct 27 02:52:25 UTC 2011


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 <sys/param.h>
 #include <sys/systm.h>
 #include <sys/lock.h>
-#include <sys/malloc.h>
 #include <sys/mount.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
@@ -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));
-}


More information about the svn-src-head mailing list