env: Replace rte_malloc with spdk_zmalloc

Use the env library to perform all memory allocations
that previously called DPDK directly.

Change-Id: I6d33e85bde99796e0c85277d6d4880521c34f10d
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-08-17 13:35:18 -07:00
parent bfdc02ab48
commit 2224ff2162
27 changed files with 118 additions and 163 deletions

View File

@ -39,30 +39,12 @@
#include <rte_memzone.h> #include <rte_memzone.h>
#include <rte_eal.h> #include <rte_eal.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include <rte_malloc.h>
#include <rte_memory.h>
#include "spdk/event.h" #include "spdk/event.h"
#include "iscsi/iscsi.h" #include "iscsi/iscsi.h"
#include "spdk/log.h" #include "spdk/log.h"
#include "spdk/net.h" #include "spdk/net.h"
static void
spdk_iscsi_dump_memory_info(void)
{
struct rte_malloc_socket_stats stats;
int i;
for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
rte_malloc_get_socket_stats(i, &stats);
if (stats.heap_totalsz_bytes > 0)
fprintf(stderr, "Socket %d: Total memory %"PRIu64" MB,"
" Free memory %"PRIu64" MB\n",
i, stats.heap_totalsz_bytes >> 20,
stats.heap_freesz_bytes >> 20);
}
}
static void static void
spdk_sigusr1(int signo __attribute__((__unused__))) spdk_sigusr1(int signo __attribute__((__unused__)))
{ {
@ -106,9 +88,6 @@ spdk_startup(spdk_event_t event)
rte_memzone_dump(stdout); rte_memzone_dump(stdout);
fflush(stdout); fflush(stdout);
} }
/* Dump socket memory information */
spdk_iscsi_dump_memory_info();
} }
int int

View File

@ -37,7 +37,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_eal.h> #include <rte_eal.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include <rte_cycles.h> #include <rte_cycles.h>
@ -117,7 +116,7 @@ ioat_exit(void)
if (dev->ioat) { if (dev->ioat) {
spdk_ioat_detach(dev->ioat); spdk_ioat_detach(dev->ioat);
} }
rte_free(dev); spdk_free(dev);
} }
} }
@ -162,7 +161,7 @@ attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_ioat_chan *
{ {
struct ioat_device *dev; struct ioat_device *dev;
dev = rte_malloc(NULL, sizeof(*dev), 0); dev = spdk_zmalloc(sizeof(*dev), 0, NULL);
if (dev == NULL) { if (dev == NULL) {
printf("Failed to allocate device struct\n"); printf("Failed to allocate device struct\n");
return; return;

View File

@ -38,7 +38,6 @@
#include <string.h> #include <string.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include <rte_malloc.h>
#include <rte_eal.h> #include <rte_eal.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_mempool.h> #include <rte_mempool.h>
@ -367,7 +366,7 @@ init_src_buffer(void)
{ {
int i; int i;
g_src = rte_malloc(NULL, SRC_BUFFER_SIZE, 512); g_src = spdk_zmalloc(SRC_BUFFER_SIZE, 512, NULL);
if (g_src == NULL) { if (g_src == NULL) {
fprintf(stderr, "Allocate src buffer failed\n"); fprintf(stderr, "Allocate src buffer failed\n");
return -1; return -1;
@ -487,7 +486,7 @@ main(int argc, char **argv)
rc = dump_result(threads, RTE_MAX_LCORE); rc = dump_result(threads, RTE_MAX_LCORE);
cleanup: cleanup:
rte_free(g_src); spdk_free(g_src);
ioat_exit(); ioat_exit();
return rc; return rc;

View File

@ -39,7 +39,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_malloc.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include "spdk/nvme.h" #include "spdk/nvme.h"
@ -294,9 +293,9 @@ static void
task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned id) task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned id)
{ {
struct arb_task *task = __task; struct arb_task *task = __task;
task->buf = rte_malloc(NULL, g_arbitration.io_size_bytes, 0x200); task->buf = spdk_zmalloc(g_arbitration.io_size_bytes, 0x200, NULL);
if (task->buf == NULL) { if (task->buf == NULL) {
fprintf(stderr, "task->buf rte_malloc failed\n"); fprintf(stderr, "task->buf spdk_zmalloc failed\n");
exit(1); exit(1);
} }
} }
@ -438,7 +437,7 @@ cleanup(void)
} while (worker); } while (worker);
if (rte_mempool_get(task_pool, (void **)&task) == 0) { if (rte_mempool_get(task_pool, (void **)&task) == 0) {
rte_free(task->buf); spdk_free(task->buf);
} }
} }

View File

@ -39,7 +39,6 @@
#include "rte_config.h" #include "rte_config.h"
#include "rte_mempool.h" #include "rte_mempool.h"
#include "rte_malloc.h"
#include "rte_eal.h" #include "rte_eal.h"
#include "spdk/nvme.h" #include "spdk/nvme.h"
@ -219,13 +218,13 @@ static int spdk_fio_close(struct thread_data *td, struct fio_file *f)
static int spdk_fio_iomem_alloc(struct thread_data *td, size_t total_mem) static int spdk_fio_iomem_alloc(struct thread_data *td, size_t total_mem)
{ {
td->orig_buffer = rte_malloc(NULL, total_mem, NVME_IO_ALIGN); td->orig_buffer = spdk_zmalloc(total_mem, NVME_IO_ALIGN, NULL);
return td->orig_buffer == NULL; return td->orig_buffer == NULL;
} }
static void spdk_fio_iomem_free(struct thread_data *td) static void spdk_fio_iomem_free(struct thread_data *td)
{ {
rte_free(td->orig_buffer); spdk_free(td->orig_buffer);
} }
static int spdk_fio_io_u_init(struct thread_data *td, struct io_u *io_u) static int spdk_fio_io_u_init(struct thread_data *td, struct io_u *io_u)

View File

@ -37,7 +37,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_malloc.h>
#include "spdk/nvme.h" #include "spdk/nvme.h"
#include "spdk/env.h" #include "spdk/env.h"
@ -114,7 +113,7 @@ read_complete(void *arg, const struct spdk_nvme_cpl *completion)
* to exit its polling loop. * to exit its polling loop.
*/ */
printf("%s", sequence->buf); printf("%s", sequence->buf);
rte_free(sequence->buf); spdk_free(sequence->buf);
sequence->is_completed = 1; sequence->is_completed = 1;
} }
@ -130,8 +129,8 @@ write_complete(void *arg, const struct spdk_nvme_cpl *completion)
* the write I/O and allocate a new zeroed buffer for reading * the write I/O and allocate a new zeroed buffer for reading
* the data back from the NVMe namespace. * the data back from the NVMe namespace.
*/ */
rte_free(sequence->buf); spdk_free(sequence->buf);
sequence->buf = rte_zmalloc(NULL, 0x1000, 0x1000); sequence->buf = spdk_zmalloc(0x1000, 0x1000, NULL);
rc = spdk_nvme_ns_cmd_read(ns_entry->ns, ns_entry->qpair, sequence->buf, rc = spdk_nvme_ns_cmd_read(ns_entry->ns, ns_entry->qpair, sequence->buf,
0, /* LBA start */ 0, /* LBA start */
@ -171,11 +170,11 @@ hello_world(void)
} }
/* /*
* Use DPDK rte_zmalloc to allocate a 4KB zeroed buffer. This memory * Use spdk_zmalloc to allocate a 4KB zeroed buffer. This memory
* will be allocated from 2MB hugepages and will be pinned. These are * will be pinned, which is required for data buffers used for SPDK NVMe
* both requirements for data buffers used for SPDK NVMe I/O operations. * I/O operations.
*/ */
sequence.buf = rte_zmalloc(NULL, 0x1000, 0x1000); sequence.buf = spdk_zmalloc(0x1000, 0x1000, NULL);
sequence.is_completed = 0; sequence.is_completed = 0;
sequence.ns_entry = ns_entry; sequence.ns_entry = ns_entry;

