env: Adding socket variants for malloc and zmalloc
Signed-off-by: Vishal Verma <vishal4.verma@intel.com> Change-Id: I2399842cf7bb80aefb6c511e167157502ba9018a
This commit is contained in:
parent
e48e569d83
commit
578c0d550d
@ -80,12 +80,24 @@ void spdk_env_init(const struct spdk_env_opts *opts);
|
||||
*/
|
||||
void *spdk_malloc(size_t size, size_t align, uint64_t *phys_addr);
|
||||
|
||||
/**
|
||||
* Allocate a pinned, physically contiguous memory buffer with the
|
||||
* given size, alignment and socket id.
|
||||
*/
|
||||
void *spdk_malloc_socket(size_t size, size_t align, uint64_t *phys_addr, int socket_id);
|
||||
|
||||
/**
|
||||
* Allocate a pinned, physically contiguous memory buffer with the
|
||||
* given size and alignment. The buffer will be zeroed.
|
||||
*/
|
||||
void *spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr);
|
||||
|
||||
/**
|
||||
* Allocate a pinned, physically contiguous memory buffer with the
|
||||
* given size, alignment and socket id. The buffer will be zeroed.
|
||||
*/
|
||||
void *spdk_zmalloc_socket(size_t size, size_t align, uint64_t *phys_addr, int socket_id);
|
||||
|
||||
/**
|
||||
* Resize the allocated and pinned memory buffer with the given
|
||||
* new size and alignment. Existing contents are preserved.
|
||||
|
@ -44,9 +44,9 @@
|
||||
#include <rte_version.h>
|
||||
|
||||
void *
|
||||
spdk_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
spdk_malloc_socket(size_t size, size_t align, uint64_t *phys_addr, int socket_id)
|
||||
{
|
||||
void *buf = rte_malloc(NULL, size, align);
|
||||
void *buf = rte_malloc_socket(NULL, size, align, socket_id);
|
||||
if (buf && phys_addr) {
|
||||
*phys_addr = rte_malloc_virt2phy(buf);
|
||||
}
|
||||
@ -54,15 +54,27 @@ spdk_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
spdk_zmalloc_socket(size_t size, size_t align, uint64_t *phys_addr, int socket_id)
|
||||
{
|
||||
void *buf = spdk_malloc(size, align, phys_addr);
|
||||
void *buf = spdk_malloc_socket(size, align, phys_addr, socket_id);
|
||||
if (buf) {
|
||||
memset(buf, 0, size);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
return spdk_malloc_socket(size, align, phys_addr, SPDK_ENV_SOCKET_ID_ANY);
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
return spdk_zmalloc_socket(size, align, phys_addr, SPDK_ENV_SOCKET_ID_ANY);
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
|
@ -62,6 +62,18 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||
return buf;
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_malloc_socket(size_t size, size_t align, uint64_t *phys_addr, int socket_id)
|
||||
{
|
||||
return spdk_malloc(size, align, phys_addr);
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_zmalloc_socket(size_t size, size_t align, uint64_t *phys_addr, int socket_id)
|
||||
{
|
||||
return spdk_zmalloc(size, align, phys_addr);
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_realloc(void *buf, size_t size, size_t align, uint64_t *phys_addr)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user