From 4f9f191c8925c752121bd752db50e6fa602709ec Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 6 Apr 2017 09:59:32 -0700 Subject: [PATCH] nvme/perf: align buffers to block size for libaio This is required by libaio. Previously, buffers were aligned to 512 bytes, but 4K devices need 4K-aligned buffers. Change-Id: I96080e72dc77e0e72f426f7c9fe98b6724f66e1b Signed-off-by: Daniel Verkamp --- examples/nvme/perf/perf.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index be781a3a0..1def610ff 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -141,6 +141,7 @@ static int g_num_workers = 0; static uint64_t g_tsc_rate; +static uint32_t g_io_align = 0x200; static uint32_t g_io_size_bytes; static int g_rw_percentage; static int g_is_random; @@ -336,6 +337,14 @@ register_aio_file(const char *path) return -1; } + /* + * TODO: This should really calculate the LCM of the current g_io_align and blklen. + * For now, it's fairly safe to just assume all block sizes are powers of 2. + */ + if (g_io_align < blklen) { + g_io_align = blklen; + } + entry = malloc(sizeof(struct ns_entry)); if (entry == NULL) { close(fd); @@ -401,7 +410,7 @@ aio_check_io(struct ns_worker_ctx *ns_ctx) static void task_ctor(struct rte_mempool *mp, void *arg, void *__task, unsigned id) { struct perf_task *task = __task; - task->buf = spdk_zmalloc(g_io_size_bytes, 0x200, NULL); + task->buf = spdk_zmalloc(g_io_size_bytes, g_io_align, NULL); if (task->buf == NULL) { fprintf(stderr, "task->buf spdk_zmalloc failed\n"); exit(1);