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.
This commit is contained in:
Alan Cox 2011-10-27 02:52:24 +00:00
parent 224f878512
commit f346986b76
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226824
2 changed files with 37 additions and 28 deletions

View file

@ -407,6 +407,43 @@ malloc_type_freed(struct malloc_type *mtp, unsigned long size)
critical_exit();
}
/*
* 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:
*

View file

@ -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 size, vm_page_t m, vm_memattr_t memattr,
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 @@ kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low,
}
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));
}