From 56e2a5fc76067c91738f7eb0efbd6ec6d349e0f2 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 20 Feb 2014 09:10:17 -0800 Subject: [PATCH] fio: allow general repeatability 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 Update by me to fix missing thread_options.h and cconv.c change. Signed-off-by: Jens Axboe --- cconv.c | 2 ++ fio.1 | 8 ++++++-- init.c | 6 ++++++ options.c | 7 +++++++ thread_options.h | 2 ++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cconv.c b/cconv.c index b7d469e9..41ef6265 100644 --- 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 1df1cd1a..aadb5ce2 100644 --- 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 469e73dc..c3b33dcc 100644 --- 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 diff --git a/options.c b/options.c index ea516643..4a68c01b 100644 --- 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", diff --git a/thread_options.h b/thread_options.h index 79c3a892..65eba7ee 100644 --- a/thread_options.h +++ b/thread_options.h @@ -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; -- 2.25.1