From 6ee7dd5375a74b6ec99d0960e44fe09d14015eba Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 7 May 2021 00:02:40 +0000 Subject: [PATCH] nvme/perf: move rand_r seed to ns_entry_ This eliminates the thread-local seed variable. But we're also adding zipf distributions in an upcoming patch, and we'll want to store that context in the ns_entry rather than making it thread local. Signed-off-by: Jim Harris Change-Id: Icc4a8b7bdbc9cd35525f2d35c9ada8e3ec0ba76c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7791 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Community-CI: Mellanox Build Bot --- examples/nvme/perf/perf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index e38ee8f06..530ea5120 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -105,6 +105,7 @@ struct ns_entry { uint32_t block_size; uint32_t md_size; bool md_interleave; + unsigned int seed; bool pi_loc; enum spdk_nvme_pi_type pi_type; uint32_t io_flags; @@ -1341,8 +1342,6 @@ register_ctrlr(struct spdk_nvme_ctrlr *ctrlr, struct trid_entry *trid_entry) } } -static __thread unsigned int seed = 0; - static inline void submit_single_io(struct perf_task *task) { @@ -1352,7 +1351,7 @@ submit_single_io(struct perf_task *task) struct ns_entry *entry = ns_ctx->entry; if (g_is_random) { - offset_in_ios = rand_r(&seed) % entry->size_in_ios; + offset_in_ios = rand_r(&entry->seed) % entry->size_in_ios; } else { offset_in_ios = ns_ctx->offset_in_ios++; if (ns_ctx->offset_in_ios == entry->size_in_ios) { @@ -1363,7 +1362,7 @@ submit_single_io(struct perf_task *task) task->submit_tsc = spdk_get_ticks(); if ((g_rw_percentage == 100) || - (g_rw_percentage != 0 && ((rand_r(&seed) % 100) < g_rw_percentage))) { + (g_rw_percentage != 0 && ((rand_r(&entry->seed) % 100) < g_rw_percentage))) { task->is_read = true; } else { task->is_read = false;