View File

@ -41,7 +41,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_lcore.h> #include <rte_lcore.h>
@ -111,7 +110,7 @@ identify_common_ns_cb(void *cb_arg, const struct spdk_nvme_cpl *cpl)
if (cpl->status.sc != SPDK_NVME_SC_SUCCESS) { if (cpl->status.sc != SPDK_NVME_SC_SUCCESS) {
/* Identify Namespace for NSID = FFFFFFFFh is optional, so failure is not fatal. */ /* Identify Namespace for NSID = FFFFFFFFh is optional, so failure is not fatal. */
rte_free(dev->common_ns_data); spdk_free(dev->common_ns_data);
dev->common_ns_data = NULL; dev->common_ns_data = NULL;
} }
@ -133,7 +132,7 @@ attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr
/* Retrieve controller data */ /* Retrieve controller data */
dev->cdata = spdk_nvme_ctrlr_get_data(dev->ctrlr); dev->cdata = spdk_nvme_ctrlr_get_data(dev->ctrlr);
dev->common_ns_data = rte_zmalloc("common_ns_data", sizeof(struct spdk_nvme_ns_data), 4096); dev->common_ns_data = spdk_zmalloc(sizeof(struct spdk_nvme_ns_data), 4096, NULL);
if (dev->common_ns_data == NULL) { if (dev->common_ns_data == NULL) {
fprintf(stderr, "common_ns_data allocation failure\n"); fprintf(stderr, "common_ns_data allocation failure\n");
return; return;
@ -149,7 +148,7 @@ attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr
if (spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, dev->common_ns_data, if (spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, dev->common_ns_data,
sizeof(struct spdk_nvme_ns_data), identify_common_ns_cb, dev) != 0) { sizeof(struct spdk_nvme_ns_data), identify_common_ns_cb, dev) != 0) {
dev->outstanding_admin_cmds--; dev->outstanding_admin_cmds--;
rte_free(dev->common_ns_data); spdk_free(dev->common_ns_data);
dev->common_ns_data = NULL; dev->common_ns_data = NULL;
} }
@ -410,7 +409,7 @@ get_allocated_nsid(struct dev *dev)
struct spdk_nvme_ns_list *ns_list; struct spdk_nvme_ns_list *ns_list;
struct spdk_nvme_cmd cmd = {0}; struct spdk_nvme_cmd cmd = {0};
ns_list = rte_zmalloc("nvme_ns_list", sizeof(*ns_list), 4096); ns_list = spdk_zmalloc(sizeof(*ns_list), 4096, NULL);
if (ns_list == NULL) { if (ns_list == NULL) {
printf("Allocation error\n"); printf("Allocation error\n");
return 0; return 0;
@ -424,7 +423,7 @@ get_allocated_nsid(struct dev *dev)
if (spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, ns_list, sizeof(*ns_list), if (spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, ns_list, sizeof(*ns_list),
identify_allocated_ns_cb, dev)) { identify_allocated_ns_cb, dev)) {
printf("Identify command failed\n"); printf("Identify command failed\n");
rte_free(ns_list); spdk_free(ns_list);
return 0; return 0;
} }
@ -440,7 +439,7 @@ get_allocated_nsid(struct dev *dev)
printf("%u\n", ns_list->ns_list[i]); printf("%u\n", ns_list->ns_list[i]);
} }
rte_free(ns_list); spdk_free(ns_list);
printf("Please Input Namespace ID: \n"); printf("Please Input Namespace ID: \n");
if (!scanf("%u", &nsid)) { if (!scanf("%u", &nsid)) {
@ -457,8 +456,8 @@ ns_attach(struct dev *device, int attachment_op, int ctrlr_id, int ns_id)
int ret = 0; int ret = 0;
struct spdk_nvme_ctrlr_list *ctrlr_list; struct spdk_nvme_ctrlr_list *ctrlr_list;
ctrlr_list = rte_zmalloc("nvme controller list", sizeof(struct spdk_nvme_ctrlr_list), ctrlr_list = spdk_zmalloc(sizeof(struct spdk_nvme_ctrlr_list),
4096); 4096, NULL);
if (ctrlr_list == NULL) { if (ctrlr_list == NULL) {
printf("Allocation error (controller list)\n"); printf("Allocation error (controller list)\n");
exit(1); exit(1);
@ -477,7 +476,7 @@ ns_attach(struct dev *device, int attachment_op, int ctrlr_id, int ns_id)
fprintf(stdout, "ns attach: Failed\n"); fprintf(stdout, "ns attach: Failed\n");
} }
rte_free(ctrlr_list); spdk_free(ctrlr_list);
} }
static void static void
@ -487,7 +486,7 @@ ns_manage_add(struct dev *device, uint64_t ns_size, uint64_t ns_capacity, int ns
uint32_t nsid; uint32_t nsid;
struct spdk_nvme_ns_data *ndata; struct spdk_nvme_ns_data *ndata;
ndata = rte_zmalloc("nvme namespace data", sizeof(struct spdk_nvme_ns_data), 4096); ndata = spdk_zmalloc(sizeof(struct spdk_nvme_ns_data), 4096, NULL);
if (ndata == NULL) { if (ndata == NULL) {
printf("Allocation error (namespace data)\n"); printf("Allocation error (namespace data)\n");
exit(1); exit(1);
@ -508,7 +507,7 @@ ns_manage_add(struct dev *device, uint64_t ns_size, uint64_t ns_capacity, int ns
printf("Created namespace ID %u\n", nsid); printf("Created namespace ID %u\n", nsid);
} }
rte_free(ndata); spdk_free(ndata);
} }
static void static void
@ -849,7 +848,7 @@ update_firmware_image(void)
size = fw_stat.st_size; size = fw_stat.st_size;
fw_image = rte_zmalloc("firmware image", size, 4096); fw_image = spdk_zmalloc(size, 4096, NULL);
if (fw_image == NULL) { if (fw_image == NULL) {
printf("Allocation error\n"); printf("Allocation error\n");
close(fd); close(fd);
@ -859,7 +858,7 @@ update_firmware_image(void)
if (read(fd, fw_image, size) != ((ssize_t)(size))) { if (read(fd, fw_image, size) != ((ssize_t)(size))) {
printf("Read firmware image failed\n"); printf("Read firmware image failed\n");
close(fd); close(fd);
rte_free(fw_image); spdk_free(fw_image);
return; return;
} }
close(fd); close(fd);
@ -867,7 +866,7 @@ update_firmware_image(void)
printf("Please Input Slot(0 - 7): \n"); printf("Please Input Slot(0 - 7): \n");
if (!scanf("%d", &slot)) { if (!scanf("%d", &slot)) {
printf("Invalid Slot\n"); printf("Invalid Slot\n");
rte_free(fw_image); spdk_free(fw_image);
while (getchar() != '\n'); while (getchar() != '\n');
return; return;
} }
@ -878,7 +877,7 @@ update_firmware_image(void)
} else { } else {
printf("spdk_nvme_ctrlr_update_firmware success\n"); printf("spdk_nvme_ctrlr_update_firmware success\n");
} }
rte_free(fw_image); spdk_free(fw_image);
} }
int main(int argc, char **argv) int main(int argc, char **argv)

