gettime: slightly improve CPU clock calibration
authorJens Axboe <axboe@kernel.dk>
Thu, 27 Sep 2018 23:38:21 +0000 (17:38 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 27 Sep 2018 23:38:21 +0000 (17:38 -0600)
We should not factor the utime_since() runtime into this, so
do the get_cpu_clock() before. In reality this probably won't
make any difference, as we're doing this tight loop for more
than a milisecond.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
gettime.c

index c0f2638..7702193 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -237,12 +237,11 @@ static unsigned long get_cycles_per_msec(void)
        c_s = get_cpu_clock();
        do {
                __fio_gettime(&e);
+               c_e = get_cpu_clock();
 
                elapsed = utime_since(&s, &e);
-               if (elapsed >= 1280) {
-                       c_e = get_cpu_clock();
+               if (elapsed >= 1280)
                        break;
-               }
        } while (1);
 
        fio_clock_source = old_cs;