env: Convert some rte_mempools to spdk_mempools

This converts some, but not all, usage of rte_mempool
to spdk_mempool. The remaining rte_mempools use features
we elected not to expose through spdk_mempool such as
constructors, so that will need to be revisited.

Change-Id: I6528809a864ab466b8d19431789bf0f976b648b6
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-09-30 14:14:18 -07:00 committed by Daniel Verkamp
parent cc402a588e
commit 7f5b671db7
18 changed files with 51 additions and 58 deletions

View File

@ -40,7 +40,7 @@
#include <rte_config.h>
#include <rte_memzone.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "nvmf_tgt.h"

View File

@ -39,10 +39,10 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_lcore.h>
#include <rte_mempool.h>
#include "spdk/ioat.h"
#include "spdk/env.h"
#include "spdk/queue.h"
#include "spdk/string.h"
struct user_config {
@ -70,8 +70,8 @@ struct thread_entry {
uint64_t current_queue_depth;
unsigned lcore_id;
bool is_draining;
struct rte_mempool *data_pool;
struct rte_mempool *task_pool;
struct spdk_mempool *data_pool;
struct spdk_mempool *task_pool;
};
struct ioat_task {
@ -134,9 +134,9 @@ ioat_done(void *cb_arg)
thread_entry->current_queue_depth--;
if (thread_entry->is_draining) {
rte_mempool_put(thread_entry->data_pool, ioat_task->src);
rte_mempool_put(thread_entry->data_pool, ioat_task->dst);
rte_mempool_put(thread_entry->task_pool, ioat_task);
spdk_mempool_put(thread_entry->data_pool, ioat_task->src);
spdk_mempool_put(thread_entry->data_pool, ioat_task->dst);
spdk_mempool_put(thread_entry->task_pool, ioat_task);
} else {
submit_single_xfer(thread_entry, ioat_task, ioat_task->dst, ioat_task->src);
}
@ -264,9 +264,9 @@ submit_xfers(struct thread_entry *thread_entry, uint64_t queue_depth)
void *src = NULL, *dst = NULL;
struct ioat_task *ioat_task = NULL;
rte_mempool_get(thread_entry->data_pool, &src);
rte_mempool_get(thread_entry->data_pool, &dst);
rte_mempool_get(thread_entry->task_pool, (void **)&ioat_task);
src = spdk_mempool_get(thread_entry->data_pool);
dst = spdk_mempool_get(thread_entry->data_pool);
ioat_task = spdk_mempool_get(thread_entry->task_pool);
submit_single_xfer(thread_entry, ioat_task, dst, src);
}
@ -287,11 +287,8 @@ work_fn(void *arg)
snprintf(buf_pool_name, sizeof(buf_pool_name), "buf_pool_%d", rte_lcore_id());
snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", rte_lcore_id());
t->data_pool = rte_mempool_create(buf_pool_name, 512, g_user_config.xfer_size_bytes, 0, 0, NULL,
NULL,
NULL, NULL, SOCKET_ID_ANY, 0);
t->task_pool = rte_mempool_create(task_pool_name, 512, sizeof(struct ioat_task), 0, 0, NULL, NULL,
NULL, NULL, SOCKET_ID_ANY, 0);
t->data_pool = spdk_mempool_create(buf_pool_name, 512, g_user_config.xfer_size_bytes, -1);
t->task_pool = spdk_mempool_create(task_pool_name, 512, sizeof(struct ioat_task), -1);
if (!t->data_pool || !t->task_pool) {
fprintf(stderr, "Could not allocate buffer pool.\n");
return 1;

View File

@ -39,10 +39,10 @@
#include <rte_config.h>
#include <rte_lcore.h>
#include <rte_eal.h>
#include <rte_mempool.h>
#include "spdk/ioat.h"
#include "spdk/env.h"
#include "spdk/queue.h"
#include "spdk/string.h"
#define SRC_BUFFER_SIZE (512*1024)
@ -77,8 +77,8 @@ struct thread_entry {
uint64_t current_queue_depth;
unsigned lcore_id;
bool is_draining;
struct rte_mempool *data_pool;
struct rte_mempool *task_pool;
struct spdk_mempool *data_pool;
struct spdk_mempool *task_pool;
};
struct ioat_task {
@ -190,8 +190,8 @@ ioat_done(void *cb_arg)
thread_entry->current_queue_depth--;
if (thread_entry->is_draining) {
rte_mempool_put(thread_entry->data_pool, ioat_task->buffer);
rte_mempool_put(thread_entry->task_pool, ioat_task);
spdk_mempool_put(thread_entry->data_pool, ioat_task->buffer);
spdk_mempool_put(thread_entry->task_pool, ioat_task);
} else {
prepare_ioat_task(thread_entry, ioat_task);
submit_single_xfer(ioat_task);
@ -308,8 +308,8 @@ submit_xfers(struct thread_entry *thread_entry, uint64_t queue_depth)
{
while (queue_depth-- > 0) {
struct ioat_task *ioat_task = NULL;
rte_mempool_get(thread_entry->task_pool, (void **)&ioat_task);
rte_mempool_get(thread_entry->data_pool, &(ioat_task->buffer));
ioat_task = spdk_mempool_get(thread_entry->task_pool);
ioat_task->buffer = spdk_mempool_get(thread_entry->data_pool);
ioat_task->type = IOAT_COPY_TYPE;
if (spdk_ioat_get_dma_capabilities(thread_entry->chan) & SPDK_IOAT_ENGINE_FILL_SUPPORTED) {
@ -336,12 +336,9 @@ work_fn(void *arg)
snprintf(buf_pool_name, sizeof(buf_pool_name), "buf_pool_%d", rte_lcore_id());
snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", rte_lcore_id());
t->data_pool = rte_mempool_create(buf_pool_name, g_user_config.queue_depth, SRC_BUFFER_SIZE, 0, 0,
NULL, NULL,
NULL, NULL, SOCKET_ID_ANY, 0);
t->task_pool = rte_mempool_create(task_pool_name, g_user_config.queue_depth,
sizeof(struct ioat_task), 0, 0, NULL, NULL,
NULL, NULL, SOCKET_ID_ANY, 0);
t->data_pool = spdk_mempool_create(buf_pool_name, g_user_config.queue_depth, SRC_BUFFER_SIZE, -1);
t->task_pool = spdk_mempool_create(task_pool_name, g_user_config.queue_depth,
sizeof(struct ioat_task), -1);
if (!t->data_pool || !t->task_pool) {
fprintf(stderr, "Could not allocate buffer pool.\n");
return 1;

View File

@ -38,7 +38,6 @@
#include <pthread.h>
#include "rte_config.h"
#include "rte_mempool.h"
#include "rte_eal.h"
#include "spdk/nvme.h"

View File

@ -32,11 +32,12 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_eal.h>
#include "spdk/nvme.h"
#include "spdk/env.h"

View File

@ -31,11 +31,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "spdk/nvme.h"

View File

@ -31,8 +31,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include <stdlib.h>
@ -41,7 +43,6 @@
#include <fcntl.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "spdk/nvme.h"

View File

@ -32,11 +32,12 @@
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "spdk/nvme.h"

View File

@ -42,7 +42,6 @@
#include <rte_config.h>
#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "spdk/conf.h"

View File

@ -48,7 +48,6 @@
#endif
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_ring.h>
#include "reactor.h"
@ -126,7 +125,7 @@ static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_INVALID;
static void spdk_reactor_construct(struct spdk_reactor *w, uint32_t lcore,
uint64_t max_delay_us);
struct rte_mempool *g_spdk_event_mempool[SPDK_MAX_SOCKET];
struct spdk_mempool *g_spdk_event_mempool[SPDK_MAX_SOCKET];
/** \file
@ -145,12 +144,11 @@ spdk_event_allocate(uint32_t lcore, spdk_event_fn fn, void *arg1, void *arg2,
spdk_event_t next)
{
struct spdk_event *event = NULL;
int rc;
uint8_t socket_id = rte_lcore_to_socket_id(lcore);
assert(socket_id < SPDK_MAX_SOCKET);
rc = rte_mempool_get(g_spdk_event_mempool[socket_id], (void **)&event);
if (rc != 0 || event == NULL) {
event = spdk_mempool_get(g_spdk_event_mempool[socket_id]);
if (event == NULL) {
assert(false);
return NULL;
}
@ -170,7 +168,7 @@ spdk_event_free(uint32_t lcore, struct spdk_event *event)
uint8_t socket_id = rte_lcore_to_socket_id(lcore);
assert(socket_id < SPDK_MAX_SOCKET);
rte_mempool_put(g_spdk_event_mempool[socket_id], (void *)event);
spdk_mempool_put(g_spdk_event_mempool[socket_id], (void *)event);
}
void
@ -617,10 +615,9 @@ spdk_reactors_init(const char *mask, unsigned int max_delay_us)
for (i = 0; i < SPDK_MAX_SOCKET; i++) {
if ((1ULL << i) & socket_mask) {
snprintf(mempool_name, sizeof(mempool_name), "spdk_event_mempool_%d", i);
g_spdk_event_mempool[i] = rte_mempool_create(mempool_name,
g_spdk_event_mempool[i] = spdk_mempool_create(mempool_name,
(262144 / socket_count),
sizeof(struct spdk_event), 128, 0,
NULL, NULL, NULL, NULL, i, 0);
sizeof(struct spdk_event), -1);
if (g_spdk_event_mempool[i] == NULL) {
SPDK_ERRLOG("spdk_event_mempool creation failed on socket %d\n", i);
@ -631,13 +628,10 @@ spdk_reactors_init(const char *mask, unsigned int max_delay_us)
* memory is not evenly installed on all sockets. If still
* fails, free all allocated memory and exits.
*/
g_spdk_event_mempool[i] = rte_mempool_create(
g_spdk_event_mempool[i] = spdk_mempool_create(
mempool_name,
(262144 / socket_count),
sizeof(struct spdk_event),
128, 0,
NULL, NULL, NULL, NULL,
SOCKET_ID_ANY, 0);
sizeof(struct spdk_event), -1);
/* TODO: in DPDK 16.04, free mempool API is avaialbe. */
if (g_spdk_event_mempool[i] == NULL) {

View File

@ -34,8 +34,6 @@
#include <arpa/inet.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_version.h>
#include "spdk/log.h"
#include "spdk/conf.h"

View File

@ -32,12 +32,12 @@
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_mempool.h>
#include "spdk/env.h"

View File

@ -39,7 +39,6 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_mempool.h>
#include <rte_ring.h>
#include <rte_lcore.h>

View File

@ -32,9 +32,10 @@
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "spdk/nvme.h"

View File

@ -36,11 +36,12 @@
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "spdk/nvme.h"

View File

@ -31,13 +31,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_atomic.h>
#include <rte_lcore.h>
#include "spdk/fd.h"

View File

@ -32,11 +32,12 @@
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
#include "spdk/nvme.h"

View File

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