View File

@ -39,7 +39,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_malloc.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include "spdk/fd.h" #include "spdk/fd.h"
@ -259,8 +258,8 @@ register_ctrlr(struct spdk_nvme_ctrlr *ctrlr)
exit(1); exit(1);
} }
entry->latency_page = rte_zmalloc("nvme latency", sizeof(struct spdk_nvme_intel_rw_latency_page), entry->latency_page = spdk_zmalloc(sizeof(struct spdk_nvme_intel_rw_latency_page),
4096); 4096, NULL);
if (entry->latency_page == NULL) { if (entry->latency_page == NULL) {
printf("Allocation error (latency page)\n"); printf("Allocation error (latency page)\n");
exit(1); exit(1);
@ -388,9 +387,9 @@ aio_check_io(struct ns_worker_ctx *ns_ctx)
static void task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned id) static void task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned id)
{ {
struct perf_task *task = __task; struct perf_task *task = __task;
task->buf = rte_malloc(NULL, g_io_size_bytes, 0x200); task->buf = spdk_zmalloc(g_io_size_bytes, 0x200, NULL);
if (task->buf == NULL) { if (task->buf == NULL) {
fprintf(stderr, "task->buf rte_malloc failed\n"); fprintf(stderr, "task->buf spdk_zmalloc failed\n");
exit(1); exit(1);
} }
memset(task->buf, id % 8, g_io_size_bytes); memset(task->buf, id % 8, g_io_size_bytes);
@ -1008,7 +1007,7 @@ unregister_controllers(void)
while (entry) { while (entry) {
struct ctrlr_entry *next = entry->next; struct ctrlr_entry *next = entry->next;
rte_free(entry->latency_page); spdk_free(entry->latency_page);
if (g_latency_tracking_enable && if (g_latency_tracking_enable &&
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING)) spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING))
set_latency_tracking_feature(entry->ctrlr, false); set_latency_tracking_feature(entry->ctrlr, false);

View File

@ -40,7 +40,6 @@
#include <unistd.h> #include <unistd.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_ring.h> #include <rte_ring.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_version.h> #include <rte_version.h>

View File

@ -35,13 +35,13 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_memcpy.h> #include <rte_memcpy.h>
#include "blockdev_malloc.h" #include "blockdev_malloc.h"
#include "spdk/bdev.h" #include "spdk/bdev.h"
#include "spdk/conf.h" #include "spdk/conf.h"
#include "spdk/endian.h" #include "spdk/endian.h"
#include "spdk/env.h"
#include "spdk/log.h" #include "spdk/log.h"
#include "spdk/copy_engine.h" #include "spdk/copy_engine.h"
#include "spdk/io_channel.h" #include "spdk/io_channel.h"
@ -120,8 +120,8 @@ blockdev_malloc_destruct(struct spdk_bdev *bdev)
{ {
struct malloc_disk *malloc_disk = (struct malloc_disk *)bdev; struct malloc_disk *malloc_disk = (struct malloc_disk *)bdev;
blockdev_malloc_delete_from_list(malloc_disk); blockdev_malloc_delete_from_list(malloc_disk);
rte_free(malloc_disk->malloc_buf); spdk_free(malloc_disk->malloc_buf);
rte_free(malloc_disk); spdk_free(malloc_disk);
return 0; return 0;
} }
@ -369,25 +369,22 @@ struct malloc_disk *create_malloc_disk(uint64_t num_blocks, uint32_t block_size)
return NULL; return NULL;
} }
mdisk = rte_malloc(NULL, sizeof(*mdisk), 0); mdisk = spdk_zmalloc(sizeof(*mdisk), 0, NULL);
if (!mdisk) { if (!mdisk) {
perror("mdisk"); perror("mdisk");
return NULL; return NULL;
} }
memset(mdisk, 0, sizeof(*mdisk));
/* /*
* Allocate the large backend memory buffer using rte_malloc(), * Allocate the large backend memory buffer from pinned memory.
* so that we guarantee it is allocated from hugepage memory.
* *
* TODO: need to pass a hint so we know which socket to allocate * TODO: need to pass a hint so we know which socket to allocate
* from on multi-socket systems. * from on multi-socket systems.
*/ */
mdisk->malloc_buf = rte_zmalloc(NULL, num_blocks * block_size, 2 * 1024 * 1024); mdisk->malloc_buf = spdk_zmalloc(num_blocks * block_size, 2 * 1024 * 1024, NULL);
if (!mdisk->malloc_buf) { if (!mdisk->malloc_buf) {
SPDK_ERRLOG("rte_zmalloc failed\n"); SPDK_ERRLOG("spdk_zmalloc failed\n");
rte_free(mdisk); spdk_free(mdisk);
return NULL; return NULL;
} }
@ -414,8 +411,8 @@ struct malloc_disk *create_malloc_disk(uint64_t num_blocks, uint32_t block_size)
static void free_malloc_disk(struct malloc_disk *mdisk) static void free_malloc_disk(struct malloc_disk *mdisk)
{ {
rte_free(mdisk->malloc_buf); spdk_free(mdisk->malloc_buf);
rte_free(mdisk); spdk_free(mdisk);
} }
static int blockdev_malloc_initialize(void) static int blockdev_malloc_initialize(void)

