From: Jens Axboe Date: Wed, 3 Aug 2016 15:11:56 +0000 (-0600) Subject: iolog: prevent early entry from skewing entire logging run X-Git-Tag: fio-2.14~62 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=f5a568cfb7c2738f80399dc155c964bc26cbb4b3 iolog: prevent early entry from skewing entire logging run If we go out of ramp time, our wakeup trigger could cause us to enter too early in add_log_sample(). If that happens, the time diff could be negative (so huge unsigned). Since we carry that forward, we end up logging every entry and not just over the average window. Signed-off-by: Jens Axboe --- diff --git a/stat.c b/stat.c index 7a35117a..d6787b7f 100644 --- a/stat.c +++ b/stat.c @@ -2139,7 +2139,9 @@ static long add_log_sample(struct thread_data *td, struct io_log *iolog, * need to do. */ this_window = elapsed - iolog->avg_last; - if (this_window < iolog->avg_msec) { + if (elapsed < iolog->avg_last) + return iolog->avg_last - elapsed; + else if (this_window < iolog->avg_msec) { int diff = iolog->avg_msec - this_window; if (inline_log(iolog) || diff > LOG_MSEC_SLACK)