X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=steadystate.c;h=ad19318c2a23f50cda50f6aef7927e4f0adde022;hb=855dc4d44e000b68c01b0e33eae3389b49eb7f7f;hp=2017ca67a896fbaba39e7b9e8a7c24369003d5a1;hpb=358ffaa6c37acb26e0f507934ba8a6f98f34ffee;p=fio.git diff --git a/steadystate.c b/steadystate.c index 2017ca67..ad19318c 100644 --- a/steadystate.c +++ b/steadystate.c @@ -2,7 +2,6 @@ #include "fio.h" #include "steadystate.h" -#include "helper_thread.h" bool steadystate_enabled = false; @@ -197,7 +196,7 @@ static bool steadystate_deviation(uint64_t iops, uint64_t bw, return false; } -void steadystate_check(void) +int steadystate_check(void) { int i, j, ddir, prev_groupid, group_ramp_time_over = 0; unsigned long rate_time; @@ -209,6 +208,7 @@ void steadystate_check(void) prev_groupid = -1; for_each_td(td, i) { + const bool needs_lock = td_async_processing(td); struct steadystate_data *ss = &td->ss; if (!ss->dur || td->runstate <= TD_SETTING_UP || @@ -236,23 +236,20 @@ void steadystate_check(void) ss->state |= FIO_SS_RAMP_OVER; } - td_io_u_lock(td); + if (needs_lock) + __td_io_u_lock(td); + for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) { td_iops += td->io_blocks[ddir]; td_bytes += td->io_bytes[ddir]; } - td_io_u_unlock(td); + + if (needs_lock) + __td_io_u_unlock(td); rate_time = mtime_since(&ss->prev_time, &now); memcpy(&ss->prev_time, &now, sizeof(now)); - /* - * Begin monitoring when job starts but don't actually use - * data in checking stopping criterion until ss->ramp_time is - * over. This ensures that we will have a sane value in - * prev_iops/bw the first time through after ss->ramp_time - * is done. - */ if (ss->state & FIO_SS_RAMP_OVER) { group_bw += 1000 * (td_bytes - ss->prev_bytes) / rate_time; group_iops += 1000 * (td_iops - ss->prev_iops) / rate_time; @@ -298,6 +295,7 @@ void steadystate_check(void) } } } + return 0; } int td_steadystate_init(struct thread_data *td) @@ -351,6 +349,9 @@ uint64_t steadystate_bw_mean(struct thread_stat *ts) int i; uint64_t sum; + if (!ts->ss_dur) + return 0; + for (i = 0, sum = 0; i < ts->ss_dur; i++) sum += ts->ss_bw_data[i]; @@ -362,6 +363,9 @@ uint64_t steadystate_iops_mean(struct thread_stat *ts) int i; uint64_t sum; + if (!ts->ss_dur) + return 0; + for (i = 0, sum = 0; i < ts->ss_dur; i++) sum += ts->ss_iops_data[i];