View File

@ -44,7 +44,6 @@
#include <rte_ring.h> #include <rte_ring.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include <rte_malloc.h>
#include "spdk/conf.h" #include "spdk/conf.h"
#include "spdk/endian.h" #include "spdk/endian.h"

View File

@ -36,7 +36,6 @@
#include <errno.h> #include <errno.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_memcpy.h> #include <rte_memcpy.h>
#include <rte_lcore.h> #include <rte_lcore.h>
@ -140,7 +139,7 @@ copy_engine_ioat_exit(void)
TAILQ_REMOVE(&g_devices, dev, tailq); TAILQ_REMOVE(&g_devices, dev, tailq);
spdk_ioat_detach(dev->ioat); spdk_ioat_detach(dev->ioat);
ioat_free_device(dev); ioat_free_device(dev);
rte_free(dev); spdk_free(dev);
} }
return; return;
} }
@ -272,7 +271,7 @@ attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_ioat_chan *
{ {
struct ioat_device *dev; struct ioat_device *dev;
dev = rte_malloc(NULL, sizeof(*dev), 0); dev = spdk_zmalloc(sizeof(*dev), 0, NULL);
if (dev == NULL) { if (dev == NULL) {
SPDK_ERRLOG("Failed to allocate device struct\n"); SPDK_ERRLOG("Failed to allocate device struct\n");
return; return;

2
lib/env/env.c vendored
View File

@ -48,8 +48,10 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
void *buf = rte_malloc(NULL, size, align); void *buf = rte_malloc(NULL, size, align);
if (buf) { if (buf) {
memset(buf, 0, size); memset(buf, 0, size);
if (phys_addr) {
*phys_addr = rte_malloc_virt2phy(buf); *phys_addr = rte_malloc_virt2phy(buf);
} }
}
return buf; return buf;
} }

View File

@ -53,7 +53,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_common.h> #include <rte_common.h>
#include <rte_log.h> #include <rte_log.h>
#include <rte_memory.h>
#include <rte_memcpy.h> #include <rte_memcpy.h>
#include <rte_memzone.h> #include <rte_memzone.h>
#include <rte_tailq.h> #include <rte_tailq.h>
@ -68,7 +67,6 @@
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_string_fns.h> #include <rte_string_fns.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_malloc.h>
#include "spdk/endian.h" #include "spdk/endian.h"
#include "spdk/trace.h" #include "spdk/trace.h"

View File

@ -35,7 +35,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_common.h> #include <rte_common.h>
#include <rte_log.h> #include <rte_log.h>
#include <rte_memory.h>
#include <rte_memcpy.h> #include <rte_memcpy.h>
#include <rte_memzone.h> #include <rte_memzone.h>
#include <rte_tailq.h> #include <rte_tailq.h>
@ -50,7 +49,6 @@
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_string_fns.h> #include <rte_string_fns.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_malloc.h>
#include <rte_version.h> #include <rte_version.h>
#include <inttypes.h> #include <inttypes.h>
@ -63,7 +61,9 @@
#include "iscsi/acceptor.h" #include "iscsi/acceptor.h"
#include "iscsi/conn.h" #include "iscsi/conn.h"
#include "iscsi/task.h" #include "iscsi/task.h"
#include "spdk/event.h" #include "spdk/event.h"
#include "spdk/env.h"
#include "spdk/log.h" #include "spdk/log.h"
#define ISCSI_CONFIG_TMPL \ #define ISCSI_CONFIG_TMPL \
@ -613,7 +613,7 @@ spdk_iscsi_app_read_parameters(void)
g_spdk_iscsi.MaxSessions = MaxSessions; g_spdk_iscsi.MaxSessions = MaxSessions;
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "MaxSessions %d\n", g_spdk_iscsi.MaxSessions); SPDK_TRACELOG(SPDK_TRACE_DEBUG, "MaxSessions %d\n", g_spdk_iscsi.MaxSessions);
g_spdk_iscsi.session = rte_malloc(NULL, sizeof(void *) * g_spdk_iscsi.MaxSessions, 0); g_spdk_iscsi.session = spdk_zmalloc(sizeof(void *) * g_spdk_iscsi.MaxSessions, 0, NULL);
if (!g_spdk_iscsi.session) { if (!g_spdk_iscsi.session) {
perror("Unable to allocate session pointer array\n"); perror("Unable to allocate session pointer array\n");
return -1; return -1;

View File

@ -43,7 +43,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include <rte_malloc.h>
#include "nvmf_internal.h" #include "nvmf_internal.h"
#include "request.h" #include "request.h"
@ -202,9 +201,9 @@ spdk_nvmf_rdma_conn_destroy(struct spdk_nvmf_rdma_conn *rdma_conn)
} }
/* Free all memory */ /* Free all memory */
rte_free(rdma_conn->cmds); spdk_free(rdma_conn->cmds);
rte_free(rdma_conn->cpls); spdk_free(rdma_conn->cpls);
rte_free(rdma_conn->bufs); spdk_free(rdma_conn->bufs);
free(rdma_conn->reqs); free(rdma_conn->reqs);
free(rdma_conn); free(rdma_conn);
} }
@ -264,12 +263,12 @@ spdk_nvmf_rdma_conn_create(struct rdma_cm_id *id, struct ibv_comp_channel *chann
SPDK_TRACELOG(SPDK_TRACE_RDMA, "New RDMA Connection: %p\n", conn); SPDK_TRACELOG(SPDK_TRACE_RDMA, "New RDMA Connection: %p\n", conn);
rdma_conn->reqs = calloc(max_queue_depth, sizeof(*rdma_conn->reqs)); rdma_conn->reqs = calloc(max_queue_depth, sizeof(*rdma_conn->reqs));
rdma_conn->cmds = rte_calloc("nvmf_rdma_cmd", max_queue_depth, rdma_conn->cmds = spdk_zmalloc(max_queue_depth * sizeof(*rdma_conn->cmds),
sizeof(*rdma_conn->cmds), 0x1000); 0x1000, NULL);
rdma_conn->cpls = rte_calloc("nvmf_rdma_cpl", max_queue_depth, rdma_conn->cpls = spdk_zmalloc(max_queue_depth * sizeof(*rdma_conn->cpls),
sizeof(*rdma_conn->cpls), 0x1000); 0x1000, NULL);
rdma_conn->bufs = rte_calloc("nvmf_rdma_buf", max_queue_depth, rdma_conn->bufs = spdk_zmalloc(max_queue_depth * g_rdma.in_capsule_data_size,
g_rdma.in_capsule_data_size, 0x1000); 0x1000, NULL);
if (!rdma_conn->reqs || !rdma_conn->cmds || !rdma_conn->cpls || !rdma_conn->bufs) { if (!rdma_conn->reqs || !rdma_conn->cmds || !rdma_conn->cpls || !rdma_conn->bufs) {
SPDK_ERRLOG("Unable to allocate sufficient memory for RDMA queue.\n"); SPDK_ERRLOG("Unable to allocate sufficient memory for RDMA queue.\n");
spdk_nvmf_rdma_conn_destroy(rdma_conn); spdk_nvmf_rdma_conn_destroy(rdma_conn);
@ -984,8 +983,8 @@ spdk_nvmf_rdma_session_init(struct spdk_nvmf_session *session, struct spdk_nvmf_
/* TODO: Make the number of elements in this pool configurable. For now, one full queue /* TODO: Make the number of elements in this pool configurable. For now, one full queue
* worth seems reasonable. * worth seems reasonable.
*/ */
rdma_sess->buf = rte_calloc("large_buf_pool", g_rdma.max_queue_depth, g_rdma.max_io_size, rdma_sess->buf = spdk_zmalloc(g_rdma.max_queue_depth * g_rdma.max_io_size,
0x20000); 0x20000, NULL);
if (!rdma_sess->buf) { if (!rdma_sess->buf) {
SPDK_ERRLOG("Large buffer pool allocation failed (%d x %d)\n", SPDK_ERRLOG("Large buffer pool allocation failed (%d x %d)\n",
g_rdma.max_queue_depth, g_rdma.max_io_size); g_rdma.max_queue_depth, g_rdma.max_io_size);
@ -998,7 +997,7 @@ spdk_nvmf_rdma_session_init(struct spdk_nvmf_session *session, struct spdk_nvmf_
if (!rdma_sess->buf_mr) { if (!rdma_sess->buf_mr) {
SPDK_ERRLOG("Large buffer pool registration failed (%d x %d)\n", SPDK_ERRLOG("Large buffer pool registration failed (%d x %d)\n",
g_rdma.max_queue_depth, g_rdma.max_io_size); g_rdma.max_queue_depth, g_rdma.max_io_size);
rte_free(rdma_sess->buf); spdk_free(rdma_sess->buf);
free(rdma_sess); free(rdma_sess);
return -1; return -1;
} }
@ -1028,7 +1027,7 @@ spdk_nvmf_rdma_session_fini(struct spdk_nvmf_session *session)
} }
rdma_dereg_mr(rdma_sess->buf_mr); rdma_dereg_mr(rdma_sess->buf_mr);
rte_free(rdma_sess->buf); spdk_free(rdma_sess->buf);
free(rdma_sess); free(rdma_sess);
session->trctx = NULL; session->trctx = NULL;
} }

View File

@ -34,9 +34,7 @@
#include "scsi_internal.h" #include "scsi_internal.h"
#include "spdk/endian.h" #include "spdk/endian.h"
#include "spdk/env.h"
#include <rte_config.h>
#include <rte_malloc.h>
void void
spdk_scsi_task_put(struct spdk_scsi_task *task) spdk_scsi_task_put(struct spdk_scsi_task *task)
@ -62,7 +60,7 @@ spdk_scsi_task_put(struct spdk_scsi_task *task)
} }
spdk_bdev_free_io(bdev_io); spdk_bdev_free_io(bdev_io);
} else { } else {
rte_free(task->rbuf); spdk_free(task->rbuf);
} }
task->rbuf = NULL; task->rbuf = NULL;
@ -127,7 +125,7 @@ spdk_scsi_task_alloc_data(struct spdk_scsi_task *task, uint32_t alloc_len,
task->alloc_len = alloc_len; task->alloc_len = alloc_len;
if (task->rbuf == NULL) { if (task->rbuf == NULL) {
task->rbuf = rte_malloc(NULL, alloc_len, 0); task->rbuf = spdk_zmalloc(alloc_len, 0, NULL);
} }
*data = task->rbuf; *data = task->rbuf;
memset(task->rbuf, 0, task->alloc_len); memset(task->rbuf, 0, task->alloc_len);

View File

@ -38,11 +38,11 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_eal.h> #include <rte_eal.h>
#include <rte_malloc.h>
#include <rte_ring.h> #include <rte_ring.h>
#include "spdk/bdev.h" #include "spdk/bdev.h"
#include "spdk/copy_engine.h" #include "spdk/copy_engine.h"
#include "spdk/env.h"
#include "spdk/log.h" #include "spdk/log.h"
#include "CUnit/Basic.h" #include "CUnit/Basic.h"
@ -93,7 +93,7 @@ static enum spdk_bdev_io_status completion_status_per_io;
static void static void
initialize_buffer(char **buf, int pattern, int size) initialize_buffer(char **buf, int pattern, int size)
{ {
*buf = rte_malloc(NULL, size, 0x1000); *buf = spdk_zmalloc(size, 0x1000, NULL);
memset(*buf, pattern, size); memset(*buf, pattern, size);
} }
@ -174,8 +174,8 @@ blockdev_write_read_data_match(char *rx_buf, char *tx_buf, int data_length)
int rc; int rc;
rc = memcmp(rx_buf, tx_buf, data_length); rc = memcmp(rx_buf, tx_buf, data_length);
rte_free(rx_buf); spdk_free(rx_buf);
rte_free(tx_buf); spdk_free(tx_buf);
return rc; return rc;
} }

