Change latency targets to be in nsec values internally
authorJens Axboe <axboe@kernel.dk>
Thu, 30 Nov 2017 04:52:46 +0000 (21:52 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 30 Nov 2017 04:52:46 +0000 (21:52 -0700)
Since all of our timekeeping is in nsec now, it's easier to convert
these at init time and not have to do it at runtime.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
init.c
io_u.c
profiles/act.c

diff --git a/init.c b/init.c
index acbbd4858b663efdb95bd9d4a2eb46299081cba4..7c16b0602e252ecd76dae31fe7d044af8f55ccb6 100644 (file)
--- a/init.c
+++ b/init.c
@@ -925,6 +925,13 @@ static int fixup_options(struct thread_data *td)
                ret = 1;
        }
 
+       /*
+        * Fix these up to be nsec internally
+        */
+       o->max_latency *= 1000ULL;
+       o->latency_target *= 1000ULL;
+       o->latency_window *= 1000ULL;
+
        return ret;
 }
 
diff --git a/io_u.c b/io_u.c
index 0466ac01e9246a6af3f86161e0cf3d052d07467c..ebe82e12e8f091b02dc4dd71c708435b642dcbc1 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1409,10 +1409,10 @@ static long set_io_u_file(struct thread_data *td, struct io_u *io_u)
 }
 
 static void lat_fatal(struct thread_data *td, struct io_completion_data *icd,
-                     unsigned long tusec, unsigned long max_usec)
+                     unsigned long long tnsec, unsigned long long max_nsec)
 {
        if (!td->error)
-               log_err("fio: latency of %lu usec exceeds specified max (%lu usec)\n", tusec, max_usec);
+               log_err("fio: latency of %llu nsec exceeds specified max (%llu nsec)\n", tnsec, max_nsec);
        td_verror(td, ETIMEDOUT, "max latency exceeded");
        icd->error = ETIMEDOUT;
 }
@@ -1862,24 +1862,23 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u,
                llnsec = ntime_since(&io_u->issue_time, &icd->time);
 
        if (!td->o.disable_lat) {
-               unsigned long long tnsec, tusec;
+               unsigned long long tnsec;
 
                tnsec = ntime_since(&io_u->start_time, &icd->time);
-               tusec = tnsec / 1000;
                add_lat_sample(td, idx, tnsec, bytes, io_u->offset);
 
                if (td->flags & TD_F_PROFILE_OPS) {
                        struct prof_io_ops *ops = &td->prof_io_ops;
 
                        if (ops->io_u_lat)
-                               icd->error = ops->io_u_lat(td, tusec);
+                               icd->error = ops->io_u_lat(td, tnsec);
                }
 
-               if (td->o.max_latency && tusec > td->o.max_latency)
-                       lat_fatal(td, icd, tusec, td->o.max_latency);
-               if (td->o.latency_target && tusec > td->o.latency_target) {
+               if (td->o.max_latency && tnsec > td->o.max_latency)
+                       lat_fatal(td, icd, tnsec, td->o.max_latency);
+               if (td->o.latency_target && tnsec > td->o.latency_target) {
                        if (lat_target_failed(td))
-                               lat_fatal(td, icd, tusec, td->o.latency_target);
+                               lat_fatal(td, icd, tnsec, td->o.latency_target);
                }
        }
 
index 4669535a9906f6b0ac34b45842de72681e30e268..3fa5afacba415a8bd4cc65850b22553c12974c8e 100644 (file)
@@ -288,10 +288,11 @@ static int act_prep_cmdline(void)
        return 0;
 }
 
-static int act_io_u_lat(struct thread_data *td, uint64_t usec)
+static int act_io_u_lat(struct thread_data *td, uint64_t nsec)
 {
        struct act_prof_data *apd = td->prof_data;
        struct act_slice *slice;
+       uint64_t usec = nsec / 1000ULL;
        int i, ret = 0;
        double perm;