commit | 400531d97395b64e416e0adfdb041419d3994621 | [log] [tgz] |
---|---|---|
author | Jens Axboe <axboe@fb.com> | Tue Dec 16 22:40:37 2014 -0700 |
committer | Mohamad Ayyash <mkayyash@google.com> | Fri Mar 06 17:58:09 2015 -0800 |
tree | b71e99c487e4e7be72833cb8c871338212d67e99 | |
parent | 80ac020b479bd433590d221fcefa3eb47327f9a3 [diff] |
gettime: fix overflow in cycle to usec conversion If this multiplication overflows: usecs = (t * inv_cycles_per_usec) / 16777216UL; then usecs is 2^64/2^24, which is 1099511627776. Divide that by 10^6 to get seconds, and that is 1099511. Since we cached the old value previously, we'd get stuck with this amount of seconds. To avoid turning this into an expensive division, have a check and only divide if we have to. This avoids the overflow. Signed-off-by: Jens Axboe <axboe@fb.com>