Commit 2224ff21 authored by Ben Walker's avatar Ben Walker
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
parent bfdc02ab
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -39,30 +39,12 @@
#include <rte_memzone.h>
#include <rte_eal.h>
#include <rte_lcore.h>
#include <rte_malloc.h>
#include <rte_memory.h>

#include "spdk/event.h"
#include "iscsi/iscsi.h"
#include "spdk/log.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
spdk_sigusr1(int signo __attribute__((__unused__)))
{
@@ -106,9 +88,6 @@ spdk_startup(spdk_event_t event)
		rte_memzone_dump(stdout);
		fflush(stdout);
	}

	/* Dump socket memory information */
	spdk_iscsi_dump_memory_info();
}

int
+2 −3
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#include <stdbool.h>
#include <string.h>
#include <rte_config.h>
#include <rte_malloc.h>
#include <rte_eal.h>
#include <rte_lcore.h>
#include <rte_cycles.h>
@@ -117,7 +116,7 @@ ioat_exit(void)
		if (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;

	dev = rte_malloc(NULL, sizeof(*dev), 0);
	dev = spdk_zmalloc(sizeof(*dev), 0, NULL);
	if (dev == NULL) {
		printf("Failed to allocate device struct\n");
		return;
+2 −3
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@
#include <string.h>
#include <rte_config.h>
#include <rte_lcore.h>
#include <rte_malloc.h>
#include <rte_eal.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
@@ -367,7 +366,7 @@ init_src_buffer(void)
{
	int i;

	g_src = rte_malloc(NULL, SRC_BUFFER_SIZE, 512);
	g_src = spdk_zmalloc(SRC_BUFFER_SIZE, 512, NULL);
	if (g_src == NULL) {
		fprintf(stderr, "Allocate src buffer failed\n");
		return -1;
@@ -487,7 +486,7 @@ main(int argc, char **argv)
	rc = dump_result(threads, RTE_MAX_LCORE);

cleanup:
	rte_free(g_src);
	spdk_free(g_src);
	ioat_exit();

	return rc;
+3 −4
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include <rte_malloc.h>
#include <rte_lcore.h>

#include "spdk/nvme.h"
@@ -294,9 +293,9 @@ static void
task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned id)
{
	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) {
		fprintf(stderr, "task->buf rte_malloc failed\n");
		fprintf(stderr, "task->buf spdk_zmalloc failed\n");
		exit(1);
	}
}
@@ -438,7 +437,7 @@ cleanup(void)
	} while (worker);

	if (rte_mempool_get(task_pool, (void **)&task) == 0) {
		rte_free(task->buf);
		spdk_free(task->buf);
	}

}
+2 −3
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@

#include "rte_config.h"
#include "rte_mempool.h"
#include "rte_malloc.h"
#include "rte_eal.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)
{
	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;
}

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)
Loading