From: Jens Axboe Date: Fri, 7 Apr 2017 22:04:31 +0000 (-0600) Subject: Split poisson rate control into read/write/trim X-Git-Tag: fio-2.20~55 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=6c8611c79713fe73fddf7458ab3ab36feaeae67b;hp=e07a8a2281c7a5a0ec4eb8e8e66601ca1f9f71bb Split poisson rate control into read/write/trim We currently have just one set of controls for this, which messes things up if we have separate iops/bandwidth settings for reads and writes, for instance. Split this into per-data direction controls, so that we can control them independently. Signed-off-by: Jens Axboe --- diff --git a/backend.c b/backend.c index 38ef3482..86e689f8 100644 --- a/backend.c +++ b/backend.c @@ -811,13 +811,13 @@ static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir) uint64_t val; iops = bps / td->o.bs[ddir]; val = (int64_t) (1000000 / iops) * - -logf(__rand_0_1(&td->poisson_state)); + -logf(__rand_0_1(&td->poisson_state[ddir])); if (val) { dprint(FD_RATE, "poisson rate iops=%llu\n", (unsigned long long) 1000000 / val); } - td->last_usec += val; - return td->last_usec; + td->last_usec[ddir] += val; + return td->last_usec[ddir]; } else if (bps) { secs = bytes / bps; remainder = bytes % bps; diff --git a/fio.h b/fio.h index 3955a819..8171b9ab 100644 --- a/fio.h +++ b/fio.h @@ -100,6 +100,8 @@ enum { FIO_DEDUPE_OFF, FIO_RAND_POISSON_OFF, FIO_RAND_ZONE_OFF, + FIO_RAND_POISSON2_OFF, + FIO_RAND_POISSON3_OFF, FIO_RAND_NR_OFFS, }; @@ -281,8 +283,8 @@ struct thread_data { unsigned long rate_blocks[DDIR_RWDIR_CNT]; unsigned long long rate_io_issue_bytes[DDIR_RWDIR_CNT]; struct timeval lastrate[DDIR_RWDIR_CNT]; - int64_t last_usec; - struct frand_state poisson_state; + int64_t last_usec[DDIR_RWDIR_CNT]; + struct frand_state poisson_state[DDIR_RWDIR_CNT]; /* * Enforced rate submission/completion workqueue diff --git a/init.c b/init.c index 2f9433b4..9aa452da 100644 --- a/init.c +++ b/init.c @@ -523,7 +523,7 @@ static int __setup_rate(struct thread_data *td, enum fio_ddir ddir) td->rate_next_io_time[ddir] = 0; td->rate_io_issue_bytes[ddir] = 0; - td->last_usec = 0; + td->last_usec[ddir] = 0; return 0; } @@ -933,7 +933,9 @@ static void td_fill_rand_seeds_internal(struct thread_data *td, bool use64) init_rand_seed(&td->file_size_state, td->rand_seeds[FIO_RAND_FILE_SIZE_OFF], use64); init_rand_seed(&td->trim_state, td->rand_seeds[FIO_RAND_TRIM_OFF], use64); init_rand_seed(&td->delay_state, td->rand_seeds[FIO_RAND_START_DELAY], use64); - init_rand_seed(&td->poisson_state, td->rand_seeds[FIO_RAND_POISSON_OFF], 0); + init_rand_seed(&td->poisson_state[0], td->rand_seeds[FIO_RAND_POISSON_OFF], 0); + init_rand_seed(&td->poisson_state[1], td->rand_seeds[FIO_RAND_POISSON2_OFF], 0); + init_rand_seed(&td->poisson_state[2], td->rand_seeds[FIO_RAND_POISSON3_OFF], 0); init_rand_seed(&td->dedupe_state, td->rand_seeds[FIO_DEDUPE_OFF], false); init_rand_seed(&td->zone_state, td->rand_seeds[FIO_RAND_ZONE_OFF], false);