View File

@ -42,13 +42,13 @@
#include <rte_eal.h> #include <rte_eal.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_malloc.h>
#include <rte_ring.h> #include <rte_ring.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include "spdk/bdev.h" #include "spdk/bdev.h"
#include "spdk/copy_engine.h" #include "spdk/copy_engine.h"
#include "spdk/endian.h" #include "spdk/endian.h"
#include "spdk/env.h"
#include "spdk/event.h" #include "spdk/event.h"
#include "spdk/log.h" #include "spdk/log.h"
#include "spdk/io_channel.h" #include "spdk/io_channel.h"
@ -288,7 +288,7 @@ task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned id)
{ {
struct bdevperf_task *task = __task; struct bdevperf_task *task = __task;
task->buf = rte_malloc(NULL, g_io_size, g_min_alignment); task->buf = spdk_zmalloc(g_io_size, g_min_alignment, NULL);
} }
static __thread unsigned int seed = 0; static __thread unsigned int seed = 0;

View File

@ -38,7 +38,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_eal.h> #include <rte_eal.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_malloc.h>
#include "spdk/env.h" #include "spdk/env.h"
@ -96,18 +95,18 @@ vtophys_positive_test(void)
int rc = 0; int rc = 0;
for (i = 0; i < 31; i++) { for (i = 0; i < 31; i++) {
p = rte_malloc("vtophys_test", size, 512); p = spdk_zmalloc(size, 512, NULL);
if (p == NULL) if (p == NULL)
continue; continue;
if (spdk_vtophys(p) == SPDK_VTOPHYS_ERROR) { if (spdk_vtophys(p) == SPDK_VTOPHYS_ERROR) {
rc = -1; rc = -1;
printf("Err: VA=%p is not mapped to a huge_page,\n", p); printf("Err: VA=%p is not mapped to a huge_page,\n", p);
rte_free(p); spdk_free(p);
break; break;
} }
rte_free(p); spdk_free(p);
size = size << 1; size = size << 1;
} }

