summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-12-15 19:54:57 -0700
committerJens Axboe <axboe@fb.com>2014-12-15 19:54:57 -0700
commitf893b76d5745811033f056ae4d4efe4f571452bd (patch)
tree1f0defe153b3d21de717c1aac7d8ec1563ae3260
parent823952afda151688e8b509be4f4e09b4ac1efd75 (diff)
downloadfio-f893b76d5745811033f056ae4d4efe4f571452bd.tar.gz
fio-f893b76d5745811033f056ae4d4efe4f571452bd.tar.bz2
backend: use monotonic clock for ETA, if we have it
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--backend.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/backend.c b/backend.c
index f1def38b..3df0133f 100644
--- a/backend.c
+++ b/backend.c
@@ -2104,11 +2104,19 @@ static void *helper_thread_main(void *data)
uint64_t sec = DISK_UTIL_MSEC / 1000;
uint64_t nsec = (DISK_UTIL_MSEC % 1000) * 1000000;
struct timespec ts;
+
+#if defined(CONFIG_CLOCK_MONOTONIC)
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ ts.tv_sec += sec;
+ ts.tv_nsec += nsec;
+#else
struct timeval tv;
gettimeofday(&tv, NULL);
ts.tv_sec = tv.tv_sec + sec;
ts.tv_nsec = (tv.tv_usec * 1000) + nsec;
+#endif
+
if (ts.tv_nsec >= 1000000000ULL) {
ts.tv_nsec -= 1000000000ULL;
ts.tv_sec++;