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.
[Modified by Jens to put the adj_sec in the branch.]
Signed-off-by: Jens Axboe <axboe@fb.com>
void timeval_add_msec(struct timeval *tv, unsigned int msec)
{
- tv->tv_usec += 1000 * msec;
- if (tv->tv_usec >= 1000000) {
+ unsigned int adj_usec = 1000 * msec;
+
+ tv->tv_usec += adj_usec;
+ if (adj_usec >= 1000000) {
+ unsigned int 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++;
}