[PATCH v2 2/5] td: Initialize ramp_period_over based on options
Jan Kara <[email protected]> Fri, 19 Dec 2025 14:42:36 +0100
| Newsgroups | org.kernel.vger.fio |
|---|---|
| Message-ID | <[email protected]> |
Instead of checking whether ramp_time is specified each time we need to check whether we are in the ramp period, initialize ramp_period_over based on the ramp_time option. This will simplify things more significantly later when ramp up period can be defined in a different way. Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Jan Kara <[email protected]> --- fio_time.h | 1 + init.c | 2 ++ time.c | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fio_time.h b/fio_time.h index 30de7aca4fb1..c67c9450f484 100644 --- a/fio_time.h +++ b/fio_time.h @@ -29,6 +29,7 @@ extern void fill_start_time(struct timespec *); extern void set_genesis_time(void); extern bool ramp_period_over(struct thread_data *); extern bool in_ramp_period(struct thread_data *); +extern void td_ramp_period_init(struct thread_data *); extern void fio_time_init(void); extern void timespec_add_msec(struct timespec *, unsigned int); extern void set_epoch_time(struct thread_data *, clockid_t, clockid_t); diff --git a/init.c b/init.c index cf66ac2c51f1..8b7728907c7f 100644 --- a/init.c +++ b/init.c @@ -1676,6 +1676,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, init_thread_stat_min_vals(&td->ts); + td_ramp_period_init(td); + /* * td->>ddir_seq_nr needs to be initialized to 1, NOT o->ddir_seq_nr, * so that get_next_offset gets a new random offset the first time it diff --git a/time.c b/time.c index 9625e8cd92af..f90f2d9044fc 100644 --- a/time.c +++ b/time.c @@ -112,7 +112,7 @@ uint64_t utime_since_genesis(void) bool in_ramp_period(struct thread_data *td) { - return td->o.ramp_time && !td->ramp_period_over; + return !td->ramp_period_over; } static bool parent_update_ramp(struct thread_data *td) @@ -130,7 +130,7 @@ static bool parent_update_ramp(struct thread_data *td) bool ramp_period_over(struct thread_data *td) { - if (!td->o.ramp_time || td->ramp_period_over) + if (td->ramp_period_over) return true; if (utime_since_now(&td->epoch) >= td->o.ramp_time) { @@ -153,6 +153,12 @@ bool ramp_period_over(struct thread_data *td) return false; } +void td_ramp_period_init(struct thread_data *td) +{ + if (!td->o.ramp_time) + td->ramp_period_over = true; +} + void fio_time_init(void) { int i; -- 2.51.0