diff --git a/examples/nvme/arbitration/arbitration.c b/examples/nvme/arbitration/arbitration.c index 9aa71c047..9e44e519b 100644 --- a/examples/nvme/arbitration/arbitration.c +++ b/examples/nvme/arbitration/arbitration.c @@ -1088,6 +1088,7 @@ main(int argc, char **argv) int rc; struct worker_thread *worker; char task_pool_name[30]; + uint32_t task_count; rc = parse_args(argc, argv); if (rc != 0) { @@ -1110,17 +1111,6 @@ main(int argc, char **argv) return 1; } - snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", getpid()); - - task_pool = rte_mempool_create(task_pool_name, 8192, - sizeof(struct arb_task), - 64, 0, NULL, NULL, task_ctor, NULL, - SOCKET_ID_ANY, 0); - if (task_pool == NULL) { - fprintf(stderr, "could not initialize task pool\n"); - return 1; - } - g_arbitration.tsc_rate = spdk_get_ticks_hz(); if (register_workers() != 0) { @@ -1135,6 +1125,26 @@ main(int argc, char **argv) return 1; } + snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", getpid()); + + /* + * The task_count will be dynamically calculated based on the + * number of attached active namespaces, queue depth and number + * of cores (workers) involved in the IO perations. + */ + task_count = g_arbitration.num_namespaces > g_arbitration.num_workers ? + g_arbitration.num_namespaces : g_arbitration.num_workers; + task_count *= g_arbitration.queue_depth; + + task_pool = rte_mempool_create(task_pool_name, task_count, + sizeof(struct arb_task), + 0, 0, NULL, NULL, task_ctor, NULL, + SOCKET_ID_ANY, 0); + if (task_pool == NULL) { + fprintf(stderr, "could not initialize task pool\n"); + return 1; + } + print_configuration(argv[0]); printf("Initialization complete. Launching workers.\n"); diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index b19a1efb4..8a04fec31 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -1188,6 +1188,7 @@ int main(int argc, char **argv) int rc; struct worker_thread *worker; char task_pool_name[30]; + uint32_t task_count; rc = parse_args(argc, argv); if (rc != 0) { @@ -1217,17 +1218,6 @@ int main(int argc, char **argv) return 1; } - snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", getpid()); - - task_pool = rte_mempool_create(task_pool_name, 8192, - sizeof(struct perf_task), - 64, 0, NULL, NULL, task_ctor, NULL, - SOCKET_ID_ANY, 0); - if (task_pool == NULL) { - fprintf(stderr, "could not initialize task pool\n"); - return 1; - } - g_tsc_rate = spdk_get_ticks_hz(); if (register_workers() != 0) { @@ -1250,6 +1240,26 @@ int main(int argc, char **argv) goto cleanup; } + snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", getpid()); + + /* + * The task_count will be dynamically calculated based on the + * number of attached active namespaces(aio files), queue depth + * and number of cores (workers) involved in the IO operations. + */ + task_count = g_num_namespaces > g_num_workers ? g_num_namespaces : g_num_workers; + task_count *= g_queue_depth; + + task_pool = rte_mempool_create(task_pool_name, task_count, + sizeof(struct perf_task), + 0, 0, NULL, NULL, task_ctor, NULL, + SOCKET_ID_ANY, 0); + if (task_pool == NULL) { + fprintf(stderr, "could not initialize task pool\n"); + rc = -1; + goto cleanup; + } + printf("Initialization complete. Launching workers.\n"); /* Launch all of the slave workers */