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 c0f26382721d0be7e01d413b8a33bcca6ac04921..7702193dc0b7eced79b5ade5b9a9d07553b9a10e 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_s = get_cpu_clock();
        do {
                __fio_gettime(&e);
+               c_e = get_cpu_clock();
 
                elapsed = utime_since(&s, &e);
 
                elapsed = utime_since(&s, &e);
-               if (elapsed >= 1280) {
-                       c_e = get_cpu_clock();
+               if (elapsed >= 1280)
                        break;
                        break;
-               }
        } while (1);
 
        fio_clock_source = old_cs;
        } while (1);
 
        fio_clock_source = old_cs;