Fix start delay being the same across threads
authorJens Axboe <axboe@kernel.dk>
Tue, 12 Jun 2018 02:02:10 +0000 (20:02 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 12 Jun 2018 02:02:10 +0000 (20:02 -0600)
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>
init.c
thread_options.h

diff --git a/init.c b/init.c
index 9257d47..e25e5e4 100644 (file)
--- 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;
 
index 52026e3..8d13b79 100644 (file)
@@ -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;