View File

@ -41,7 +41,6 @@
#include <rte_eal.h> #include <rte_eal.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_malloc.h>
#include <rte_ring.h> #include <rte_ring.h>
#include <rte_lcore.h> #include <rte_lcore.h>

View File

@ -34,7 +34,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_lcore.h> #include <rte_lcore.h>
@ -158,7 +157,7 @@ cleanup(void)
foreach_dev(dev) { foreach_dev(dev) {
if (dev->health_page) { if (dev->health_page) {
rte_free(dev->health_page); spdk_free(dev->health_page);
} }
} }
} }
@ -215,7 +214,7 @@ attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr
printf("Attached to %s\n", dev->name); printf("Attached to %s\n", dev->name);
dev->health_page = rte_zmalloc("nvme health", sizeof(*dev->health_page), 4096); dev->health_page = spdk_zmalloc(sizeof(*dev->health_page), 4096, NULL);
if (dev->health_page == NULL) { if (dev->health_page == NULL) {
printf("Allocation error (health page)\n"); printf("Allocation error (health page)\n");
failed = 1; failed = 1;

View File

@ -40,7 +40,6 @@
#include <string.h> #include <string.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_lcore.h> #include <rte_lcore.h>
@ -181,7 +180,7 @@ static uint32_t dp_guard_check_extended_lba_test(struct spdk_nvme_ns *ns, struct
sector_size = spdk_nvme_ns_get_sector_size(ns); sector_size = spdk_nvme_ns_get_sector_size(ns);
md_size = spdk_nvme_ns_get_md_size(ns); md_size = spdk_nvme_ns_get_md_size(ns);
req->contig = rte_zmalloc(NULL, (sector_size + md_size) * req->lba_count, 0x1000); req->contig = spdk_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL);
if (!req->contig) if (!req->contig)
return 0; return 0;
@ -217,7 +216,7 @@ static uint32_t dp_with_pract_test(struct spdk_nvme_ns *ns, struct io_request *r
sector_size = spdk_nvme_ns_get_sector_size(ns); sector_size = spdk_nvme_ns_get_sector_size(ns);
/* No additional metadata buffer provided */ /* No additional metadata buffer provided */
req->contig = rte_zmalloc(NULL, sector_size * req->lba_count, 0x1000); req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
if (!req->contig) if (!req->contig)
return 0; return 0;
@ -264,7 +263,7 @@ static uint32_t dp_without_pract_extended_lba_test(struct spdk_nvme_ns *ns, stru
sector_size = spdk_nvme_ns_get_sector_size(ns); sector_size = spdk_nvme_ns_get_sector_size(ns);
md_size = spdk_nvme_ns_get_md_size(ns); md_size = spdk_nvme_ns_get_md_size(ns);
req->contig = rte_zmalloc(NULL, (sector_size + md_size) * req->lba_count, 0x1000); req->contig = spdk_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL);
if (!req->contig) if (!req->contig)
return 0; return 0;
@ -298,7 +297,7 @@ static uint32_t dp_without_flags_extended_lba_test(struct spdk_nvme_ns *ns, stru
sector_size = spdk_nvme_ns_get_sector_size(ns); sector_size = spdk_nvme_ns_get_sector_size(ns);
md_size = spdk_nvme_ns_get_md_size(ns); md_size = spdk_nvme_ns_get_md_size(ns);
req->contig = rte_zmalloc(NULL, (sector_size + md_size) * req->lba_count, 0x1000); req->contig = spdk_zmalloc((sector_size + md_size) * req->lba_count, 0x1000, NULL);
if (!req->contig) if (!req->contig)
return 0; return 0;
@ -332,13 +331,13 @@ static uint32_t dp_without_pract_separate_meta_test(struct spdk_nvme_ns *ns, str
sector_size = spdk_nvme_ns_get_sector_size(ns); sector_size = spdk_nvme_ns_get_sector_size(ns);
md_size = spdk_nvme_ns_get_md_size(ns); md_size = spdk_nvme_ns_get_md_size(ns);
req->contig = rte_zmalloc(NULL, sector_size * req->lba_count, 0x1000); req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
if (!req->contig) if (!req->contig)
return 0; return 0;
req->metadata = rte_zmalloc(NULL, md_size * req->lba_count, 0x1000); req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL);
if (!req->metadata) { if (!req->metadata) {
rte_free(req->contig); spdk_free(req->contig);
return 0; return 0;
} }
@ -375,13 +374,13 @@ static uint32_t dp_without_pract_separate_meta_apptag_test(struct spdk_nvme_ns *
sector_size = spdk_nvme_ns_get_sector_size(ns); sector_size = spdk_nvme_ns_get_sector_size(ns);
md_size = spdk_nvme_ns_get_md_size(ns); md_size = spdk_nvme_ns_get_md_size(ns);
req->contig = rte_zmalloc(NULL, sector_size * req->lba_count, 0x1000); req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
if (!req->contig) if (!req->contig)
return 0; return 0;
req->metadata = rte_zmalloc(NULL, md_size * req->lba_count, 0x1000); req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL);
if (!req->metadata) { if (!req->metadata) {
rte_free(req->contig); spdk_free(req->contig);
return 0; return 0;
} }
@ -416,13 +415,13 @@ static uint32_t dp_without_flags_separate_meta_test(struct spdk_nvme_ns *ns, str
sector_size = spdk_nvme_ns_get_sector_size(ns); sector_size = spdk_nvme_ns_get_sector_size(ns);
md_size = spdk_nvme_ns_get_md_size(ns); md_size = spdk_nvme_ns_get_md_size(ns);
req->contig = rte_zmalloc(NULL, sector_size * req->lba_count, 0x1000); req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL);
if (!req->contig) if (!req->contig)
return 0; return 0;
req->metadata = rte_zmalloc(NULL, md_size * req->lba_count, 0x1000); req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL);
if (!req->metadata) { if (!req->metadata) {
rte_free(req->contig); spdk_free(req->contig);
return 0; return 0;
} }
@ -444,12 +443,12 @@ free_req(struct io_request *req)
} }
if (req->contig) if (req->contig)
rte_free(req->contig); spdk_free(req->contig);
if (req->metadata) if (req->metadata)
rte_free(req->metadata); spdk_free(req->metadata);
rte_free(req); spdk_free(req);
} }
static int static int
@ -506,7 +505,7 @@ write_read_e2e_dp_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, con
return 0; return 0;
} }
req = rte_zmalloc(NULL, sizeof(*req), 0); req = spdk_zmalloc(sizeof(*req), 0, NULL);
if (!req) { if (!req) {
fprintf(stderr, "Allocate request failed\n"); fprintf(stderr, "Allocate request failed\n");
return 0; return 0;

View File

@ -39,7 +39,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_malloc.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include "spdk/fd.h" #include "spdk/fd.h"
@ -601,15 +600,15 @@ int main(int argc, char **argv)
return 1; return 1;
} }
g_task = rte_zmalloc("task", sizeof(struct perf_task), 0); g_task = spdk_zmalloc(sizeof(struct perf_task), 0, NULL);
if (g_task == NULL) { if (g_task == NULL) {
fprintf(stderr, "g_task alloc failed\n"); fprintf(stderr, "g_task alloc failed\n");
exit(1); exit(1);
} }
g_task->buf = rte_malloc(NULL, g_io_size_bytes, 0x1000); g_task->buf = spdk_zmalloc(g_io_size_bytes, 0x1000, NULL);
if (g_task->buf == NULL) { if (g_task->buf == NULL) {
fprintf(stderr, "g_task->buf rte_malloc failed\n"); fprintf(stderr, "g_task->buf spdk_zmalloc failed\n");
exit(1); exit(1);
} }

