From 20a01a04950bdd71674bc53b602633fe9ac4d6b3 Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Tue, 23 Mar 2021 08:59:05 +0000 Subject: [PATCH] nvme/fio_plugin: use calloc to allocate zone report buffer spdk_nvme_zns_report_zones() is implemented using nvme_allocate_request_user_copy(), which under the hood will do a spdk_zmalloc() with the SPDK_MALLOC_DMA flag set, and will copy over the result to our buffer. Therefore, it is redundant for us to use spdk_dma_zmalloc(), because it will cause us to allocate twice the amount of memory from the precious DMA pool than needed. Changing this zone report buffer allocation to a calloc also has the benefit of making the code uniform with all other spdk_nvme_zns_report_zones() call sites in the SPDK codebase. Signed-off-by: Niklas Cassel Change-Id: Ia354fa51c66ae07a38a9a57b07c15d145dd609f0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7005 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- examples/nvme/fio_plugin/fio_plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index 02a91234d..e1eef0082 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -1243,7 +1243,7 @@ spdk_fio_report_zones(struct thread_data *td, struct fio_file *f, uint64_t offse report_nzones_max = (mdts_nbytes - sizeof(*report)) / sizeof(report->descs[0]); report_nzones_max = spdk_min(spdk_min(report_nzones_max, nr_zones), ns_nzones); report_nbytes = sizeof(report->descs[0]) * report_nzones_max + sizeof(*report); - report = spdk_dma_zmalloc(report_nbytes, NVME_IO_ALIGN, NULL); + report = calloc(1, report_nbytes); if (!report) { log_err("spdk/nvme: failed report_zones(): ENOMEM\n"); return -ENOMEM; @@ -1310,7 +1310,7 @@ spdk_fio_report_zones(struct thread_data *td, struct fio_file *f, uint64_t offse } exit: - spdk_dma_free(report); + free(report); return err ? err : (int)report_nzones; }