From df8fb6097058098f1c2f7c2cf4019640561768df Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 21 Nov 2014 14:33:33 -0700 Subject: [PATCH 1/1] iolog: account for wasted time in ipo stall Signed-off-by: Jens Axboe --- fio.h | 1 + iolog.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fio.h b/fio.h index 0601b376..5e352c6c 100644 --- a/fio.h +++ b/fio.h @@ -252,6 +252,7 @@ struct thread_data { struct timeval start; /* start of this loop */ struct timeval epoch; /* time job was started */ struct timeval last_issue; + long time_offset; struct timeval tv_cache; struct timeval terminate_time; unsigned int tv_cache_nr; diff --git a/iolog.c b/iolog.c index 785e549a..99f8bc18 100644 --- a/iolog.c +++ b/iolog.c @@ -60,14 +60,22 @@ void log_file(struct thread_data *td, struct fio_file *f, static void iolog_delay(struct thread_data *td, unsigned long delay) { - unsigned long usec = utime_since_now(&td->last_issue); - unsigned long this_delay; + uint64_t usec = utime_since_now(&td->last_issue); + uint64_t this_delay; + struct timeval tv; + if (delay < td->time_offset) { + td->time_offset = 0; + return; + } + + delay -= td->time_offset; if (delay < usec) return; delay -= usec; + fio_gettime(&tv, NULL); while (delay && !td->terminate) { this_delay = delay; if (this_delay > 500000) @@ -76,6 +84,12 @@ static void iolog_delay(struct thread_data *td, unsigned long delay) usec_sleep(td, this_delay); delay -= this_delay; } + + usec = utime_since_now(&tv); + if (usec > delay) + td->time_offset = usec - delay; + else + td->time_offset = 0; } static int ipo_special(struct thread_data *td, struct io_piece *ipo) -- 2.25.1