svn commit: r262863 - in stable/9/sys: kern vm
Jean-Sebastien Pedron
dumbbell at FreeBSD.org
Thu Mar 6 18:50:36 UTC 2014
Author: dumbbell
Date: Thu Mar 6 18:50:35 2014
New Revision: 262863
URL: http://svnweb.freebsd.org/changeset/base/262863
Log:
MFC r226824:
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:
stable/9/sys/kern/kern_malloc.c
stable/9/sys/vm/vm_contig.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/kern/kern_malloc.c
==============================================================================
--- stable/9/sys/kern/kern_malloc.c Thu Mar 6 18:48:02 2014 (r262862)
+++ stable/9/sys/kern/kern_malloc.c Thu Mar 6 18:50:35 2014 (r262863)
@@ -406,6 +406,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: stable/9/sys/vm/vm_contig.c
==============================================================================
--- stable/9/sys/vm/vm_contig.c Thu Mar 6 18:48:02 2014 (r262862)
+++ stable/9/sys/vm/vm_contig.c Thu Mar 6 18:50:35 2014 (r262863)
@@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/eventhandler.h>
#include <sys/lock.h>
-#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@@ -359,25 +358,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,
@@ -407,11 +387,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-stable-9
mailing list