fio: allow general repeatability
authorChristian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Thu, 20 Feb 2014 17:10:17 +0000 (09:10 -0800)
committerJens Axboe <axboe@fb.com>
Thu, 20 Feb 2014 17:10:17 +0000 (09:10 -0800)
This patch adds a "allrandrepeat" option similar to the existing
randrepeat.  But other than the former option it does not only affect
the random I/O pattern, but also all remaining users of randomness as
well.

By that e.g. testcases using nrfiles, filesize ranges, blocksizesplit
ranges and so on will stay repeatable across (euqally parametrized) runs
as well.  To maintain compatibility the default is off.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Update by me to fix missing thread_options.h and cconv.c change.

Signed-off-by: Jens Axboe <axboe@fb.com>
cconv.c
fio.1
init.c
options.c
thread_options.h

diff --git a/cconv.c b/cconv.c
index b7d469e920141f862a33b5ee91f341195bbb7194..41ef6265d5695dfc6546ac8dd3b0dff110600e6b 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -142,6 +142,7 @@ void convert_thread_options_to_cpu(struct thread_options *o,
        o->do_disk_util = le32_to_cpu(top->do_disk_util);
        o->override_sync = le32_to_cpu(top->override_sync);
        o->rand_repeatable = le32_to_cpu(top->rand_repeatable);
+       o->allrand_repeatable = le32_to_cpu(top->allrand_repeatable);
        o->rand_seed = le64_to_cpu(top->rand_seed);
        o->use_os_rand = le32_to_cpu(top->use_os_rand);
        o->log_avg_msec = le32_to_cpu(top->log_avg_msec);
@@ -308,6 +309,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
        top->do_disk_util = cpu_to_le32(o->do_disk_util);
        top->override_sync = cpu_to_le32(o->override_sync);
        top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
+       top->allrand_repeatable = cpu_to_le32(o->allrand_repeatable);
        top->rand_seed = __cpu_to_le64(o->rand_seed);
        top->use_os_rand = cpu_to_le32(o->use_os_rand);
        top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
diff --git a/fio.1 b/fio.1
index 1df1cd1a2004ce2bc3fec5cce2a7f11424582592..aadb5ce2bc84bc2a1f0c761c1e8336d68e506e11 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -293,8 +293,12 @@ read, write, and trim are accounted and reported separately. If this option is
 set, the fio will sum the results and report them as "mixed" instead.
 .TP
 .BI randrepeat \fR=\fPbool
-Seed the random number generator in a predictable way so results are repeatable
-across runs.  Default: true.
+Seed the random number generator used for random I/O patterns in a predictable
+way so the pattern is repeatable across runs.  Default: true.
+.TP
+.BI allrandrepeat \fR=\fPbool
+Seed all random number generators in a predictable way so results are
+repeatable across runs.  Default: false.
 .TP
 .BI randseed \fR=\fPint
 Seed the random number generators based on this seed value, to be able to
diff --git a/init.c b/init.c
index 469e73dc433c4b9a020d6fb1bc5d2c17aa98960f..c3b33dccfaca2d538b39470532bc302be1544e5b 100644 (file)
--- a/init.c
+++ b/init.c
@@ -751,6 +751,12 @@ static void td_fill_rand_seeds_internal(struct thread_data *td)
 
 void td_fill_rand_seeds(struct thread_data *td)
 {
+       if (td->o.allrand_repeatable) {
+               for (int i = 0; i < FIO_RAND_NR_OFFS; i++)
+                       td->rand_seeds[i] = FIO_RANDSEED * td->thread_number
+                               + i;
+       }
+
        if (td->o.use_os_rand)
                td_fill_rand_seeds_os(td);
        else
index ea5166434cf7b56a2db8e5a9696987f115421d2a..4a68c01bc9e4a0a11368b10ca9586e179c5ab0be 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1783,6 +1783,13 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .category = FIO_OPT_C_IO,
                .group  = FIO_OPT_G_RANDOM,
        },
+       {
+               .name   = "allrandrepeat",
+               .type   = FIO_OPT_BOOL,
+               .off1   = td_var_offset(allrand_repeatable),
+               .help   = "Use repeatable random numbers for everything",
+               .def    = "0",
+       },
        {
                .name   = "nrfiles",
                .lname  = "Number of files",
index 79c3a89247876254a83d6adf8c9595a29cdffd3a..65eba7eebd2e02792b835161826d4bccdc390195 100644 (file)
@@ -100,6 +100,7 @@ struct thread_options {
        unsigned int do_disk_util;
        unsigned int override_sync;
        unsigned int rand_repeatable;
+       unsigned int allrand_repeatable;
        unsigned long long rand_seed;
        unsigned int use_os_rand;
        unsigned int log_avg_msec;
@@ -324,6 +325,7 @@ struct thread_options_pack {
        uint32_t do_disk_util;
        uint32_t override_sync;
        uint32_t rand_repeatable;
+       uint32_t allrand_repeatable;
        uint64_t rand_seed;
        uint32_t use_os_rand;
        uint32_t log_avg_msec;