Merge branch 'histograms-PR' of https://github.com/cronburg/fio
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index 965ff9fc129dcdf791a3d67f6f3a1e516fdafa79..96af94ba683deb5b4de2420e7fd04cf10e7b7d88 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -2140,7 +2140,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)