commit | 9da67e75febb49f29b1657e93e592b656ec84f11 | [log] [tgz] |
---|---|---|
author | Jens Axboe <axboe@fb.com> | Mon Apr 14 09:47:14 2014 -0600 |
committer | Jens Axboe <axboe@fb.com> | Mon Apr 14 09:47:14 2014 -0600 |
tree | 5fdea6550ef39ed4d89d7749bf83e41a826d136b | |
parent | 476882d7947f650783b255a8da74954069af90de [diff] [blame] |
idletime: fix potential divide-by-zero Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/idletime.c b/idletime.c index c0bc0bf..bc80976 100644 --- a/idletime.c +++ b/idletime.c
@@ -336,7 +336,10 @@ /* 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; }