From 49050b56681b17968256702a7a3ec0f545c7dad8 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 11 Jun 2018 20:02:10 -0600 Subject: [PATCH] Fix start delay being the same across threads Two issues here: 1) We copy the start_delay into the original thread, which ends up offsetting job 2..N off the thread 1 start delay 2) We don't initialize the start delay random seed prior to generating the offsets Signed-off-by: Jens Axboe --- init.c | 20 +++++++++++--------- thread_options.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/init.c b/init.c index 9257d47c..e25e5e48 100644 --- a/init.c +++ b/init.c @@ -578,8 +578,7 @@ static int fixed_block_size(struct thread_options *o) static unsigned long long get_rand_start_delay(struct thread_data *td) { unsigned long long delayrange; - uint64_t frand_max; - unsigned long r; + uint64_t r, frand_max; delayrange = td->o.start_delay_high - td->o.start_delay; @@ -587,7 +586,7 @@ static unsigned long long get_rand_start_delay(struct thread_data *td) r = __rand(&td->delay_state); delayrange = (unsigned long long) ((double) delayrange * (r / (frand_max + 1.0))); - delayrange += td->o.start_delay; + delayrange += td->o.start_delay_orig; return delayrange; } @@ -685,8 +684,11 @@ static int fixup_options(struct thread_data *td) if (!o->file_size_high) o->file_size_high = o->file_size_low; - if (o->start_delay_high) + if (o->start_delay_high) { + if (!o->start_delay_orig) + o->start_delay_orig = o->start_delay; o->start_delay = get_rand_start_delay(td); + } if (o->norandommap && o->verify != VERIFY_NONE && !fixed_block_size(o)) { @@ -1456,6 +1458,11 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, } } + if (setup_random_seeds(td)) { + td_verror(td, errno, "setup_random_seeds"); + goto err; + } + if (fixup_options(td)) goto err; @@ -1511,11 +1518,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, td->groupid = groupid; prev_group_jobs++; - if (setup_random_seeds(td)) { - td_verror(td, errno, "setup_random_seeds"); - goto err; - } - if (setup_rate(td)) goto err; diff --git a/thread_options.h b/thread_options.h index 52026e36..8d13b79a 100644 --- a/thread_options.h +++ b/thread_options.h @@ -172,6 +172,7 @@ struct thread_options { unsigned int fdatasync_blocks; unsigned int barrier_blocks; unsigned long long start_delay; + unsigned long long start_delay_orig; unsigned long long start_delay_high; unsigned long long timeout; unsigned long long ramp_time; -- 2.25.1