Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_malloc.c
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
#include <sys/sbuf.h> | #include <sys/sbuf.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <sys/vmem.h> | #include <sys/vmem.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <vm/vm_domainset.h> | |||||
#include <vm/vm_pageout.h> | #include <vm/vm_pageout.h> | ||||
#include <vm/vm_param.h> | #include <vm/vm_param.h> | ||||
#include <vm/vm_kern.h> | #include <vm/vm_kern.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/vm_map.h> | #include <vm/vm_map.h> | ||||
#include <vm/vm_page.h> | #include <vm/vm_page.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <vm/uma_int.h> | #include <vm/uma_int.h> | ||||
▲ Show 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | contigmalloc(unsigned long size, struct malloc_type *type, int flags, | ||||
return (ret); | return (ret); | ||||
} | } | ||||
void * | void * | ||||
contigmalloc_domain(unsigned long size, struct malloc_type *type, | contigmalloc_domain(unsigned long size, struct malloc_type *type, | ||||
int domain, int flags, vm_paddr_t low, vm_paddr_t high, | int domain, int flags, vm_paddr_t low, vm_paddr_t high, | ||||
unsigned long alignment, vm_paddr_t boundary) | unsigned long alignment, vm_paddr_t boundary) | ||||
{ | { | ||||
return (contigmalloc_domainset(size, type, DOMAINSET_PREF(domain), | |||||
flags, low, high, alignment, boundary)); | |||||
} | |||||
/* | |||||
* contigmalloc_domainset: | |||||
* | |||||
* Allocate a block of physically contiguous memory, using the specified | |||||
* policy to select a domain. | |||||
*/ | |||||
void * | |||||
contigmalloc_domainset(unsigned long size, struct malloc_type *type, | |||||
struct domainset *ds, int flags, vm_paddr_t low, vm_paddr_t high, | |||||
unsigned long alignment, vm_paddr_t boundary) | |||||
{ | |||||
void *ret; | void *ret; | ||||
ret = (void *)kmem_alloc_contig_domain(domain, size, flags, low, high, | ret = (void *)kmem_alloc_contig_domainset(ds, size, flags, low, high, | ||||
alignment, boundary, VM_MEMATTR_DEFAULT); | alignment, boundary, VM_MEMATTR_DEFAULT); | ||||
if (ret != NULL) | if (ret != NULL) | ||||
malloc_type_allocated(type, round_page(size)); | malloc_type_allocated(type, round_page(size)); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
/* | /* | ||||
* contigfree: | * contigfree: | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | else if (va == NULL) | ||||
t_malloc_fail = time_uptime; | t_malloc_fail = time_uptime; | ||||
#ifdef DEBUG_REDZONE | #ifdef DEBUG_REDZONE | ||||
if (va != NULL) | if (va != NULL) | ||||
va = redzone_setup(va, osize); | va = redzone_setup(va, osize); | ||||
#endif | #endif | ||||
return ((void *) va); | return ((void *) va); | ||||
} | } | ||||
void * | static void * | ||||
malloc_domain(size_t size, struct malloc_type *mtp, int domain, | _malloc_domain(size_t size, struct malloc_type *mtp, int domain, int flags) | ||||
int flags) | |||||
{ | { | ||||
int indx; | int indx; | ||||
caddr_t va; | caddr_t va; | ||||
uma_zone_t zone; | uma_zone_t zone; | ||||
#if defined(DEBUG_REDZONE) | #if defined(DEBUG_REDZONE) | ||||
unsigned long osize = size; | unsigned long osize = size; | ||||
#endif | #endif | ||||
Show All 24 Lines | if (flags & M_WAITOK) | ||||
KASSERT(va != NULL, ("malloc(M_WAITOK) returned NULL")); | KASSERT(va != NULL, ("malloc(M_WAITOK) returned NULL")); | ||||
else if (va == NULL) | else if (va == NULL) | ||||
t_malloc_fail = time_uptime; | t_malloc_fail = time_uptime; | ||||
#ifdef DEBUG_REDZONE | #ifdef DEBUG_REDZONE | ||||
if (va != NULL) | if (va != NULL) | ||||
va = redzone_setup(va, osize); | va = redzone_setup(va, osize); | ||||
#endif | #endif | ||||
return ((void *) va); | return ((void *) va); | ||||
} | |||||
void * | |||||
malloc_domain(size_t size, struct malloc_type *mtp, int domain, int flags) | |||||
{ | |||||
return (malloc_domainset(size, mtp, DOMAINSET_PREF(domain), flags)); | |||||
} | |||||
void * | |||||
malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds, | |||||
int flags) | |||||
{ | |||||
struct vm_domainset_iter di; | |||||
void *ret; | |||||
int domain; | |||||
markj: This test is inverted. | |||||
vm_domainset_iter_policy_init(&di, ds, &domain, &flags); | |||||
do { | |||||
ret = _malloc_domain(size, mtp, domain, flags); | |||||
if (ret != NULL) | |||||
break; | |||||
} while (vm_domainset_iter_policy(&di, &domain) == 0); | |||||
return (ret); | |||||
} | } | ||||
void * | void * | ||||
mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags) | mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags) | ||||
{ | { | ||||
if (WOULD_OVERFLOW(nmemb, size)) | if (WOULD_OVERFLOW(nmemb, size)) | ||||
panic("mallocarray: %zu * %zu overflowed", nmemb, size); | panic("mallocarray: %zu * %zu overflowed", nmemb, size); | ||||
▲ Show 20 Lines • Show All 649 Lines • Show Last 20 Lines |
This test is inverted.