Commit 11f43621 authored by GangCao's avatar GangCao Committed by Daniel Verkamp
Browse files

examples/nvme: add task_count to dynamically allocate memory



The memory allocation is based on user specified queue depth,
number of attached active namespaces(aio files) and number of
cores involved in the IO operations.

Change-Id: I370b9fdacc1bb40d110bec7e96adac2424d39431
Signed-off-by: default avatarGangCao <gang.cao@intel.com>
parent 950b48de
Loading
Loading
Loading
Loading
+21 −11
Original line number Diff line number Diff line
@@ -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");
+21 −11
Original line number Diff line number Diff line
@@ -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 */