idletime: fix potential divide-by-zero
authorJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 15:47:14 +0000 (09:47 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 15:47:14 +0000 (09:47 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
idletime.c

index c0bc0bf..bc80976 100644 (file)
@@ -336,7 +336,10 @@ void fio_idle_prof_stop(void)
                /* calculate idleness */
                if (ipc.cali_mean != 0.0) {
                        runt = utime_since(&ipt->tps, &ipt->tpe);
-                       ipt->idleness = ipt->loops * ipc.cali_mean / runt;
+                       if (runt)
+                               ipt->idleness = ipt->loops * ipc.cali_mean / runt;
+                       else
+                               ipt->idleness = 0.0;
                } else
                        ipt->idleness = 0.0;
        }