From 760452eefe9a9ad32aa826cb3e12dc2b6a146d40 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 6 May 2021 23:18:58 +0000 Subject: [PATCH] bdevperf: store the rand_r seed in the bdevperf_job 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 job rather than making it thread local. Signed-off-by: Jim Harris Change-Id: If8079682e7d3da8f989ee6b880edc8d3fcb4fdd8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7789 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Community-CI: Mellanox Build Bot --- test/bdev/bdevperf/bdevperf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/bdev/bdevperf/bdevperf.c b/test/bdev/bdevperf/bdevperf.c index 9515f2b7a..fcdeed5ea 100644 --- a/test/bdev/bdevperf/bdevperf.c +++ b/test/bdev/bdevperf/bdevperf.c @@ -118,6 +118,7 @@ struct bdevperf_job { bool flush; bool abort; int queue_depth; + unsigned int seed; uint64_t io_completed; uint64_t io_failed; @@ -826,15 +827,13 @@ bdevperf_job_get_task(struct bdevperf_job *job) return task; } -static __thread unsigned int seed = 0; - static void bdevperf_submit_single(struct bdevperf_job *job, struct bdevperf_task *task) { uint64_t offset_in_ios; if (job->is_random) { - offset_in_ios = rand_r(&seed) % job->size_in_ios; + offset_in_ios = rand_r(&job->seed) % job->size_in_ios; } else { offset_in_ios = job->offset_in_ios++; if (job->offset_in_ios == job->size_in_ios) { @@ -884,7 +883,7 @@ bdevperf_submit_single(struct bdevperf_job *job, struct bdevperf_task *task) } else if (job->write_zeroes) { task->io_type = SPDK_BDEV_IO_TYPE_WRITE_ZEROES; } else if ((job->rw_percentage == 100) || - (job->rw_percentage != 0 && ((rand_r(&seed) % 100) < job->rw_percentage))) { + (job->rw_percentage != 0 && ((rand_r(&job->seed) % 100) < job->rw_percentage))) { task->io_type = SPDK_BDEV_IO_TYPE_READ; } else { if (g_zcopy) {