View File

@ -39,7 +39,6 @@
#include <rte_config.h> #include <rte_config.h>
#include <rte_cycles.h> #include <rte_cycles.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_malloc.h>
#include <rte_lcore.h> #include <rte_lcore.h>
#include "spdk/nvme.h" #include "spdk/nvme.h"
@ -156,9 +155,9 @@ static void task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned
{ {
struct reset_task *task = __task; struct reset_task *task = __task;
task->buf = rte_malloc(NULL, g_io_size_bytes, 0x200); task->buf = spdk_zmalloc(g_io_size_bytes, 0x200, NULL);
if (task->buf == NULL) { if (task->buf == NULL) {
fprintf(stderr, "task->buf rte_malloc failed\n"); fprintf(stderr, "task->buf spdk_zmalloc failed\n");
exit(1); exit(1);
} }
} }

View File

@ -36,7 +36,6 @@
#include <string.h> #include <string.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_lcore.h> #include <rte_lcore.h>
@ -136,7 +135,7 @@ static void build_io_request_0(struct io_request *req)
{ {
req->nseg = 1; req->nseg = 1;
req->iovs[0].base = rte_zmalloc(NULL, 0x800, 4); req->iovs[0].base = spdk_zmalloc(0x800, 4, NULL);
req->iovs[0].len = 0x800; req->iovs[0].len = 0x800;
} }
@ -145,7 +144,7 @@ static void build_io_request_1(struct io_request *req)
req->nseg = 1; req->nseg = 1;
/* 512B for 1st sge */ /* 512B for 1st sge */
req->iovs[0].base = rte_zmalloc(NULL, 0x200, 0x200); req->iovs[0].base = spdk_zmalloc(0x200, 0x200, NULL);
req->iovs[0].len = 0x200; req->iovs[0].len = 0x200;
} }
@ -154,7 +153,7 @@ static void build_io_request_2(struct io_request *req)
req->nseg = 1; req->nseg = 1;
/* 256KB for 1st sge */ /* 256KB for 1st sge */
req->iovs[0].base = rte_zmalloc(NULL, 0x40000, 0x1000); req->iovs[0].base = spdk_zmalloc(0x40000, 0x1000, NULL);
req->iovs[0].len = 0x40000; req->iovs[0].len = 0x40000;
} }
@ -164,16 +163,16 @@ static void build_io_request_3(struct io_request *req)
/* 2KB for 1st sge, make sure the iov address start at 0x800 boundary, /* 2KB for 1st sge, make sure the iov address start at 0x800 boundary,
* and end with 0x1000 boundary */ * and end with 0x1000 boundary */
req->iovs[0].base = rte_zmalloc(NULL, 0x1000, 0x1000); req->iovs[0].base = spdk_zmalloc(0x1000, 0x1000, NULL);
req->iovs[0].offset = 0x800; req->iovs[0].offset = 0x800;
req->iovs[0].len = 0x800; req->iovs[0].len = 0x800;
/* 4KB for 2th sge */ /* 4KB for 2th sge */
req->iovs[1].base = rte_zmalloc(NULL, 0x1000, 0x1000); req->iovs[1].base = spdk_zmalloc(0x1000, 0x1000, NULL);
req->iovs[1].len = 0x1000; req->iovs[1].len = 0x1000;
/* 12KB for 3th sge */ /* 12KB for 3th sge */
req->iovs[2].base = rte_zmalloc(NULL, 0x3000, 0x1000); req->iovs[2].base = spdk_zmalloc(0x3000, 0x1000, NULL);
req->iovs[2].len = 0x3000; req->iovs[2].len = 0x3000;
} }
@ -184,12 +183,12 @@ static void build_io_request_4(struct io_request *req)
req->nseg = 32; req->nseg = 32;
/* 4KB for 1st sge */ /* 4KB for 1st sge */
req->iovs[0].base = rte_zmalloc(NULL, 0x1000, 0x1000); req->iovs[0].base = spdk_zmalloc(0x1000, 0x1000, NULL);
req->iovs[0].len = 0x1000; req->iovs[0].len = 0x1000;
/* 8KB for the rest 31 sge */ /* 8KB for the rest 31 sge */
for (i = 1; i < req->nseg; i++) { for (i = 1; i < req->nseg; i++) {
req->iovs[i].base = rte_zmalloc(NULL, 0x2000, 0x1000); req->iovs[i].base = spdk_zmalloc(0x2000, 0x1000, NULL);
req->iovs[i].len = 0x2000; req->iovs[i].len = 0x2000;
} }
} }
@ -199,7 +198,7 @@ static void build_io_request_5(struct io_request *req)
req->nseg = 1; req->nseg = 1;
/* 8KB for 1st sge */ /* 8KB for 1st sge */
req->iovs[0].base = rte_zmalloc(NULL, 0x2000, 0x1000); req->iovs[0].base = spdk_zmalloc(0x2000, 0x1000, NULL);
req->iovs[0].len = 0x2000; req->iovs[0].len = 0x2000;
} }
@ -208,11 +207,11 @@ static void build_io_request_6(struct io_request *req)
req->nseg = 2; req->nseg = 2;
/* 4KB for 1st sge */ /* 4KB for 1st sge */
req->iovs[0].base = rte_zmalloc(NULL, 0x1000, 0x1000); req->iovs[0].base = spdk_zmalloc(0x1000, 0x1000, NULL);
req->iovs[0].len = 0x1000; req->iovs[0].len = 0x1000;
/* 4KB for 2st sge */ /* 4KB for 2st sge */
req->iovs[1].base = rte_zmalloc(NULL, 0x1000, 0x1000); req->iovs[1].base = spdk_zmalloc(0x1000, 0x1000, NULL);
req->iovs[1].len = 0x1000; req->iovs[1].len = 0x1000;
} }
@ -228,10 +227,10 @@ free_req(struct io_request *req)
} }
for (i = 0; i < req->nseg; i++) { for (i = 0; i < req->nseg; i++) {
rte_free(req->iovs[i].base); spdk_free(req->iovs[i].base);
} }
rte_free(req); spdk_free(req);
} }
static int static int
@ -258,7 +257,7 @@ writev_readv_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, const ch
return 0; return 0;
} }
req = rte_zmalloc(NULL, sizeof(*req), 0); req = spdk_zmalloc(sizeof(*req), 0, NULL);
if (!req) { if (!req) {
fprintf(stderr, "Allocate request failed\n"); fprintf(stderr, "Allocate request failed\n");
return 0; return 0;
@ -271,7 +270,7 @@ writev_readv_tests(struct dev *dev, nvme_build_io_req_fn_t build_io_fn, const ch
for (i = 0; i < req->nseg; i++) { for (i = 0; i < req->nseg; i++) {
struct sgl_element *sge = &req->iovs[i]; struct sgl_element *sge = &req->iovs[i];
sge->phys_addr = rte_malloc_virt2phy(sge->base) + sge->offset; sge->phys_addr = spdk_vtophys(sge->base) + sge->offset;
len += sge->len; len += sge->len;
} }

View File

@ -37,7 +37,6 @@
#include <stdio.h> #include <stdio.h>
#include <rte_config.h> #include <rte_config.h>
#include <rte_malloc.h>
#include <rte_mempool.h> #include <rte_mempool.h>
#include <rte_lcore.h> #include <rte_lcore.h>