summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2018-06-11 20:02:10 -0600
committerJens Axboe <axboe@kernel.dk>2018-06-11 20:02:10 -0600
commit49050b56681b17968256702a7a3ec0f545c7dad8 (patch)
treecbd45596c0f740dc30e3c5ffb39f1f83156c7ce3 /init.c
parentab5643cb04dac549b2202231d5c6e33339b7fe7d (diff)
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 <axboe@kernel.dk>
Diffstat (limited to 'init.c')
-rw-r--r--init.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/init.c b/init.c
index 9257d47..e25e5e4 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;