From: Jens Axboe Date: Fri, 14 Dec 2012 19:37:06 +0000 (+0100) Subject: clock: ensure that we re-init if the clocksource changes from the default X-Git-Tag: fio-2.0.12~9 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=01423eae85a071ff6acee870edd696c7929723ba;p=fio.git clock: ensure that we re-init if the clocksource changes from the default Signed-off-by: Jens Axboe --- diff --git a/gettime.c b/gettime.c index 1ba18e99..9f23e3ff 100644 --- a/gettime.c +++ b/gettime.c @@ -22,6 +22,7 @@ static int last_tv_valid; enum fio_cs fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE; int fio_clock_source_set = 0; +enum fio_cs fio_clock_source_inited = CS_INVAL; #ifdef FIO_DEBUG_TIME @@ -262,7 +263,11 @@ static void calibrate_cpu_clock(void) void fio_clock_init(void) { + if (fio_clock_source == fio_clock_source_inited) + return; + last_tv_valid = 0; + fio_clock_source_inited = fio_clock_source; calibrate_cpu_clock(); /* diff --git a/gettime.h b/gettime.h index 309ef210..64651a1b 100644 --- a/gettime.h +++ b/gettime.h @@ -8,6 +8,7 @@ enum fio_cs { CS_GTOD = 1, CS_CGETTIME, CS_CPUCLOCK, + CS_INVAL, }; extern void fio_gettime(struct timeval *, void *); diff --git a/options.c b/options.c index 738c78bb..ae290edb 100644 --- a/options.c +++ b/options.c @@ -371,6 +371,7 @@ static int fio_clock_source_cb(void *data, const char *str) fio_clock_source = td->o.clocksource; fio_clock_source_set = 1; + fio_clock_init(); return 0; }