From: Jens Axboe Date: Thu, 27 Sep 2018 23:38:21 +0000 (-0600) Subject: gettime: slightly improve CPU clock calibration X-Git-Tag: fio-3.11~15 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=152529ae26d1167779138b6cd30d4de10623da1b gettime: slightly improve CPU clock calibration 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 --- diff --git a/gettime.c b/gettime.c index c0f26382..7702193d 100644 --- 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;