X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=time.c;h=5c4d6de0399c5cc681e9ca362c019870baf9db98;hb=7ddc4ed1ce94639e3306f980a7c651da3dd81c1d;hp=28c20717406029bc584e583810e24416d0cf2457;hpb=3eeb162085b43311546e395039c19664ea781b0f;p=fio.git diff --git a/time.c b/time.c index 28c20717..5c4d6de0 100644 --- a/time.c +++ b/time.c @@ -57,6 +57,13 @@ uint64_t usec_sleep(struct thread_data *td, unsigned long usec) if (ts >= 1000000) { req.tv_sec = ts / 1000000; ts -= 1000000 * req.tv_sec; + /* + * Limit sleep to ~1 second at most, otherwise we + * don't notice then someone signaled the job to + * exit manually. + */ + if (req.tv_sec > 1) + req.tv_sec = 1; } else req.tv_sec = 0; @@ -105,7 +112,7 @@ static bool parent_update_ramp(struct thread_data *td) return false; reset_all_stats(parent); - parent->ramp_time_over = 1; + parent->ramp_time_over = true; td_set_runstate(parent, TD_RAMP); return true; } @@ -116,8 +123,9 @@ bool ramp_time_over(struct thread_data *td) return true; if (utime_since_now(&td->epoch) >= td->o.ramp_time) { - td->ramp_time_over = 1; + td->ramp_time_over = true; reset_all_stats(td); + reset_io_stats(td); td_set_runstate(td, TD_RAMP); /* @@ -164,14 +172,14 @@ void set_genesis_time(void) fio_gettime(&genesis, NULL); } -void set_epoch_time(struct thread_data *td, int log_unix_epoch) +void set_epoch_time(struct thread_data *td, int log_alternate_epoch, clockid_t clock_id) { fio_gettime(&td->epoch, NULL); - if (log_unix_epoch) { - struct timeval tv; - gettimeofday(&tv, NULL); - td->unix_epoch = (unsigned long long)(tv.tv_sec) * 1000 + - (unsigned long long)(tv.tv_usec) / 1000; + if (log_alternate_epoch) { + struct timespec ts; + clock_gettime(clock_id, &ts); + td->alternate_epoch = (unsigned long long)(ts.tv_sec) * 1000 + + (unsigned long long)(ts.tv_nsec) / 1000000; } }