FIO log averaging issue with --write_bw_log and --write_iops_log using > 1000 log_avg_msec values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is an issue in FIO when using the detailed bandwidth and iops logging with averaging over a period of time > 1 second.
It seems that usecs overflows which later causes negative time diff values resulting in skewed toward 0 results.
I have attached a potential fix that should prevent usecs from going beyond 1000000.

diff --git a/time.c b/time.c
index f5dc049..c748bee 100644
--- a/time.c
+++ b/time.c
@@ -8,11 +8,18 @@ static unsigned long ns_granularity;

void timeval_add_msec(struct timeval *tv, unsigned int msec)
{
-       tv->tv_usec += 1000 * msec;
-       if (tv->tv_usec >= 1000000) {
-               tv->tv_usec -= 1000000;
-               tv->tv_sec++;
-       }
+       int adj_usec = 1000 * msec;
+       int adj_sec = 0;
+       tv->tv_usec +=  adj_usec;
+       if (adj_usec >= 1000000) {
+               adj_sec = adj_usec / 1000000;
+               tv->tv_usec -=  adj_sec * 1000000;
+               tv->tv_sec += adj_sec;
+    }
+    if (tv->tv_usec >= 1000000){
+            tv->tv_usec -= 1000000;
+            tv->tv_sec++;
+    }
}

/*

--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux