Beispiel #1
0
static int
vtophys_positive_test(void)
{
	void *p = NULL;
	int i;
	unsigned int size = 1;
	int rc = 0;

	for (i = 0; i < 31; i++) {
		p = spdk_zmalloc(size, 512, NULL);
		if (p == NULL)
			continue;

		if (spdk_vtophys(p) == SPDK_VTOPHYS_ERROR) {
			rc = -1;
			printf("Err: VA=%p is not mapped to a huge_page,\n", p);
			spdk_free(p);
			break;
		}

		spdk_free(p);
		size = size << 1;
	}

	if (!rc)
		printf("vtophys_positive_test passed\n");
	else
		printf("vtophys_positive_test failed\n");

	return rc;
}
Beispiel #2
0
static void
initialize_buffer(char **buf, int pattern, int size)
{
	*buf = spdk_zmalloc(size, 0x1000, NULL);
	memset(*buf, pattern, size);
}
Beispiel #3
0
int main(int argc, char **argv)
{
	int rc;

	rc = parse_args(argc, argv);
	if (rc != 0) {
		return rc;
	}

	rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs);

	if (rc < 0) {
		fprintf(stderr, "could not initialize dpdk\n");
		return 1;
	}

	g_task = spdk_zmalloc(sizeof(struct perf_task), 0, NULL);
	if (g_task == NULL) {
		fprintf(stderr, "g_task alloc failed\n");
		exit(1);
	}

	g_task->buf = spdk_zmalloc(g_io_size_bytes, 0x1000, NULL);
	if (g_task->buf == NULL) {
		fprintf(stderr, "g_task->buf spdk_zmalloc failed\n");
		exit(1);
	}

	g_tsc_rate = spdk_get_ticks_hz();

#if HAVE_LIBAIO
	if (g_aio_optind < argc) {
		printf("Measuring overhead for AIO device %s.\n", argv[g_aio_optind]);
		if (register_aio_file(argv[g_aio_optind]) != 0) {
			rc = -1;
			goto cleanup;
		}
	} else
#endif
	{
		if (register_controllers() != 0) {
			rc = -1;
			goto cleanup;
		}
	}

	printf("Initialization complete. Launching workers.\n");

	rc = work_fn();

	print_stats();

cleanup:
	free(g_ns);
	if (g_ctrlr) {
		spdk_nvme_detach(g_ctrlr->ctrlr);
		free(g_ctrlr);
	}

	if (rc != 0) {
		fprintf(stderr, "%s: errors occured\n", argv[0]);
	}

	return rc;
}