Implement mallocarray_domainset(9) variant of mallocarray(9).
Reviewed by: kib @ MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking
This commit is contained in:
parent
d708f23ebb
commit
c743a6bd4f
@ -1391,6 +1391,7 @@ MLINKS+=make_dev.9 destroy_dev.9 \
|
|||||||
MLINKS+=malloc.9 free.9 \
|
MLINKS+=malloc.9 free.9 \
|
||||||
malloc.9 malloc_domainset.9 \
|
malloc.9 malloc_domainset.9 \
|
||||||
malloc.9 mallocarray.9 \
|
malloc.9 mallocarray.9 \
|
||||||
|
malloc.9 mallocarray_domainset.9 \
|
||||||
malloc.9 MALLOC_DECLARE.9 \
|
malloc.9 MALLOC_DECLARE.9 \
|
||||||
malloc.9 MALLOC_DEFINE.9 \
|
malloc.9 MALLOC_DEFINE.9 \
|
||||||
malloc.9 realloc.9 \
|
malloc.9 realloc.9 \
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $
|
.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd October 30, 2020
|
.Dd March 6, 2021
|
||||||
.Dt MALLOC 9
|
.Dt MALLOC 9
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -70,6 +70,8 @@
|
|||||||
.Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags"
|
.Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags"
|
||||||
.Ft void *
|
.Ft void *
|
||||||
.Fn malloc_domainset_exec "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags"
|
.Fn malloc_domainset_exec "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags"
|
||||||
|
.Ft void *
|
||||||
|
.Fn mallocarray_domainset "size_t nmemb" "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags"
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Fn malloc
|
.Fn malloc
|
||||||
@ -102,6 +104,15 @@ entries whose size is specified by
|
|||||||
.Fa size .
|
.Fa size .
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
.Fn mallocarray_domainset
|
||||||
|
variant allocates memory from a specific
|
||||||
|
.Xr numa 4
|
||||||
|
domain using the specified domain selection policy.
|
||||||
|
See
|
||||||
|
.Xr domainset 9
|
||||||
|
for some example policies.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
.Fn free
|
.Fn free
|
||||||
function releases memory at address
|
function releases memory at address
|
||||||
.Fa addr
|
.Fa addr
|
||||||
|
@ -804,6 +804,17 @@ mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags)
|
|||||||
return (malloc(size * nmemb, type, flags));
|
return (malloc(size * nmemb, type, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
mallocarray_domainset(size_t nmemb, size_t size, struct malloc_type *type,
|
||||||
|
struct domainset *ds, int flags)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (WOULD_OVERFLOW(nmemb, size))
|
||||||
|
panic("mallocarray_domainset: %zu * %zu overflowed", nmemb, size);
|
||||||
|
|
||||||
|
return (malloc_domainset(size * nmemb, type, ds, flags));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef INVARIANTS
|
#ifdef INVARIANTS
|
||||||
static void
|
static void
|
||||||
free_save_type(void *addr, struct malloc_type *mtp, u_long size)
|
free_save_type(void *addr, struct malloc_type *mtp, u_long size)
|
||||||
|
@ -246,6 +246,9 @@ void *malloc_domainset(size_t size, struct malloc_type *type,
|
|||||||
void *mallocarray(size_t nmemb, size_t size, struct malloc_type *type,
|
void *mallocarray(size_t nmemb, size_t size, struct malloc_type *type,
|
||||||
int flags) __malloc_like __result_use_check
|
int flags) __malloc_like __result_use_check
|
||||||
__alloc_size2(1, 2);
|
__alloc_size2(1, 2);
|
||||||
|
void *mallocarray_domainset(size_t nmemb, size_t size, struct malloc_type *type,
|
||||||
|
struct domainset *ds, int flags) __malloc_like __result_use_check
|
||||||
|
__alloc_size2(1, 2);
|
||||||
void *malloc_exec(size_t size, struct malloc_type *type, int flags) __malloc_like
|
void *malloc_exec(size_t size, struct malloc_type *type, int flags) __malloc_like
|
||||||
__result_use_check __alloc_size(1);
|
__result_use_check __alloc_size(1);
|
||||||
void *malloc_domainset_exec(size_t size, struct malloc_type *type,
|
void *malloc_domainset_exec(size_t size, struct malloc_type *type,
|
||||||
|
Loading…
Reference in New Issue
Block a user